我有一个应用程序,其中客户端组件在“托管”环境中运行(作为 Adobe InDesign 插件)。在这种“托管”环境中,似乎不可能在执行期间创建线程,而只能在应用程序启动时创建。
这个客户端组件通过 JNDI 和 RMI/IIOP 连接到 Glassfish 服务器,以执行各种 EJB 方法调用,所有这些都可以完美运行(除了一些在这里不重要的繁琐的CORBA 序列化问题)。我想让它也使用 JMS 连接,以执行一些主题阅读。我用来执行这些主题阅读的代码已经在单元测试中,确保它可以启动、阅读主题并执行所需的集成(这更像是一个集成测试而不是单元测试,但我必须确定我的应用程序通信层,不是吗?)。这段代码在单元测试中运行时可以完美运行。不幸的是,当从我的客户端组件(嵌入在 Indesign 中,并且无法创建线程)运行时,它以NullPointerException
以下方式失败:
29 mai 2012 18:07:22 com.sun.enterprise.connectors.ActiveRAFactory getActiveRA
INFO: Deployed RAR [ jmsra ] has inbound artifacts, but the runtime does not support it. Providing only outbound support
29 mai 2012 18:07:22 org.hibernate.validator.util.Version <clinit>
INFO: Hibernate Validator 4.2.0.Final
29 mai 2012 18:07:24 com.sun.messaging.jms.ra.ResourceAdapter start
INFO: MQJMSRA_RA1101: GlassFish MQ JMS Resource Adapter: Version: 4.5 (Build 29-b) Compile: Wed Feb 9 22:53:30 PST 2011
29 mai 2012 18:07:24 com.sun.messaging.jms.ra.ResourceAdapter start
INFO: MQJMSRA_RA1101: GlassFish MQ JMS Resource Adapter starting: broker is EMBEDDED, connection mode is Direct
29 mai 2012 18:12:58 com.sun.messaging.jms.blc.LifecycleManagedBroker start
GRAVE: MQJMSRA_RA4001: start:Aborting:Exception starting EMBEDDED broker=java.lang.NullPointerException
29 mai 2012 18:12:58 com.sun.messaging.jms.blc.LifecycleManagedBroker start
INFO: SJSMQ LifecycleManagedBroker configuration=
brokerInstanceName =imqbroker
brokerBindAddress =null
brokerPort =7676
brokerHomeDir =C:\Java-ext\glassfish3\mq
brokerLibDir =C:\Java-ext\glassfish3\mq\lib
brokerVarDir =C:\Java-ext\glassfish3\glassfish\domains\autocat\imq
brokerJavaDir =C:\Program Files\Java\jdk1.6.0_30\jre
brokerArgs =null
MasterBroker =null
brokerId =null
adminUsername =admin
adminPassword =<default>
adminPassFile =null
ConnectionURL =mq://localhost:7676/
dbType =null
dbProps ={}
dsProps ={}
useJNDIRmiServiceURL =true
useSSLJMXConnector =true
brokerEnableHA =false
clusterId =null
rmiRegistryPort =7776
startRmiRegistry =true
brokerStartTimeout = jmxServiceURL =null
60000
29 mai 2012 18:12:58 com.sun.enterprise.connectors.ActiveOutboundResourceAdapter init
GRAVE: RAR6035 : Resource adapter start failed.
javax.resource.spi.ResourceAdapterInternalException: MQJMSRA_RA4001: start:Aborting:Exception starting EMBEDDED broker=java.lang.NullPointerException
at com.sun.messaging.jms.blc.LifecycleManagedBroker.start(LifecycleManagedBroker.java:458)
at com.sun.messaging.jms.ra.ResourceAdapter.start(ResourceAdapter.java:380)
at com.sun.enterprise.connectors.ActiveOutboundResourceAdapter.startResourceAdapter(ActiveOutboundResourceAdapter.java:182)
at com.sun.enterprise.connectors.ActiveOutboundResourceAdapter.init(ActiveOutboundResourceAdapter.java:129)
at com.sun.enterprise.connectors.ActiveRAFactory.instantiateActiveResourceAdapter(ActiveRAFactory.java:135)
at com.sun.enterprise.connectors.ActiveRAFactory.createActiveResourceAdapter(ActiveRAFactory.java:106)
at com.sun.enterprise.connectors.service.ResourceAdapterAdminServiceImpl.createActiveResourceAdapter(ResourceAdapterAdminServiceImpl.java:212)
at com.sun.enterprise.connectors.ConnectorRuntime.createActiveResourceAdapter(ConnectorRuntime.java:379)
at com.sun.enterprise.resource.naming.AdministeredObjectFactory.getObjectInstance(AdministeredObjectFactory.java:107)
at javax.naming.spi.NamingManager.getObjectInstance(Unknown Source)
at com.sun.enterprise.naming.impl.SerialContext.getObjectInstance(SerialContext.java:556)
at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:514)
at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:455)
at javax.naming.InitialContext.lookup(Unknown Source)
at fr.perigee.autocat.indesign.remoting.jndi.jms.AdapterJMSListener.getConsumer(AdapterJMSListener.java:261)
at fr.perigee.autocat.indesign.remoting.jndi.jms.AdapterJMSListener$AdapterJMSListenerRunnable.run(AdapterJMSListener.java:50)
at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
at java.util.concurrent.FutureTask$Sync.innerRunAndReset(Unknown Source)
at java.util.concurrent.FutureTask.runAndReset(Unknown Source)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$101(Unknown Source)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.runPeriodic(Unknown Source)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.RuntimeException: java.lang.NullPointerException
at com.sun.messaging.jmq.jmsclient.runtime.impl.BrokerInstanceImpl.start(BrokerInstanceImpl.java:211)
at com.sun.messaging.jms.blc.EmbeddedBrokerRunner.start(EmbeddedBrokerRunner.java:331)
at com.sun.messaging.jms.blc.LifecycleManagedBroker.start(LifecycleManagedBroker.java:454)
... 24 more
Caused by: java.lang.NullPointerException
at com.sun.messaging.jmq.jmsserver.data.TransactionList.<init>(TransactionList.java:182)
at com.sun.messaging.jmq.jmsserver.Broker._start(Broker.java:1170)
at com.sun.messaging.jmq.jmsserver.Broker.start(Broker.java:456)
at com.sun.messaging.jmq.jmsserver.BrokerProcess.start(BrokerProcess.java:164)
at com.sun.messaging.jmq.jmsserver.DirectBrokerProcess.start(DirectBrokerProcess.java:92)
at com.sun.messaging.jmq.jmsclient.runtime.impl.BrokerInstanceImpl.start(BrokerInstanceImpl.java:206)
... 26 more
从我目前发现的情况来看,客户端代码获得了到 JMS 服务器的连接(连接到mq://localhost://7676
),但随后无法启动 TransactionList。未编译的源代码(感谢 Jad !)表明它在那里失败:
/* 182*/Globals.getClusterManager().addEventListener(((ClusterListener) (this)));
尝试调试时,我还发现我的客户端无法启动,org.glassfish.enterprise.iiop.util.S1ASThreadPoolManager
因为同样不可能创建线程。
我想某处有问题,但是什么?我不知道。
那么,我如何告诉 glassfish 客户端环境线程只能从我的个人线程池(在应用程序启动时创建)中获取,而不是尝试创建自己的线程池并惨遭失败?