Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

I am trying to configure Jetty with JSF and Weld CDI. After following this manual, I stumble upon the following stacktrace:

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 someone see what is going wrong here?

like image 718
Jan-Willem Gmelig Meyling Avatar asked Mar 22 '16 21:03

Jan-Willem Gmelig Meyling


1 Answers

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

For a Maven project remember that:

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

I had this problem when I moved an application developed using Glassfish (that doesn't need these files) to Tomcat 7.

like image 118
xonya Avatar answered Oct 22 '22 05:10

xonya