无法解析 JMSContext 注入
JMSContext injection cannot be resolved
我在我的 websphere
上创建了一个 connectionFactory (qcf/cont) 和一个队列 (queue/Impact)
当我尝试在我的消息驱动 bean 中注入连接工厂时,我遇到了这个错误:
javax.ejb.EJBException: The @Inject java.lang.reflect.Field.context reference of type javax.jms.JMSContext for the XXXXProducerBean component in the XXXEJB-5.1-SNAPSHOT.jar module of the XXXXServiceEAR application cannot be resolved.
at com.ibm.wsspi.injectionengine.InjectionBinding.getInjectionObject(InjectionBinding.java:1154) ~[com.ibm.ws.runtime.jar:na]
at com.ibm.wsspi.injectionengine.InjectionBinding.getInjectableObject(InjectionBinding.java:1032) ~[com.ibm.ws.runtime.jar:na]
at com.ibm.wsspi.injectionengine.InjectionTarget.inject(InjectionTarget.java:125) ~[com.ibm.ws.runtime.jar:na]
at com.ibm.ws.injectionengine.AbstractInjectionEngine.inject(AbstractInjectionEngine.java:1084) ~[na:na]
at com.ibm.ejs.container.StatelessBeanO.initialize(StatelessBeanO.java:289) ~[com.ibm.ws.runtime.jar:na]
at com.ibm.ejs.container.BeanOFactory.create(BeanOFactory.java:130) ~[com.ibm.ws.runtime.jar:na]
at com.ibm.ejs.container.EJSHome.createNewBeanO(EJSHome.java:869) ~[com.ibm.ws.runtime.jar:na]
at com.ibm.ejs.container.EJSHome.createBeanO(EJSHome.java:1242) ~[com.ibm.ws.runtime.jar:na]
at com.ibm.ejs.container.EJSHome.createBeanO(EJSHome.java:1360) ~[com.ibm.ws.runtime.jar:na]
at com.ibm.ejs.container.activator.UncachedActivationStrategy.atActivate(UncachedActivationStrategy.java:89) ~[com.ibm.ws.runtime.jar:na]
at com.ibm.ejs.container.activator.Activator.preInvokeActivateBean(Activator.java:324) ~[com.ibm.ws.runtime.jar:na]
at com.ibm.ejs.container.EJSContainer.preInvokeActivate(EJSContainer.java:3728) ~[com.ibm.ws.runtime.jar:na]
at com.ibm.ejs.container.EJSContainer.EjbPreInvoke(EJSContainer.java:3042) ~[com.ibm.ws.runtime.jar:na]
我的 mdb 看起来像这样:
@Stateless
@Remote({ IXXXX.class })
@Interceptors(SpringBeanAutowiringInterceptor.class)
@TransactionAttribute(TransactionAttributeType.REQUIRED)
@TransactionManagement(TransactionManagementType.CONTAINER)
@DeclareRoles(Constants.USER_ROLE_NAME)
@RolesAllowed(Constants.USER_ROLE_NAME)
public class XXXXProducerBean implements IXXXX {
@Inject
@JMSConnectionFactory("qcf/cont")
private JMSContext context;
@Resource(name="queue/Impact")
private Destination queueImpact;
我在 Internet 上找到的所有文档中,JMSContext 似乎在没有任何配置的情况下被注入...是否缺少某些内容?
编辑
感谢 Eddie 提供 beans.xml 文件。我忘了。
但现在我有另一个例外:
[10/04/15 09:34:55:031 CEST] 0000006e BeansDeployer E BeansDeployer deploy
javax.enterprise.inject.UnsatisfiedResolutionException: Api type [javax.jms.JMSContext] is not found with the qualifiers
Qualifiers: [@javax.enterprise.inject.Default()]
for injection into
Field Injection Point, field : private javax.jms.JMSContext com.package.producer.ejb.XXXXProducerBean.context, Bean Owner : [WSEjbBean [businessLocals=[], ejbName=XXXXProducerBean2142018237,Name:null,WebBeans Type:ENTERPRISE,API Types:[java.lang.Object],Qualifiers:[javax.enterprise.inject.Any,javax.enterprise.inject.Default]]
InjectionType : [interface javax.jms.JMSContext]
Annotated : [Annotated Field,Base Type : interface javax.jms.JMSContext,Type Closures : [interface javax.jms.JMSContext, interface java.lang.AutoCloseable, class java.lang.Object],Annotations : [@javax.jms.JMSConnectionFactory(value=qcf/cont), @javax.inject.Inject()],Java Member Name : context]
Qualifiers : [[@javax.enterprise.inject.Default()]]
at org.apache.webbeans.util.InjectionExceptionUtils.throwUnsatisfiedResolutionException(InjectionExceptionUtils.java:92)
WebSphere 支持 JMS 1.1 而非 2.0。 @JMSConnectionFactory
来自 2.0。您需要像这样将其更改为 @Resource
:
@Resource("qcf/cont")
private ConnectionFactory connectionFactory;
我在我的 websphere
上创建了一个 connectionFactory (qcf/cont) 和一个队列 (queue/Impact)
当我尝试在我的消息驱动 bean 中注入连接工厂时,我遇到了这个错误:
javax.ejb.EJBException: The @Inject java.lang.reflect.Field.context reference of type javax.jms.JMSContext for the XXXXProducerBean component in the XXXEJB-5.1-SNAPSHOT.jar module of the XXXXServiceEAR application cannot be resolved.
at com.ibm.wsspi.injectionengine.InjectionBinding.getInjectionObject(InjectionBinding.java:1154) ~[com.ibm.ws.runtime.jar:na]
at com.ibm.wsspi.injectionengine.InjectionBinding.getInjectableObject(InjectionBinding.java:1032) ~[com.ibm.ws.runtime.jar:na]
at com.ibm.wsspi.injectionengine.InjectionTarget.inject(InjectionTarget.java:125) ~[com.ibm.ws.runtime.jar:na]
at com.ibm.ws.injectionengine.AbstractInjectionEngine.inject(AbstractInjectionEngine.java:1084) ~[na:na]
at com.ibm.ejs.container.StatelessBeanO.initialize(StatelessBeanO.java:289) ~[com.ibm.ws.runtime.jar:na]
at com.ibm.ejs.container.BeanOFactory.create(BeanOFactory.java:130) ~[com.ibm.ws.runtime.jar:na]
at com.ibm.ejs.container.EJSHome.createNewBeanO(EJSHome.java:869) ~[com.ibm.ws.runtime.jar:na]
at com.ibm.ejs.container.EJSHome.createBeanO(EJSHome.java:1242) ~[com.ibm.ws.runtime.jar:na]
at com.ibm.ejs.container.EJSHome.createBeanO(EJSHome.java:1360) ~[com.ibm.ws.runtime.jar:na]
at com.ibm.ejs.container.activator.UncachedActivationStrategy.atActivate(UncachedActivationStrategy.java:89) ~[com.ibm.ws.runtime.jar:na]
at com.ibm.ejs.container.activator.Activator.preInvokeActivateBean(Activator.java:324) ~[com.ibm.ws.runtime.jar:na]
at com.ibm.ejs.container.EJSContainer.preInvokeActivate(EJSContainer.java:3728) ~[com.ibm.ws.runtime.jar:na]
at com.ibm.ejs.container.EJSContainer.EjbPreInvoke(EJSContainer.java:3042) ~[com.ibm.ws.runtime.jar:na]
我的 mdb 看起来像这样:
@Stateless
@Remote({ IXXXX.class })
@Interceptors(SpringBeanAutowiringInterceptor.class)
@TransactionAttribute(TransactionAttributeType.REQUIRED)
@TransactionManagement(TransactionManagementType.CONTAINER)
@DeclareRoles(Constants.USER_ROLE_NAME)
@RolesAllowed(Constants.USER_ROLE_NAME)
public class XXXXProducerBean implements IXXXX {
@Inject
@JMSConnectionFactory("qcf/cont")
private JMSContext context;
@Resource(name="queue/Impact")
private Destination queueImpact;
我在 Internet 上找到的所有文档中,JMSContext 似乎在没有任何配置的情况下被注入...是否缺少某些内容?
编辑
感谢 Eddie 提供 beans.xml 文件。我忘了。
但现在我有另一个例外:
[10/04/15 09:34:55:031 CEST] 0000006e BeansDeployer E BeansDeployer deploy
javax.enterprise.inject.UnsatisfiedResolutionException: Api type [javax.jms.JMSContext] is not found with the qualifiers
Qualifiers: [@javax.enterprise.inject.Default()]
for injection into
Field Injection Point, field : private javax.jms.JMSContext com.package.producer.ejb.XXXXProducerBean.context, Bean Owner : [WSEjbBean [businessLocals=[], ejbName=XXXXProducerBean2142018237,Name:null,WebBeans Type:ENTERPRISE,API Types:[java.lang.Object],Qualifiers:[javax.enterprise.inject.Any,javax.enterprise.inject.Default]]
InjectionType : [interface javax.jms.JMSContext]
Annotated : [Annotated Field,Base Type : interface javax.jms.JMSContext,Type Closures : [interface javax.jms.JMSContext, interface java.lang.AutoCloseable, class java.lang.Object],Annotations : [@javax.jms.JMSConnectionFactory(value=qcf/cont), @javax.inject.Inject()],Java Member Name : context]
Qualifiers : [[@javax.enterprise.inject.Default()]]
at org.apache.webbeans.util.InjectionExceptionUtils.throwUnsatisfiedResolutionException(InjectionExceptionUtils.java:92)
WebSphere 支持 JMS 1.1 而非 2.0。 @JMSConnectionFactory
来自 2.0。您需要像这样将其更改为 @Resource
:
@Resource("qcf/cont")
private ConnectionFactory connectionFactory;