尝试注入Res-Ref-Env-Property的异常

时间:2015-05-12 16:06:01

标签: jms

您好我正在与JMS合作尝试发送电子邮件并在我尝试

之后
connection = (Connection) mailerFactory.createConnection();
session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
MessageProducer messageProducer = session.createProducer((Destination) mailer);
messageProducer.send(createJMSMessageForjmsMailer(session, messageData));

我在messageProducer.send:

之后得到了当前的异常
[2015-05-12T10:47:06.840-0430] [glassfish 4.0] [SEVERE] [containers.mdb.ejb_creation_exception] [javax.enterprise.system.container.ejb.mdb.org.glassfish.ejb.mdb] [tid: _ThreadID=125 _ThreadName=p: thread-pool-1; w: 10] [timeMillis: 1431443826840] [levelValue: 1000] [[
  MDB00050: Message-driven bean [BancoCaroniMovil:EmailMessageBean]: Exception in creating message-driven ejb : [java.lang.IllegalStateException: Exception attempting to inject Res-Ref-Env-Property: mailer@javax.mail.Session@ resolved as: jndi: mailer@res principal: null@mail: null
No Runtime properties
Database Vendor : null
Create Tables at Deploy : false
Delete Tables at Undeploy : false into class com.totaltexto.bancamovil.caroni.v1.beans.EmailMessageBean: Lookup failed for 'java:comp/env/mailer' in SerialContext[myEnv={java.naming.factory.initial=com.sun.enterprise.naming.impl.SerialInitContextFactory, java.naming.factory.state=com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl, java.naming.factory.url.pkgs=com.sun.enterprise.naming}]]]

[2015-05-12T10:47:06.840-0430] [glassfish 4.0] [SEVERE] [] [javax.enterprise.system.container.ejb.mdb.org.glassfish.ejb.mdb] [tid: _ThreadID=125 _ThreadName=p: thread-pool-1; w: 10] [timeMillis: 1431443826840] [levelValue: 1000] [[
  java.lang.IllegalStateException
java.lang.IllegalStateException: Exception attempting to inject Res-Ref-Env-Property: mailer@javax.mail.Session@ resolved as: jndi: mailer@res principal: null@mail: null
No Runtime properties
Database Vendor : null
Create Tables at Deploy : false
Delete Tables at Undeploy : false into class com.totaltexto.bancamovil.caroni.v1.beans.EmailMessageBean: Lookup failed for 'java:comp/env/mailer' in SerialContext[myEnv={java.naming.factory.initial=com.sun.enterprise.naming.impl.SerialInitContextFactory, java.naming.factory.state=com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl, java.naming.factory.url.pkgs=com.sun.enterprise.naming}
    at org.glassfish.weld.services.InjectionServicesImpl.aroundInject(InjectionServicesImpl.java:145)
    at org.jboss.weld.injection.InjectionContextImpl.run(InjectionContextImpl.java:46)
    at org.jboss.weld.injection.producer.DefaultInjector.inject(DefaultInjector.java:64)
    at org.jboss.weld.injection.producer.BasicInjectionTarget.inject(BasicInjectionTarget.java:91)
    at org.glassfish.weld.services.JCDIServiceImpl.injectEJBInstance(JCDIServiceImpl.java:257)
    at com.sun.ejb.containers.BaseContainer.injectEjbInstance(BaseContainer.java:1683)
    at org.glassfish.ejb.mdb.MessageBeanContainer.createMessageDrivenEJB(MessageBeanContainer.java:811)
    at org.glassfish.ejb.mdb.MessageBeanContainer.access$100(MessageBeanContainer.java:119)
    at org.glassfish.ejb.mdb.MessageBeanContainer$MessageBeanContextFactory.create(MessageBeanContainer.java:547)
    at com.sun.ejb.containers.util.pool.NonBlockingPool.getObject(NonBlockingPool.java:246)
    at org.glassfish.ejb.mdb.MessageBeanContainer._getContext(MessageBeanContainer.java:610)
    at com.sun.ejb.containers.BaseContainer.getContext(BaseContainer.java:2516)
    at org.glassfish.ejb.mdb.MessageBeanContainer.beforeMessageDelivery(MessageBeanContainer.java:1119)
    at org.glassfish.ejb.mdb.MessageBeanListenerImpl.beforeMessageDelivery(MessageBeanListenerImpl.java:77)
    at com.sun.enterprise.connectors.inbound.MessageEndpointInvocationHandler.invoke(MessageEndpointInvocationHandler.java:139)
    at com.sun.proxy.$Proxy550.beforeDelivery(Unknown Source)
    at com.sun.messaging.jms.ra.OnMessageRunner.run(OnMessageRunner.java:262)
    at com.sun.enterprise.connectors.work.OneWork.doWork(OneWork.java:107)
    at com.sun.corba.ee.impl.threadpool.ThreadPoolImpl$WorkerThread.performWork(ThreadPoolImpl.java:497)
    at com.sun.corba.ee.impl.threadpool.ThreadPoolImpl$WorkerThread.run(ThreadPoolImpl.java:540)
Caused by: com.sun.enterprise.container.common.spi.util.InjectionException: Exception attempting to inject Res-Ref-Env-Property: mailer@javax.mail.Session@ resolved as: jndi: mailer@res principal: null@mail: null
No Runtime properties
Database Vendor : null
Create Tables at Deploy : false
Delete Tables at Undeploy : false into class com.totaltexto.bancamovil.caroni.v1.beans.EmailMessageBean: Lookup failed for 'java:comp/env/mailer' in SerialContext[myEnv={java.naming.factory.initial=com.sun.enterprise.naming.impl.SerialInitContextFactory, java.naming.factory.state=com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl, java.naming.factory.url.pkgs=com.sun.enterprise.naming}
    at com.sun.enterprise.container.common.impl.util.InjectionManagerImpl._inject(InjectionManagerImpl.java:717)
    at com.sun.enterprise.container.common.impl.util.InjectionManagerImpl.inject(InjectionManagerImpl.java:484)
    at com.sun.enterprise.container.common.impl.util.InjectionManagerImpl.injectInstance(InjectionManagerImpl.java:170)
    at org.glassfish.weld.services.InjectionServicesImpl.aroundInject(InjectionServicesImpl.java:138)
    ... 19 more
Caused by: javax.naming.NamingException: Lookup failed for 'java:comp/env/mailer' in SerialContext[myEnv={java.naming.factory.initial=com.sun.enterprise.naming.impl.SerialInitContextFactory, java.naming.factory.state=com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl, java.naming.factory.url.pkgs=com.sun.enterprise.naming} [Root exception is javax.naming.NamingException: Lookup failed for 'mailer' in SerialContext[myEnv={java.naming.factory.initial=com.sun.enterprise.naming.impl.SerialInitContextFactory, java.naming.factory.state=com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl, java.naming.factory.url.pkgs=com.sun.enterprise.naming, com.sun.enterprise.naming.logicalName=java:comp/env/mailer} [Root exception is javax.naming.NameNotFoundException: mailer not found]]
    at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:491)
    at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:438)
    at javax.naming.InitialContext.lookup(InitialContext.java:411)
    at javax.naming.InitialContext.lookup(InitialContext.java:411)
    at com.sun.enterprise.container.common.impl.util.InjectionManagerImpl._inject(InjectionManagerImpl.java:613)
    ... 22 more
Caused by: javax.naming.NamingException: Lookup failed for 'mailer' in SerialContext[myEnv={java.naming.factory.initial=com.sun.enterprise.naming.impl.SerialInitContextFactory, java.naming.factory.state=com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl, java.naming.factory.url.pkgs=com.sun.enterprise.naming, com.sun.enterprise.naming.logicalName=java:comp/env/mailer} [Root exception is javax.naming.NameNotFoundException: mailer not found]
    at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:491)
    at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:438)
    at javax.naming.InitialContext.lookup(InitialContext.java:411)
    at javax.naming.InitialContext.lookup(InitialContext.java:411)
    at com.sun.enterprise.naming.util.JndiNamingObjectFactory.create(JndiNamingObjectFactory.java:90)
    at com.sun.enterprise.naming.util.JndiInitializationNamingObjectFactory.create(JndiInitializationNamingObjectFactory.java:110)
    at com.sun.enterprise.naming.impl.GlassfishNamingManagerImpl.lookup(GlassfishNamingManagerImpl.java:745)
    at com.sun.enterprise.naming.impl.GlassfishNamingManagerImpl.lookup(GlassfishNamingManagerImpl.java:715)
    at com.sun.enterprise.naming.impl.JavaURLContext.lookup(JavaURLContext.java:159)
    at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:471)
    ... 26 more
Caused by: javax.naming.NameNotFoundException: mailer not found
    at com.sun.enterprise.naming.impl.TransientContext.doLookup(TransientContext.java:237)
    at com.sun.enterprise.naming.impl.TransientContext.lookup(TransientContext.java:204)
    at com.sun.enterprise.naming.impl.SerialContextProviderImpl.lookup(SerialContextProviderImpl.java:66)
    at com.sun.enterprise.naming.impl.LocalSerialContextProviderImpl.lookup(LocalSerialContextProviderImpl.java:114)
    at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:478)
    ... 35 more
]]
[2015-05-12T10:47:06.856-0430] [glassfish 4.0] [WARNING] [] [javax.resourceadapter.mqjmsra.inbound.message] [tid: _ThreadID=125 _ThreadName=p: thread-pool-1; w: 10] [timeMillis: 1431443826856] [levelValue: 900] [[
  MQJMSRA_MR2001: run:Caught Exception from onMessage():Redelivering:
java.lang.ClassCastException: org.glassfish.api.invocation.ComponentInvocation cannot be cast to com.sun.ejb.EjbInvocation
    at org.glassfish.ejb.mdb.MessageBeanContainer.deliverMessage(MessageBeanContainer.java:1182)
    at org.glassfish.ejb.mdb.MessageBeanListenerImpl.deliverMessage(MessageBeanListenerImpl.java:81)
    at com.sun.enterprise.connectors.inbound.MessageEndpointInvocationHandler.invoke(MessageEndpointInvocationHandler.java:171)
    at com.sun.proxy.$Proxy550.onMessage(Unknown Source)
    at com.sun.messaging.jms.ra.OnMessageRunner.run(OnMessageRunner.java:283)
    at com.sun.enterprise.connectors.work.OneWork.doWork(OneWork.java:107)
    at com.sun.corba.ee.impl.threadpool.ThreadPoolImpl$WorkerThread.performWork(ThreadPoolImpl.java:497)
    at com.sun.corba.ee.impl.threadpool.ThreadPoolImpl$WorkerThread.run(ThreadPoolImpl.java:540)
]]

[2015-05-12T10:47:07.606-0430] [glassfish 4.0] [WARNING] [] [javax.resourceadapter.mqjmsra.inbound.message] [tid: _ThreadID=125 _ThreadName=p: thread-pool-1; w: 10] [timeMillis: 1431443827606] [levelValue: 900] [[
  MQJMSRA_MR2001: run:onMessage caught Throwable-before/on/afterDelivery:Class=java.lang.ClassCastExceptionMsg=org.glassfish.api.invocation.ComponentInvocation cannot be cast to com.sun.ejb.EjbInvocation
java.lang.ClassCastException: org.glassfish.api.invocation.ComponentInvocation cannot be cast to com.sun.ejb.EjbInvocation
    at org.glassfish.ejb.mdb.MessageBeanContainer.afterMessageDeliveryInternal(MessageBeanContainer.java:1310)
    at org.glassfish.ejb.mdb.MessageBeanContainer.afterMessageDelivery(MessageBeanContainer.java:1301)
    at org.glassfish.ejb.mdb.MessageBeanListenerImpl.afterMessageDelivery(MessageBeanListenerImpl.java:86)
    at com.sun.enterprise.connectors.inbound.MessageEndpointInvocationHandler.invoke(MessageEndpointInvocationHandler.java:143)
    at com.sun.proxy.$Proxy550.afterDelivery(Unknown Source)
    at com.sun.messaging.jms.ra.OnMessageRunner.run(OnMessageRunner.java:361)
    at com.sun.enterprise.connectors.work.OneWork.doWork(OneWork.java:107)
    at com.sun.corba.ee.impl.threadpool.ThreadPoolImpl$WorkerThread.performWork(ThreadPoolImpl.java:497)
    at com.sun.corba.ee.impl.threadpool.ThreadPoolImpl$WorkerThread.run(ThreadPoolImpl.java:540)
]]

我已经检查了JMS资源配置,包括连接工厂和目标资源。

这是在我的SessionBean上:

@Resource(mappedName = "jms/mailer")
private Queue mailer;
@Resource(mappedName = "jms/mailerFactory")
private ConnectionFactory mailerFactory;

这是在EmailMessageBean上:

@MessageDriven(mappedName = "jms/mailer", activationConfig = {
@ActivationConfigProperty(propertyName = "acknowledgeMode", propertyValue = "Auto-acknowledge"),
@ActivationConfigProperty(propertyName = "destinationName", propertyValue = "mailer"),
@ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue")
})
public class EmailMessageBean implements MessageListener, Serializable {

@Resource(name = "mailer")
private Session mailer;
private static final Logger logger = Logger.getLogger(EmailMessageBean.class.getName());

public EmailMessageBean() {
}

如果有人能帮助我,我真的很感激。

0 个答案:

没有答案