我写过消息驱动的bean。我刚接触JMS并尝试学习消息驱动的bean。主要是EJB 3.x规范。我正在尝试部署为下面的类创建的jar。
import javax.ejb.ActivationConfigProperty;
import javax.ejb.MessageDriven;
import javax.jms.Message;
import javax.jms.MessageListener;
@MessageDriven(name="xxx", activationConfig = {
@ActivationConfigProperty(propertyName = "destination",
propertyValue = "/queue/helloQueue"),
@ActivationConfigProperty(propertyName = "destinationType",
propertyValue = "javax.jms.Queue")
})
public class JMSListner implements MessageListener {
@Override
public void onMessage(Message arg0) {
// TODO Auto-generated method stub
System.out.println("message received");
}
}
tomee.xml如下
<?xml version="1.0" encoding="UTF-8"?>
<tomee>
<!-- JMS configuration -->
<Container id="ExeJmsMdbContainer" ctype="MESSAGE">
ResourceAdapter = ExeJmsResourceAdapter
# Specifies the maximum number of bean instances that are
# allowed to exist for each MDB deployment.
InstanceLimit = 1000
StrictPooling = false
</Container>
<Resource id="ExeJmsResourceAdapter" type="ActiveMQResourceAdapter">
BrokerXmlConfig = broker:(tcp://0.0.0.0:61616?daemon=true)?persistent=false&deleteAllMessagesOnStartup=true
DataSource =
</Resource>
<Resource id="fiper/jms/connectionfactory" type="javax.jms.ConnectionFactory">
ResourceAdapter = ExeJmsResourceAdapter
TransactionSupport xa
PoolMaxSize 15000
</Resource>
<Resource id="MyJmsConnectionFactory" type="javax.jms.ConnectionFactory">
ResourceAdapter = ExeJmsResourceAdapter
</Resource>
<!-- JMS Queues used by demo -->
<Resource id="helloQueue" type="javax.jms.Queue">
Destination helloQueue
</Resource>
<Resource id="TestDS" type="DataSource">
JdbcDriver com.mysql.jdbc.Driver
JdbcUrl jdbc:mysql://localhost/jpadb
UserName root
Password ######1Aa
</Resource>
<!-- see http://tomee.apache.org/containers-and-resources.html -->
<!-- activeMQ activation placeholder -->
<!-- activate next line to be able to deploy applications in apps -->
<!-- <Deployments dir="apps" /> -->
<Deployments dir="apps/" />
</tomee>
启动startup.bat
时获取异常java.lang.NullPointerException
at org.apache.openejb.persistence.PersistenceUnitInfoImpl$PersistenceClassFileTransformer.transform(PersistenceUnitInfoImpl.java:358)
at org.apache.openejb.persistence.PersistenceBootstrap$Transformer.transform(PersistenceBootstrap.java:429)
at sun.instrument.TransformerManager.transform(TransformerManager.java:188)
at sun.instrument.InstrumentationImpl.transform(InstrumentationImpl.java:428)
at sun.misc.Unsafe.defineAnonymousClass(Native Method)
at java.lang.invoke.InvokerBytecodeGenerator.loadAndInitializeInvokerClass(InvokerBytecodeGenerator.java:282)
at java.lang.invoke.InvokerBytecodeGenerator.loadMethod(InvokerBytecodeGenerator.java:274)
at java.lang.invoke.InvokerBytecodeGenerator.generateCustomizedCode(InvokerBytecodeGenerator.java:616)
at java.lang.invoke.LambdaForm.compileToBytecode(LambdaForm.java:629)
at java.lang.invoke.DirectMethodHandle.makePreparedLambdaForm(DirectMethodHandle.java:248)
at java.lang.invoke.DirectMethodHandle.preparedLambdaForm(DirectMethodHandle.java:188)
at java.lang.invoke.DirectMethodHandle.preparedLambdaForm(DirectMethodHandle.java:177)
at java.lang.invoke.DirectMethodHandle.make(DirectMethodHandle.java:84)
at java.lang.invoke.DirectMethodHandle.make(DirectMethodHandle.java:104)
at java.lang.invoke.DirectMethodHandle.make(DirectMethodHandle.java:109)
at java.lang.invoke.LambdaForm$NamedFunction.resolve(LambdaForm.java:1053)
Nov 17, 2015 7:26:20 PM org.apache.activemq.transport.TransportServerThreadSupport doStart
INFO: Listening for connections at: tcp://RKPWIN764PLP:61616?daemon=true
at java.lang.invoke.DirectMethodHandle$Lazy.<clinit>(DirectMethodHandle.java:689)
at java.lang.invoke.DirectMethodHandle.makePreparedLambdaForm(DirectMethodHandle.java:232)
Nov 17, 2015 7:26:20 PM org.apache.activemq.broker.TransportConnector start
INFO: Connector tcp://RKPWIN764PLP:61616?daemon=true started
at java.lang.invoke.DirectMethodHandle.preparedLambdaForm(DirectMethodHandle.java:188)
at java.lang.invoke.DirectMethodHandle.preparedLambdaForm(DirectMethodHandle.java:177)
at java.lang.invoke.DirectMethodHandle.make(DirectMethodHandle.java:84)
at java.lang.invoke.MethodHandles$Lookup.getDirectMethodCommon(MethodHandles.java:1656)
Nov 17, 2015 7:26:20 PM org.apache.activemq.broker.BrokerService doStartBroker
INFO: Apache ActiveMQ 5.10.0 (localhost, ID:RKPWIN764PLP-62595-1447768580766-0:1) started
at java.lang.invoke.MethodHandles$Lookup.getDirectMethod(MethodHandles.java:1601)
Nov 17, 2015 7:26:20 PM org.apache.activemq.broker.BrokerService doStartBroker
INFO: For help or more information please see: http://activemq.apache.org
at java.lang.invoke.MethodHandles$Lookup.findStatic(MethodHandles.java:778)
at java.lang.invoke.BoundMethodHandle$Factory.makeCbmhCtor(BoundMethodHandle.java:817)
at java.lang.invoke.BoundMethodHandle$Factory.makeCtors(BoundMethodHandle.java:772)
at java.lang.invoke.BoundMethodHandle$SpeciesData.initForBootstrap(BoundMethodHandle.java:358)
at java.lang.invoke.BoundMethodHandle$SpeciesData.<clinit>(BoundMethodHandle.java:447)
at java.lang.invoke.BoundMethodHandle.<clinit>(BoundMethodHandle.java:829)
at java.lang.invoke.LambdaForm.createIdentityForms(LambdaForm.java:1753)
at java.lang.invoke.LambdaForm.<clinit>(LambdaForm.java:1808)
at java.lang.invoke.DirectMethodHandle.makePreparedLambdaForm(DirectMethodHandle.java:223)
at java.lang.invoke.DirectMethodHandle.preparedLambdaForm(DirectMethodHandle.java:188)
at java.lang.invoke.DirectMethodHandle.preparedLambdaForm(DirectMethodHandle.java:177)
at java.lang.invoke.DirectMethodHandle.make(DirectMethodHandle.java:84)
at java.lang.invoke.MethodHandles$Lookup.getDirectMethodCommon(MethodHandles.java:1656)
at java.lang.invoke.MethodHandles$Lookup.getDirectMethodNoSecurityManager(MethodHandles.java:1613)
at java.lang.invoke.MethodHandles$Lookup.getDirectMethodForConstant(MethodHandles.java:1798)
at java.lang.invoke.MethodHandles$Lookup.linkMethodHandleConstant(MethodHandles.java:1747)
at java.lang.invoke.MethodHandleNatives.linkMethodHandleConstant(MethodHandleNatives.java:477)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:682)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
java.lang.NullPointerException
Nov 17, 2015 7:26:21 PM org.apache.openejb.resource.activemq.ActiveMQ5Factory$1 run
INFO: Starting ActiveMQ checkpoint
at org.apache.openejb.persistence.PersistenceUnitInfoImpl$PersistenceClassFileTransformer.transform(PersistenceUnitInfoImpl.java:358)
at org.apache.openejb.persistence.PersistenceBootstrap$Transformer.transform(PersistenceBootstrap.java:429)
at sun.instrument.TransformerManager.transform(TransformerManager.java:188)
at sun.instrument.InstrumentationImpl.transform(InstrumentationImpl.java:428)
at sun.misc.Unsafe.defineAnonymousClass(Native Method)
at java.lang.invoke.InvokerBytecodeGenerator.loadAndInitializeInvokerClass(InvokerBytecodeGenerator.java:282)
Nov 17, 2015 7:26:21 PM org.apache.openejb.resource.activemq.ActiveMQ5Factory createBroker
INFO: ActiveMQ broker started
at java.lang.invoke.InvokerBytecodeGenerator.loadMethod(InvokerBytecodeGenerator.java:274)
at java.lang.invoke.InvokerBytecodeGenerator.generateCustomizedCode(InvokerBytecodeGenerator.java:616)
at java.lang.invoke.LambdaForm.compileToBytecode(LambdaForm.java:629)
at java.lang.invoke.DirectMethodHandle.makePreparedLambdaForm(DirectMethodHandle.java:248)
Nov 17, 2015 7:26:21 PM org.apache.openejb.assembler.classic.Assembler createRecipe
INFO: Creating Resource(id=TestDS)
at java.lang.invoke.DirectMethodHandle.preparedLambdaForm(DirectMethodHandle.java:188)
at java.lang.invoke.DirectMethodHandle.preparedLambdaForm(DirectMethodHandle.java:177)
at java.lang.invoke.DirectMethodHandle.make(DirectMethodHandle.java:84)
at java.lang.invoke.DirectMethodHandle.make(DirectMethodHandle.java:104)
at java.lang.invoke.DirectMethodHandle.make(DirectMethodHandle.java:109)
at java.lang.invoke.LambdaForm$NamedFunction.resolve(LambdaForm.java:1053)
at java.lang.invoke.DirectMethodHandle$Lazy.<clinit>(DirectMethodHandle.java:689)
at java.lang.invoke.DirectMethodHandle.makePreparedLambdaForm(DirectMethodHandle.java:232)
at java.lang.invoke.DirectMethodHandle.preparedLambdaForm(DirectMethodHandle.java:188)
at java.lang.invoke.DirectMethodHandle.preparedLambdaForm(DirectMethodHandle.java:177)
at java.lang.invoke.DirectMethodHandle.make(DirectMethodHandle.java:84)
at java.lang.invoke.MethodHandles$Lookup.getDirectMethodCommon(MethodHandles.java:1656)
at java.lang.invoke.MethodHandles$Lookup.getDirectMethod(MethodHandles.java:1601)
at java.lang.invoke.MethodHandles$Lookup.findStatic(MethodHandles.java:778)
at java.lang.invoke.BoundMethodHandle$Factory.makeCbmhCtor(BoundMethodHandle.java:817)
at java.lang.invoke.BoundMethodHandle$Factory.makeCtors(BoundMethodHandle.java:772)
at java.lang.invoke.BoundMethodHandle$SpeciesData.initForBootstrap(BoundMethodHandle.java:358)
at java.lang.invoke.BoundMethodHandle$SpeciesData.<clinit>(BoundMethodHandle.java:447)
at java.lang.invoke.BoundMethodHandle.<clinit>(BoundMethodHandle.java:829)
at java.lang.invoke.LambdaForm.createIdentityForms(LambdaForm.java:1753)
at java.lang.invoke.LambdaForm.<clinit>(LambdaForm.java:1808)
at java.lang.invoke.DirectMethodHandle.makePreparedLambdaForm(DirectMethodHandle.java:223)
at java.lang.invoke.DirectMethodHandle.preparedLambdaForm(DirectMethodHandle.java:188)
at java.lang.invoke.DirectMethodHandle.preparedLambdaForm(DirectMethodHandle.java:177)
at java.lang.invoke.DirectMethodHandle.make(DirectMethodHandle.java:84)
at java.lang.invoke.MethodHandles$Lookup.getDirectMethodCommon(MethodHandles.java:1656)
at java.lang.invoke.MethodHandles$Lookup.getDirectMethodNoSecurityManager(MethodHandles.java:1613)
at java.lang.invoke.MethodHandles$Lookup.getDirectMethodForConstant(MethodHandles.java:1798)
at java.lang.invoke.MethodHandles$Lookup.linkMethodHandleConstant(MethodHandles.java:1747)
at java.lang.invoke.MethodHandleNatives.linkMethodHandleConstant(MethodHandleNatives.java:477)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:682)
Nov 17, 2015 7:26:21 PM org.apache.tomee.jdbc.TomEEDataSourceCreator$TomEEDataSource readOnly
INFO: Disabling testOnBorrow since no validation query is provided
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
java.lang.NullPointerException
at org.apache.openejb.persistence.PersistenceUnitInfoImpl$PersistenceClassFileTransformer.transform(PersistenceUnitInfoImpl.java:358)
不确定配置或我编写的MDB有什么问题。你能帮忙吗?
答案 0 :(得分:0)
如果你有机会测试tomee 7(SNAPSHOT或投票中的那个ATM:https://repository.apache.org/#nexus-search;gav~org.apache.tomee~apache-tomee~~~~kw,versionexpand)我想这已经修复了。