尝试在TomEE服务器中创建javax.jms.ConnectionFactory
资源时遇到了问题。我正在使用tomee.xml
文件来写资源条目。
我能够创建javax.jms.Queue
和主题,但不能创建此主题。当我尝试创建JMS ConnectionFactory资源时,TomEE启动时出错。
在我的tomee.xml
文件下面提供。我为此参考了Apache TomEE文档。作为per documentation,我应该能够创建此资源。
<?xml version="1.0" encoding="UTF-8"?>
<tomee>
<!-- see http://tomee.apache.org/containers-and-resources.html -->
<!-- activate next line to be able to deploy applications in apps -->
<!-- <Deployments dir="apps" /> -->
<Resource id="Foo" type="javax.jms.ConnectionFactory">
ResourceAdapter = Default JMS Resource Adapter
TransactionSupport = xa
PoolMaxSize = 10
PoolMinSize = 0
ConnectionMaxWaitTime = 5 seconds
ConnectionMaxIdleTime = 15 Minutes
</Resource>
</tomee>
e, provider-id=Tomcat Security Service)
10-May-2019 11:15:36.532 INFO [main] org.apache.openejb.config.ConfigurationFactory.configureService Configuring Service(id=Default Transaction Manager, type=TransactionManager, provider-id=Default Transaction Manager)
10-May-2019 11:15:36.536 INFO [main] org.apache.openejb.config.ConfigurationFactory.configureService Configuring Service(id=Foo, type=Resource, provider-id=Default JMS Connection Factory)
10-May-2019 11:15:36.544 INFO [main] org.apache.openejb.util.OptionsLog.info Using 'openejb.deployments.classpath=false'
10-May-2019 11:15:36.600 INFO [main] org.apache.openejb.assembler.classic.Assembler.createRecipe Creating TransactionManager(id=Default Transaction Manager)
10-May-2019 11:15:36.864 INFO [main] org.apache.openejb.assembler.classic.Assembler.createRecipe Creating SecurityService(id=Tomcat Security Service)
10-May-2019 11:15:37.484 INFO [main] org.apache.openejb.assembler.classic.Assembler.createRecipe Creating Resource(id=Foo)
10-May-2019 11:15:37.520 SEVERE [main] org.apache.openejb.OpenEJB$Instance.<init> OpenEJB has encountered a fatal error and cannot be started: Assembler failed to build the container system.
org.apache.openejb.OpenEJBException: No existing resource adapter defined with id 'Default JMS Resource Adapter'.
at org.apache.openejb.assembler.classic.Assembler.replaceResourceAdapterProperty(Assembler.java:2942)
at org.apache.openejb.assembler.classic.Assembler.doCreateResource(Assembler.java:3108)
at org.apache.openejb.assembler.classic.Assembler.createResource(Assembler.java:2966)
at org.apache.openejb.assembler.classic.Assembler.buildContainerSystem(Assembler.java:586)
at org.apache.openejb.assembler.classic.Assembler.build(Assembler.java:487)
at org.apache.openejb.OpenEJB$Instance.<init>(OpenEJB.java:150)
at org.apache.openejb.OpenEJB.init(OpenEJB.java:307)
at org.apache.tomee.catalina.TomcatLoader.initialize(TomcatLoader.java:247)
at org.apache.tomee.catalina.ServerListener.lifecycleEvent(ServerListener.java:168)
at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:94)
at org.apache.catalina.util.LifecycleBase.setStateInternal(LifecycleBase.java:395)
at org.apache.catalina.util.LifecycleBase.init(LifecycleBase.java:108)
at org.apache.catalina.startup.Catalina.load(Catalina.java:632)
at org.apache.catalina.startup.Catalina.load(Catalina.java:655)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:567)
at org.apache.catalina.startup.Bootstrap.load(Bootstrap.java:309)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:492)
10-May-2019 11:15:37.524 SEVERE [main] org.apache.tomee.catalina.ServerListener.lifecycleEvent TomEE Listener can't start OpenEJB
org.apache.openejb.OpenEJBException: No existing resource adapter defined with id 'Default JMS Resource Adapter'.
at org.apache.openejb.assembler.classic.Assembler.replaceResourceAdapterProperty(Assembler.java:2942)
at org.apache.openejb.assembler.classic.Assembler.doCreateResource(Assembler.java:3108)
at org.apache.openejb.assembler.classic.Assembler.createResource(Assembler.java:2966)
at org.apache.openejb.assembler.classic.Assembler.buildContainerSystem(Assembler.java:586)
at org.apache.openejb.assembler.classic.Assembler.build(Assembler.java:487)
at org.apache.openejb.OpenEJB$Instance.<init>(OpenEJB.java:150)
at org.apache.openejb.OpenEJB.init(OpenEJB.java:307)
at org.apache.tomee.catalina.TomcatLoader.initialize(TomcatLoader.java:247)
at org.apache.tomee.catalina.ServerListener.lifecycleEvent(ServerListener.java:168)
at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:94)
at org.apache.catalina.util.LifecycleBase.setStateInternal(LifecycleBase.java:395)
at org.apache.catalina.util.LifecycleBase.init(LifecycleBase.java:108)
at org.apache.catalina.startup.Catalina.load(Catalina.java:632)
at org.apache.catalina.startup.Catalina.load(Catalina.java:655)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:567)
at org.apache.catalina.startup.Bootstrap.load(Bootstrap.java:309)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:492)
10-May-2019 11:15:37.576 INFO [main] jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke Initialization processed in 8796 ms
10-May-2019 11:15:37.788 INFO [main] jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke Starting service [Catalina]
10-May-2019 11:15:37.788 INFO [main] jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke Starting Servlet Engine: Apache Tomcat/8.5.32
10-May-2019 11:15:37.816 INFO [localhost-startStop-1] jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke Deploying web application directory [D:\servers_\apache-tomee-7.1.0-plus\apache-tomee-plus-7.1.0\webapps\docs]
10-May-2019 11:15:37.848 INFO [localhost-startStop-1] org.apache.tomee.catalina.TomcatWebAppBuilder.init ------------------------- localhost -> /docs
WARNING: An illegal reflective access operation has occurred
我真的很感谢与此有关的任何帮助。我被卡住了!预先感谢。
答案 0 :(得分:2)
您正在使用的配置(如您的问题中所述)
ConnectionMaxWaitTime = 5 seconds
ConnectionMaxIdleTime = 15 Minutes
无效没有明确记录。
根据{em> Resources / javax.jms.ConnectionFactory 小节下的the documentation,这两个参数应如下所示:
ConnectionMaxWaitMilliseconds = 5000
ConnectionMaxIdleMinutes = 15
请注意不同的属性名称和值(无单位)。尝试在tomee.xml
中进行调整,然后重新启动设置。
pre-final TomEE 8 documentation建议您的设置可能对较新的版本有效。但是,这似乎是“误导性”,示例中的错误,或者此语法仅适用于> = 8.x的TomEE版本(例如8.0.0-M2)。您可能需要测试/验证我在答案的原始部分中引用的先前表格,并报告该表格是否按预期工作。
我在 TomEE 7.1.0 和 TomEE-8.0.0-M2 的tomee.xml
中为以下配置工作:
<Resource id="myCustomizedJmsConnectionFactory" type="javax.jms.ConnectionFactory">
connectionMaxWaitMilliseconds = 5000
connectionMaxIdleMinutes = 15
poolMaxSize = 10
poolMinSize = 0
resourceAdapter = Default JMS Resource Adapter
transactionSupport = xa
</Resource>
<Resource id="Default JMS Resource Adapter" type="ActiveMQResourceAdapter">
BrokerXmlConfig = broker:(tcp://localhost:61616)?persistent=true
ServerUrl = tcp://localhost:61616
DataSource = MyDataSource
</Resource>
其中您必须将 MyDataSource
更改为本地数据源(名称)。
遗憾的是,当前文档对于必须指定
的事实并不完全清楚<Resource id="Default JMS Resource Adapter" type="ActiveMQResourceAdapter">...
为自己。作为参考和更多(配置)细节,我也想指出您this post。
希望有帮助。
答案 1 :(得分:0)
您应该将 tomee 与 activemq 集成。有两种工作形式:1) 嵌入activemq 或2) 独立activemq
示例: 嵌入activemq(文件tomee.xml)
<?xml version="1.0" encoding="UTF-8"?>
<tomee>
<!-- see http://tomee.apache.org/containers-and-resources.html -->
<!-- activate next line to be able to deploy applications in apps -->
<!-- <Deployments dir="apps" /> -->
<Resource id="MyJmsResourceAdapter" type="ActiveMQResourceAdapter">
BrokerXmlConfig =broker:(tcp://localhost:61616)
ServerUrl = tcp://localhost:61616
</Resource>
<Resource id="MyJmsConnectionFactory" type="javax.jms.ConnectionFactory">
ResourceAdapter = MyJmsResourceAdapter
</Resource>
<Container id="MyJmsMdbContainer" ctype="MESSAGE">
ResourceAdapter = MyJmsResourceAdapter
</Container>
<Resource id="MyQueue" type="javax.jms.Queue"/>
</tomee>
具有独立的activemq
<?xml version="1.0" encoding="UTF-8"?>
<tomee>
<!-- see http://tomee.apache.org/containers-and-resources.html -->
<!-- activate next line to be able to deploy applications in apps -->
<!-- <Deployments dir="apps" /> -->
<Resource id="MyJmsResourceAdapter" type="ActiveMQResourceAdapter">
# Do not start the embedded ActiveMQ broker
BrokerXmlConfig =
ServerUrl = tcp://localhost:61616
</Resource>
<Resource id="MyJmsConnectionFactory" type="javax.jms.ConnectionFactory">
ResourceAdapter = MyJmsResourceAdapter
</Resource>
<Container id="MyJmsMdbContainer" ctype="MESSAGE">
ResourceAdapter = MyJmsResourceAdapter
</Container>
<Resource id="MyQueue" type="javax.jms.Queue"/>
</tomee>