1

我有一个 ejb 文件,其中包含一些文件和一个消息驱动的 bean。

当我运行我的 ejb 文件时,我得到了这个错误。

EJB 容器初始化错误。

但是,当我从我的 ejb 中删除消息驱动 bean 时。我的ejb可以流畅运行。

关于如何解决这个问题的任何想法?

Glassfish 服务器的错误在这里 http://pastebin.com/HkyRFnwE

SEVERE: Exception while loading the app : EJB Container initialization error
java.lang.Exception
        at com.sun.enterprise.connectors.inbound.ConnectorMessageBeanClient.setup(ConnectorMessageBeanClient.java:233)
        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:305)
        at org.glassfish.ejb.startup.EjbDeployer.load(EjbDeployer.java:108)
        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:860)
        at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:757)
        at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1056)
        at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:229)
        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:724)
Caused by: java.security.PrivilegedActionException: com.sun.appserv.connectors.internal.api.ConnectorRuntimeException
        at java.security.AccessController.doPrivileged(Native Method)
        at com.sun.enterprise.connectors.inbound.ConnectorMessageBeanClient.getActivationSpec(ConnectorMessageBeanClient.java:257)
        at com.sun.enterprise.connectors.inbound.ConnectorMessageBeanClient.setup(ConnectorMessageBeanClient.java:213)
        ... 36 more
Caused by: com.sun.appserv.connectors.internal.api.ConnectorRuntimeException
        at com.sun.enterprise.connectors.util.SetMethodAction.handleException(SetMethodAction.java:152)
        at com.sun.enterprise.connectors.util.SetMethodAction.run(SetMethodAction.java:136)
        ... 39 more
Caused by: java.lang.reflect.InvocationTargetException
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:606)
        at com.sun.enterprise.connectors.util.SetMethodAction.run(SetMethodAction.java:105)
        ... 39 more
Caused by: java.lang.IllegalArgumentException: MQJMSRA_AS4001: setSubscriptionDurability:Invalid subscriptionDurability=durable
        at com.sun.messaging.jms.ra.ActivationSpec.setSubscriptionDurability(ActivationSpec.java:537)
        ... 44 more
4

2 回答 2

0

你得到了例外

引起:java.lang.IllegalArgumentException: MQJMSRA_AS4001: setSubscriptionDurability:Invalid subscriptionDurability=durable

因为subscriptionDurability属性值区分大小写,并且您将其指定为小写,即“durable”而不是Durable的正确值(即首字母大写)

我遇到了同样的问题,这就是原因。

此属性使您能够配置主题订阅者的持久性。持久订阅者可以在与 JMS 服务器的任何断开连接中幸存下来。

有效值为 Durable 和 NonDurable。

可以使用以下 MDB(消息驱动 Bean)重现该问题:

@JMSDestinationDefinition(name = "BookingTopic", interfaceName = "javax.jms.Topic", 
        resourceAdapter = "jmsra", destinationName = "BookingTopic") @MessageDriven(activationConfig = {
    @ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Topic"),
    @ActivationConfigProperty(propertyName = "destinationLookup", propertyValue = "BookingTopic"),
    @ActivationConfigProperty(propertyName = "subscriptionDurability", propertyValue = "durable"),
    @ActivationConfigProperty(propertyName = "clientId", propertyValue = "BookingTopic"),
    @ActivationConfigProperty(propertyName = "subscriptionName", propertyValue = "BookingTopic") }) public class ReservationNotifier implements MessageListener {
    private static final Logger loggger = Logger.getLogger(ReservationNotifier.class.getSimpleName());

    public ReservationNotifier() {
    }

    @Override
    public void onMessage(Message message) {
        try {
            Booking booking = (Booking) ((ObjectMessage) message).getObject();
            loggger.log(Level.INFO, "Sending e-mail containing reservation information to {0}", booking.getCustomer().getEmail());
        } catch (JMSException ex) {
            loggger.log(Level.SEVERE, "Error reading booking from topic");
        }
    }

}
于 2014-06-20T17:38:36.650 回答
0

我猜你的 EJB 模块使用了 EJBContainer。需要注意的是,EJBContainer 仅支持不包括远程 EJB 或 MDB 的 EJB lite。有关详细信息,请参阅此链接

EJBContainer 主要用于在 JUnit 中进行测试,而不是用于生产代码。

于 2013-10-28T22:53:04.150 回答