出于某种原因,我应该使用旧的 EJB 容器 GlassFish 2.1.1。(通过 Java EE 5 和 EJB 3.0 认证)。项目结构如下:
多边开发银行:
@MessageDriven(
mappedName = "jms/Queue",
activationConfig = {
@ActivationConfigProperty(propertyName = "destinationType",
propertyValue = "javax.jms.Queue")
})
public class TriggerMBean implements MessageListener {
@EJB
private TriggerProcessor triggerService;
public void onMessage(Message message) {
//.......
triggerService.process();
//.......
}
}
触发器处理器:
@Stateless
public class TriggerProcessor {
public void proceess() {
//....
}
}
我还没有创建部署描述符。据我了解,如果我从 3.0 开始使用注释和 EJB 版本,则没有必要
部署时,异常如下:
[#|2012-06-15T15:55:50.290+0300|SEVERE|sun-appserver2.1|javax.enterprise.system.container.ejb.mdb|_ThreadID=42;_ThreadName=p: thread-pool-1; w: 61;_RequestID=824fc411-7772-42cc-aeee-9a8d9b451dbf;|com.sun.enterprise.InjectionException
com.sun.enterprise.InjectionException: Exception attempting to inject Unresolved Ejb-Ref fi.prh.novus.sync.consumer.TriggerMBean/triggerService@jndi: fi.prh.novus.sync.service.TriggerProcessor@null@fi.prh.novus.sync.service.TriggerProcessor@Session@null into class fi.prh.novus.sync.consumer.TriggerMBean
at com.sun.enterprise.util.InjectionManagerImpl._inject(InjectionManagerImpl.java:387)
at com.sun.enterprise.util.InjectionManagerImpl.inject(InjectionManagerImpl.java:206)
at com.sun.enterprise.util.InjectionManagerImpl.injectInstance(InjectionManagerImpl.java:127)
at com.sun.ejb.containers.MessageBeanContainer.createMessageDrivenEJB(MessageBeanContainer.java:711)
at com.sun.ejb.containers.MessageBeanContainer.access$100(MessageBeanContainer.java:109)
at com.sun.ejb.containers.MessageBeanContainer$MessageBeanContextFactory.create(MessageBeanContainer.java:492)
at com.sun.ejb.containers.util.pool.NonBlockingPool.getObject(NonBlockingPool.java:199)
at com.sun.ejb.containers.MessageBeanContainer._getContext(MessageBeanContainer.java:555)
at com.sun.ejb.containers.BaseContainer.getContext(BaseContainer.java:1731)
at com.sun.ejb.containers.MessageBeanContainer.beforeMessageDelivery(MessageBeanContainer.java:1008)
at com.sun.ejb.containers.MessageBeanListenerImpl.beforeMessageDelivery(MessageBeanListenerImpl.java:70)
at com.sun.enterprise.connectors.inflow.MessageEndpointInvocationHandler.invoke(MessageEndpointInvocationHandler.java:135)
at $Proxy86.beforeDelivery(Unknown Source)
at com.sun.messaging.jms.ra.OnMessageRunner.run(OnMessageRunner.java:245)
at com.sun.enterprise.connectors.work.OneWork.doWork(OneWork.java:77)
at com.sun.corba.ee.impl.orbutil.threadpool.ThreadPoolImpl$WorkerThread.run(ThreadPoolImpl.java:555)
Caused by: javax.naming.NameNotFoundException: fi.prh.novus.sync.service.TriggerProcessor#fi.prh.novus.sync.service.TriggerProcessor not found
at com.sun.enterprise.naming.TransientContext.doLookup(TransientContext.java:216)
at com.sun.enterprise.naming.TransientContext.lookup(TransientContext.java:188)
at com.sun.enterprise.naming.SerialContextProviderImpl.lookup(SerialContextProviderImpl.java:74)
at com.sun.enterprise.naming.LocalSerialContextProviderImpl.lookup(LocalSerialContextProviderImpl.java:111)
at com.sun.enterprise.naming.SerialContext.lookup(SerialContext.java:409)
at javax.naming.InitialContext.lookup(InitialContext.java:392)
at com.sun.enterprise.naming.NamingManagerImpl.lookup(NamingManagerImpl.java:951)
at com.sun.enterprise.naming.java.javaURLContext.lookup(javaURLContext.java:173)
at com.sun.enterprise.naming.SerialContext.lookup(SerialContext.java:407)
at javax.naming.InitialContext.lookup(InitialContext.java:392)
at com.sun.enterprise.util.InjectionManagerImpl._inject(InjectionManagerImpl.java:287)
... 15 more
|#]
我试图private TriggerProcessor triggerService;
用@EJB(beanName="TriggerProcessor")
和public class TriggerProcessor {..
用注释,@Stateless(name="TriggerProcessor")
但它没有帮助。
实际上,这在最新的 Glassfish 3.1 上完美运行,但正如我珍贵地告诉的那样,我应该使用 GF 2.1.1。
任何帮助表示赞赏!