Exception using CDI welding with Jetty: Singleton not set for STATIC_INSTANCE

I am trying to configure Jetty with JSF and Weld CDI. After completing this tutorial, I came across the following stack:

Caused by: java.lang.IllegalStateException: Singleton not set for STATIC_INSTANCE => [] at org.jboss.weld.bootstrap.api.helpers.RegistrySingletonProvider$RegistrySingleton.get(RegistrySingletonProvider.java:28) at org.jboss.weld.Container.instance(Container.java:55) at org.jboss.weld.SimpleCDI.<init>(SimpleCDI.java:77) at org.jboss.weld.environment.WeldProvider$EnvironmentCDI.<init>(WeldProvider.java:45) at org.jboss.weld.environment.WeldProvider.getCDI(WeldProvider.java:61) at javax.enterprise.inject.spi.CDI.current(CDI.java:60) at org.jboss.weld.servlet.WeldInitialListener.contextInitialized(WeldInitialListener.java:94) at org.jboss.weld.servlet.api.helpers.ForwardingServletListener.contextInitialized(ForwardingServletListener.java:34) at org.jboss.weld.environment.servlet.EnhancedListener.onStartup(EnhancedListener.java:65) at org.eclipse.jetty.plus.annotation.ContainerInitializer.callStartup(ContainerInitializer.java:140) at org.eclipse.jetty.annotations.ServletContainerInitializersStarter.doStart(ServletContainerInitializersStarter.java:63) ... 50 more 

Does anyone see what is going wrong here?

+6
source share
2 answers

This error appears if you forget the beans.xml file or, as in my case, you put it in the wrong place. Your beans.xml can only have a root element, but must exist.

For the Maven project, remember that:

  • context.xml shoud stay in src/main/webapp/META-INF/
  • beans.xml should remain in src/main/resources/META-INF/

I had this problem when I moved an application developed using Glassfish (which does not need these files) for Tomcat 7.

+3
source

The problem is that you are using both weld-servlet and weld-servlet-core in your pom. This causes duplication of class entries, since the welded servlet is a combination of a servo core. Removing the dependencies of the core of the welded channel fixed a single error not found.

Now that I have done this, I got errors in the JSF, but these may be other configuration problems.

+1
source

All Articles