本文介绍了在Jetty上使用焊接CDI的异常:未为STATIC_INSTANCE设置单例的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试使用JSF和Weld CDI配置Jetty。遵循手册之后,我偶然发现了以下堆栈跟踪:
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
有人
推荐答案
如果您忘记了 beans.xml 文件,则会出现此错误或者,就我而言,您将其放置在错误的位置。您的beans.xml只能具有根元素,但必须存在。
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.
对于 Maven 项目,请记住:
-
context.xml
应该留在src / main / webapp / META-INF /
-
beans.xml
应该保留在src / main / resources / META中-INF /
context.xml
shoud stay insrc/main/webapp/META-INF/
beans.xml
should stay insrc/main/resources/META-INF/
我在移动使用Glassfish开发的应用程序时遇到了这个问题(需要这些文件)到Tomcat 7。
I had this problem when I moved an application developed using Glassfish (that doesn't need these files) to Tomcat 7.
这篇关于在Jetty上使用焊接CDI的异常:未为STATIC_INSTANCE设置单例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!