简体   繁体   中英

Exception when deploying EJB 3 MDB in Glassfish3

Screenshots from Glassfish Web Admin:

在此处输入图片说明

在此处输入图片说明

With the factory and Queue are injected, the code deploys OK:

@Resource(name = "jmsQueueConnectionFactory", mappedName = "connectionFactory")
private ConnectionFactory connectionFactory;

@Resource(name = "jmsDvdQueue", mappedName = "dvdQueue")
private Destination destination;

But when I add a MDB that looks like this:

@MessageDriven(name = "Consumer",
        activationConfig = {
                @ActivationConfigProperty(
                        propertyName = "destinationType",
                        propertyValue = "javax.jms.Queue"
                ),
                @ActivationConfigProperty(
                        propertyName = "destination",
                        propertyValue = "jmsDvdQueue"
                ),
                @ActivationConfigProperty(
                        propertyName = "connectionFactoryJndiName",
                        propertyValue = "jmsQueueConnectionFactory"
                )
        })
public class QueueConsumer implements MessageListener {
    @Inject
    private UserBean userBean;

    @Override
    public void onMessage(Message message) {
        ObjectMessage objectMessage = (ObjectMessage) message;
        try {
            Dvd dvd = (Dvd) ((ObjectMessage) message).getObject();
            System.out.println(dvd);
        } catch (JMSException e) {
            e.printStackTrace();
        }
    }
}

it would not deploy; the server logs say:

[#|2012-11-06T16:19:49.290+0200|SEVERE|glassfish3.1.2|javax.enterprise.resource.jms.com.sun.enterprise.connectors.jms.system|_ThreadID=22;_ThreadName=Thread-2;|Missing Destination JNDI Name|#]

[#|2012-11-06T16:19:49.290+0200|SEVERE|glassfish3.1.2|javax.enterprise.system.container.ejb.mdb.com.sun.ejb.containers|_ThreadID=22;_ThreadName=Thread-2;|MDB00017: [Consumer]: Exception in creating message-driven bean container: [com.sun.appserv.connectors.internal.api.ConnectorRuntimeException: Error in Runtime DD: missing destination JNDI name]|#]

[#|2012-11-06T16:19:49.291+0200|SEVERE|glassfish3.1.2|javax.enterprise.system.container.ejb.mdb.com.sun.ejb.containers|_ThreadID=22;_ThreadName=Thread-2;|com.sun.appserv.connectors.internal.api.ConnectorRuntimeException
com.sun.appserv.connectors.internal.api.ConnectorRuntimeException: Error in Runtime DD: missing destination JNDI name
    at com.sun.enterprise.connectors.jms.system.ActiveJmsResourceAdapter.updateMDBRuntimeInfo(ActiveJmsResourceAdapter.java:1872)
    at com.sun.enterprise.connectors.inbound.ConnectorMessageBeanClient.setup(ConnectorMessageBeanClient.java:186)
    at com.sun.ejb.containers.MessageBeanContainer.<init>(MessageBeanContainer.java:205)
    at com.sun.ejb.containers.ContainerFactoryImpl.createContainer(ContainerFactoryImpl.java:121)
    at org.glassfish.ejb.startup.EjbApplication.loadContainers(EjbApplication.java:230)
    at org.glassfish.ejb.startup.EjbDeployer.load(EjbDeployer.java:299)
    at org.glassfish.ejb.startup.EjbDeployer.load(EjbDeployer.java:105)
    at org.glassfish.internal.data.ModuleInfo.load(ModuleInfo.java:186)
    at org.glassfish.internal.data.ApplicationInfo.load(ApplicationInfo.java:264)
    at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:460)
    at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:240)
    at org.glassfish.deployment.admin.DeployCommand.execute(DeployCommand.java:389)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl$1.execute(CommandRunnerImpl.java:348)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:363)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:1085)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl.access$1200(CommandRunnerImpl.java:95)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1291)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1259)
    at com.sun.enterprise.v3.admin.AdminAdapter.doCommand(AdminAdapter.java:461)
    at com.sun.enterprise.v3.admin.AdminAdapter.service(AdminAdapter.java:212)
    at com.sun.grizzly.tcp.http11.GrizzlyAdapter.service(GrizzlyAdapter.java:179)
    at com.sun.enterprise.v3.server.HK2Dispatcher.dispath(HK2Dispatcher.java:117)
    at com.sun.enterprise.v3.services.impl.ContainerMapper$Hk2DispatcherCallable.call(ContainerMapper.java:354)
    at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:195)
    at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:849)
    at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:746)
    at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1045)
    at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:228)
    at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137)
    at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104)
    at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90)
    at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79)
    at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54)
    at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59)
    at com.sun.grizzly.ContextTask.run(ContextTask.java:71)
    at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532)
    at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513)
    at java.lang.Thread.run(Thread.java:662)
|#]

尝试也添加maptedName

@MessageDriven(mappedName="jms/Queue", activationConfig =  {...})

All seems to be OK. What I would try is to change the @MessageDriven annotation as follows:

@MessageDriven(mappedName = "jmsDvdQueue", activationConfig = {
        @ActivationConfigProperty(propertyName = "acknowledgeMode", propertyValue = "Auto-acknowledge"),
        @ActivationConfigProperty(propertyName = "maxSessions", propertyValue = "1"),
        @ActivationConfigProperty(propertyName = "maxMessages", propertyValue = "1"),
        @ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue")
})

Mapped name of your MDB should refer to your JNDI name: mappedName = "jmsDvdQueue" .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM