Why is TomEE not able to create JMS connection factory resource? - java

I am facing an issue, while trying to create a javax.jms.ConnectionFactory resource in TomEE server. i am using tomee.xml file to do write the resource entries.
I am able to create javax.jms.Queue and Topic but not this. Getting an error while TomEE startup, when i try to create a JMS ConnectionFactory resource.
Giving below my tomee.xml file. I referred the Apache TomEE documentation for this. As per documentation i should be able to create this resource.
<?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
I really appreciate any help related to this. I am stuck! Thanks in advance.

The configuration you are using (as given in your question)
ConnectionMaxWaitTime = 5 seconds
ConnectionMaxIdleTime = 15 Minutes
is invalid not clearly documented.
According to the documentation under subsection Resources/javax.jms.ConnectionFactory those two parameters should read as follows:
ConnectionMaxWaitMilliseconds = 5000
ConnectionMaxIdleMinutes = 15
Note the different property names and the values (without units). Try to adjust it in your tomee.xml and restart your setup.
EDIT
The pre-final TomEE 8 documentation suggests that your setup might be valid for newer versions. Yet, it seems that this is either "misleading", a bug in the example, or this syntax only works for TomEE releases >= 8.x (e.g., 8.0.0-M2). You might want to test/verify the previous form which I refer to in the original part of the answer and report whether this works as expected.
EDIT-2
I got it working for the following configuration in tomee.xml in TomEE 7.1.0 and TomEE-8.0.0-M2:
<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>
In which you would have to change MyDataSource into your local data source (name).
Sadly, the current documentation is not entirely clear about the fact that you have to specify
<Resource id="Default JMS Resource Adapter" type="ActiveMQResourceAdapter">...
for yourself. For reference and for more (configuration) details, I'd like to point you to this post as well.
Hope it helps.

You should integrate tomee with activemq. There are two work forms: 1) with activemq embedded or 2) with independent activemq
Example:
With activemq embedded (file 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>
with independent 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>

Related

Could not create resource instance in Tomcat, when trying to configure Application name in dynamic Manner using JNDI

I am using Tomcat 9 and trying to configure the name of application in dynamic manner using JNDI as shown in the below link.
https://tomcat.apache.org/tomcat-9.0-doc/jndi-resources-howto.html
I did the below changes
Web.xml of Application
<resource-env-ref>
<resource-env-ref-name>moduleName</resource-env-ref-name>
<resource-env-ref-type>java.lang.String</resource-env-ref-type>
</resource-env-ref>
Tomcat Server
Context.xml
<ResourceLink auth="Container" global="Application_moduleName" name="moduleName" type="java.lang.String"/>
Server.xml
<GlobalNamingResources>
<Resource auth="Container" name="moduleName" override="false" type="java.lang.String" value="my-application"/>
</GlobalNamingResources>
Got the below Exception during application startup:
Mar 03, 2022 9:50:03 PM org.apache.catalina.mbeans.GlobalResourcesLifecycleListener createMBeans
SEVERE: Exception processing global JNDI Resources
javax.naming.NamingException: Could not create resource instance
at org.apache.naming.factory.FactoryBase.getObjectInstance(FactoryBase.java:98)
at javax.naming.spi.NamingManager.getObjectInstance(NamingManager.java:321)
at org.apache.naming.NamingContext.lookup(NamingContext.java:864)
at org.apache.naming.NamingContext.lookup(NamingContext.java:158)
at org.apache.naming.NamingContextBindingsEnumeration.nextElementInternal(NamingContextBindingsEnumeration.java:115)
at org.apache.naming.NamingContextBindingsEnumeration.next(NamingContextBindingsEnumeration.java:69)
at org.apache.naming.NamingContextBindingsEnumeration.next(NamingContextBindingsEnumeration.java:32)
at org.apache.catalina.mbeans.GlobalResourcesLifecycleListener.createMBeans(GlobalResourcesLifecycleListener.java:133)
at org.apache.catalina.mbeans.GlobalResourcesLifecycleListener.createMBeans(GlobalResourcesLifecycleListener.java:107)
at org.apache.catalina.mbeans.GlobalResourcesLifecycleListener.lifecycleEvent(GlobalResourcesLifecycleListener.java:82)
at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:123)
at org.apache.catalina.util.LifecycleBase.setStateInternal(LifecycleBase.java:423)
at org.apache.catalina.util.LifecycleBase.setState(LifecycleBase.java:366)
at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:920)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
at org.apache.catalina.startup.Catalina.start(Catalina.java:772)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:345)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:476)
Can anyone tell me what I am missing here.
Is there any other better way to pass application name in dynamic manner without using JNDI?
Thanks
Manzoor

How to share JPA data model between 2 EAR in JBoss "Wildfly"

We have a working JBoss v8 "Wildfly" deployment like this:
App-ear.ear
|_App-model.jar
|_App-ejb.jar
|_App-web.war
This deployment comes with a persistence.xml inside the App-model.jar. Now I want to deploy a second EAR with a different WAR module that I can re-deploy independent from the original application. Therefor I've created a second EAR like this:
Second-ear.ear
|_Second-web.war
The second application has a classpath dependency to App-model.jar during development in Eclipse (setup as Maven projects) and builds just fine. To make that dependency available during runtime I've edited Second-ear.ear/META-INF/jboss-deployment-structure.xml like this:
<?xml version="1.0" encoding="UTF-8"?>
<jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.2">
<deployment>
<dependencies>
<module name="deployment.App-ear.ear.App-model.jar" />
</dependencies>
</deployment>
</jboss-deployment-structure>
But the JBoss AS fails to load the persistence with the following error:
2015-08-19 09:13:36,903 ERROR [] [ # ] [] [MSC service thread 1-5] [fail] MSC000001: Failed to start service jboss.deployment.unit."Second-ear.ear".WeldStartService: org.jboss.msc.service.StartException in service jboss.deployment.unit."Second-ear.ear".WeldStartService: Failed to start service
at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1904) [jboss-msc-1.2.2.Final.jar:1.2.2.Final]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [rt.jar:1.8.0_25]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [rt.jar:1.8.0_25]
at java.lang.Thread.run(Thread.java:745) [rt.jar:1.8.0_25]
Caused by: java.lang.IllegalArgumentException: JBAS016069: Error injecting persistence unit into CDI managed bean. Can't find a persistence unit named MyPersistenceUnitName in deployment Second-ear.ear
at org.jboss.as.weld.services.bootstrap.WeldJpaInjectionServices.getScopedPUName(WeldJpaInjectionServices.java:110)
at org.jboss.as.weld.services.bootstrap.WeldJpaInjectionServices.registerPersistenceUnitInjectionPoint(WeldJpaInjectionServices.java:90)
at org.jboss.weld.injection.ResourceInjectionFactory$PersistenceUnitResourceInjectionProcessor.getResourceReferenceFactory(ResourceInjectionFactory.java:279)
at org.jboss.weld.injection.ResourceInjectionFactory$PersistenceUnitResourceInjectionProcessor.getResourceReferenceFactory(ResourceInjectionFactory.java:267)
at org.jboss.weld.injection.ResourceInjectionFactory$ResourceInjectionProcessor.createFieldResourceInjection(ResourceInjectionFactory.java:207)
at org.jboss.weld.injection.ResourceInjectionFactory$ResourceInjectionProcessor.createResourceInjections(ResourceInjectionFactory.java:182)
at org.jboss.weld.injection.ResourceInjectionFactory.discoverType(ResourceInjectionFactory.java:405)
at org.jboss.weld.injection.ResourceInjectionFactory.getResourceInjections(ResourceInjectionFactory.java:92)
at org.jboss.weld.injection.producer.ResourceInjector.<init>(ResourceInjector.java:59)
at org.jboss.weld.injection.producer.ResourceInjector.of(ResourceInjector.java:49)
at org.jboss.weld.injection.producer.BeanInjectionTarget.<init>(BeanInjectionTarget.java:62)
at org.jboss.weld.injection.producer.BeanInjectionTarget.createDefault(BeanInjectionTarget.java:46)
at org.jboss.weld.manager.InjectionTargetFactoryImpl.chooseInjectionTarget(InjectionTargetFactoryImpl.java:128)
at org.jboss.weld.manager.InjectionTargetFactoryImpl.createInjectionTarget(InjectionTargetFactoryImpl.java:87)
at org.jboss.weld.bean.ManagedBean.<init>(ManagedBean.java:91)
at org.jboss.weld.bean.ManagedBean.of(ManagedBean.java:71)
at org.jboss.weld.bootstrap.AbstractBeanDeployer.createManagedBean(AbstractBeanDeployer.java:264)
at org.jboss.weld.bootstrap.BeanDeployer.createClassBean(BeanDeployer.java:228)
at org.jboss.weld.bootstrap.ConcurrentBeanDeployer$2.doWork(ConcurrentBeanDeployer.java:78)
at org.jboss.weld.bootstrap.ConcurrentBeanDeployer$2.doWork(ConcurrentBeanDeployer.java:75)
at org.jboss.weld.executor.IterativeWorkerTaskFactory$1.call(IterativeWorkerTaskFactory.java:60)
at org.jboss.weld.executor.IterativeWorkerTaskFactory$1.call(IterativeWorkerTaskFactory.java:53)
at java.util.concurrent.FutureTask.run(FutureTask.java:266) [rt.jar:1.8.0_25]
... 3 more
The CDI Bean that's trying to use that persistence unit injects an EntityManager produced by the original App-model.jar:
#Named("test")
public class Test {
#Inject
#MyModelDB // Qualifier
private EntityManager em = null;
// A simple test of the datamodel...
public Long numberOfProjects() {
if (this.em != null) {
return ((BigDecimal) this.em.createNativeQuery("select count(*) from e_bo_projects").getSingleResult()).longValue();
}
return -1L;
}
}
How can I solve this problem?
I've successfully deployed my two EARs now... thanks for your comments to my original question. My initial approach with 2 EAR including the same data-model JAR works, if the persistence.xml doesn't include the JNDI binding. Thanks #Franck! The mentioned jboss-deployment-structure.xml does no longer refer to my other EAR.
So now my deployment looks like this:
App-ear.ear
|_App-model.jar
|_App-ejb.jar
|_App-web.war
Second-ear.ear
|_App-model.jar
|_Second-web.war
This works for both applications and I've successfully accessed the database in both cases.

Couchbase spring configuration connection issue

I was trying to configure couchdb with spring but when i deploy the project it gives me java.net.ConnectException: Connection refused.
and the dataSource.xml defined below configs. values are read from property file.
<context:annotation-config />
<context:property-placeholder
location="classpath:properties/dataSource.properties" />
<!-- establish couch db connection -->
<couchbase:couchbase bucket="${couch.dbName}" password="" host="${couch.host}" />
<couchbase:template/>
<couchbase:repositories base-package="com.link.twitter.repository"/>
These are the dependencies I used in my POM
<!-- Spring data couchbase -->
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-couchbase</artifactId>
<version>${spring.data.couchbase.version}</version>
</dependency>
<dependency>
<groupId>com.couchbase.client</groupId>
<artifactId>couchbase-client</artifactId>
<version>${couchbase.client.version}</version>
</dependency>
This is the exception Im getting when its deploying.
DEBUG CouchbaseConfigConnection:84 - Reconnecting due to failure to `connect to {QA sa=/127.0.0.1:11210, #Rops=0, #Wops=0, #iq=0, topRop=null,` topWop=null, toWrite=0, interested=0}
java.net.ConnectException: Connection refused
at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method)
at sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:692)
at net.spy.memcached.MemcachedConnection.handleIO(MemcachedConnection.java:677)
at net.spy.memcached.MemcachedConnection.handleIO(MemcachedConnection.java:436)
at com.couchbase.client.CouchbaseConnection.run(CouchbaseConnection.java:325)
how can i fix this issue. Thanks in advance
CouchDB listen for requests on port 5984 by default - your request was sent to 127.0.0.1:11210 and gots rejected.
Change the value of the config param bind_address to 11210
Couchbase and CouchDB are two different products. Your trying to use the Couchbase java client against Couchbase and that will not work. See the http://www.couchbase.com/couchbase-vs-couchdb for more information on the difference between the two products.

Apache ActiveMQ Starts then Stops Abruptly On Windows

I am running apachemq on windows xp.I have no web server services running or any database of any sort,but i keep on getting this error once i start active mq
ERROR | Failed to start Apache ActiveMQ ([localhost,
ID:computer_1-3725-13902958 73141-0:1], java.net.URISyntaxException:
Illegal character in hostname at index 13:
ws://computer_1:61614?maximumConnections=1000&wireFormat.maxFrameSize=104857
600)
This is the complete log
C:\apache_activemq>.\bin\activemq
Java Runtime: Oracle Corporation 1.7.0_21 C:\Program Files\Java\jdk1.7.0_21\jre
Heap sizes: current=1013632k free=996854k max=1013632k
JVM args: -Dcom.sun.management.jmxremote -Xms1G -Xmx1G -Djava.util.logging.c
onfig.file=logging.properties -Dhawtio.realm=activemq -Dhawtio.role=admins -Dhaw
tio.rolePrincipalClasses=org.apache.activemq.jaas.GroupPrincipal -Djava.security
.auth.login.config=C:\apache_activemq\bin\..\conf\login.config -Dactivemq.classp
ath=C:\apache_activemq\bin\..\conf;C:\apache_activemq\bin\../conf;C:\apache_acti
vemq\bin\../conf; -Dactivemq.home=C:\apache_activemq\bin\.. -Dactivemq.base=C:\a
pache_activemq\bin\.. -Dactivemq.conf=C:\apache_activemq\bin\..\conf -Dactivemq.
data=C:\apache_activemq\bin\..\data -Djava.io.tmpdir=C:\apache_activemq\bin\..\d
ata\tmp
Extensions classpath:
[C:\apache_activemq\bin\..\lib,C:\apache_activemq\bin\..\lib\camel,C:\apache_a
ctivemq\bin\..\lib\optional,C:\apache_activemq\bin\..\lib\web,C:\apache_activemq
\bin\..\lib\extra]
ACTIVEMQ_HOME: C:\apache_activemq\bin\..
ACTIVEMQ_BASE: C:\apache_activemq\bin\..
ACTIVEMQ_CONF: C:\apache_activemq\bin\..\conf
ACTIVEMQ_DATA: C:\apache_activemq\bin\..\data
Loading message broker from: xbean:activemq.xml
INFO | Refreshing org.apache.activemq.xbean.XBeanBrokerFactory$1#726b5b: startu
p date [Tue Jan 21 12:17:33 EAT 2014]; root of context hierarchy
INFO | PListStore:[C:\apache_activemq\bin\..\data\localhost\tmp_storage] starte
d
INFO | Using Persistence Adapter: KahaDBPersistenceAdapter[C:\apache_activemq\b
in\..\data\kahadb]
INFO | JMX consoles can connect to service:jmx:rmi:///jndi/rmi://localhost:1099
/jmxrmi
INFO | KahaDB is version 5
INFO | Recovering from the journal ...
INFO | Recovery replayed 14 operations from the journal in 0.16 seconds.
INFO | Apache ActiveMQ 5.9.0 (localhost, ID:computer_1-3725-1390295873141-0:1)
is starting
INFO | Listening for connections at: tcp://0.0.0.0:61616?maximumConnections=100
0&wireFormat.maxFrameSize=104857600
INFO | Connector openwire started
INFO | Listening for connections at: amqp://0.0.0.0:5672?maximumConnections=100
0&wireFormat.maxFrameSize=104857600
INFO | Connector amqp started
INFO | Listening for connections at: stomp://0.0.0.0:61613?maximumConnections=1
000&wireFormat.maxFrameSize=104857600
INFO | Connector stomp started
INFO | Listening for connections at: mqtt://0.0.0.0:1883?maximumConnections=100
0&wireFormat.maxFrameSize=104857600
INFO | Connector mqtt started
ERROR | Failed to start Apache ActiveMQ ([localhost, ID:computer_1-3725-13902958
73141-0:1], java.net.URISyntaxException: Illegal character in hostname at index
13: ws://computer_1:61614?maximumConnections=1000&wireFormat.maxFrameSize=104857
600)
INFO | Apache ActiveMQ 5.9.0 (localhost, ID:computer_1-3725-1390295873141-0:1)
is shutting down
INFO | Connector openwire stopped
INFO | Connector amqp stopped
INFO | Connector stomp stopped
INFO | Connector mqtt stopped
INFO | Connector ws stopped
INFO | PListStore:[C:\apache_activemq\bin\..\data\localhost\tmp_storage] stoppe
d
INFO | Stopping async queue tasks
INFO | Stopping async topic tasks
INFO | Stopped KahaDB
INFO | Apache ActiveMQ 5.9.0 (localhost, ID:computer_1-3725-1390295873141-0:1)
uptime 13.059 seconds
INFO | Apache ActiveMQ 5.9.0 (localhost, ID:computer_1-3725-1390295873141-0:1)
is shutdown
INFO | Closing org.apache.activemq.xbean.XBeanBrokerFactory$1#726b5b: startup d
ate [Tue Jan 21 12:17:33 EAT 2014]; root of context hierarchy
WARN | Exception thrown from LifecycleProcessor on context close
java.lang.IllegalStateException: LifecycleProcessor not initialized - call 'refr
esh' before invoking lifecycle methods via the context: org.apache.activemq.xbea
n.XBeanBrokerFactory$1#726b5b: startup date [Tue Jan 21 12:17:33 EAT 2014]; root
of context hierarchy
at org.springframework.context.support.AbstractApplicationContext.getLif
ecycleProcessor(AbstractApplicationContext.java:360)
at org.springframework.context.support.AbstractApplicationContext.doClos
e(AbstractApplicationContext.java:1057)
at org.springframework.context.support.AbstractApplicationContext.close(
AbstractApplicationContext.java:1010)
at org.apache.activemq.hooks.SpringContextHook.run(SpringContextHook.jav
a:30)
at org.apache.activemq.broker.BrokerService.stop(BrokerService.java:782)
at org.apache.activemq.xbean.XBeanBrokerService.stop(XBeanBrokerService.
java:122)
at org.apache.activemq.broker.BrokerService.start(BrokerService.java:574
)
at org.apache.activemq.xbean.XBeanBrokerService.afterPropertiesSet(XBean
BrokerService.java:73)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at org.springframework.beans.factory.support.AbstractAutowireCapableBean
Factory.invokeCustomInitMethod(AbstractAutowireCapableBeanFactory.java:1608)
at org.springframework.beans.factory.support.AbstractAutowireCapableBean
Factory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1549)
at org.springframework.beans.factory.support.AbstractAutowireCapableBean
Factory.initializeBean(AbstractAutowireCapableBeanFactory.java:1479)
at org.springframework.beans.factory.support.AbstractAutowireCapableBean
Factory.doCreateBean(AbstractAutowireCapableBeanFactory.java:521)
at org.springframework.beans.factory.support.AbstractAutowireCapableBean
Factory.createBean(AbstractAutowireCapableBeanFactory.java:458)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getOb
ject(AbstractBeanFactory.java:295)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistr
y.getSingleton(DefaultSingletonBeanRegistry.java:223)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBe
an(AbstractBeanFactory.java:292)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean
(AbstractBeanFactory.java:194)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.
preInstantiateSingletons(DefaultListableBeanFactory.java:628)
at org.springframework.context.support.AbstractApplicationContext.finish
BeanFactoryInitialization(AbstractApplicationContext.java:932)
at org.springframework.context.support.AbstractApplicationContext.refres
h(AbstractApplicationContext.java:479)
at org.apache.xbean.spring.context.ResourceXmlApplicationContext.<init>(
ResourceXmlApplicationContext.java:64)
at org.apache.xbean.spring.context.ResourceXmlApplicationContext.<init>(
ResourceXmlApplicationContext.java:52)
at org.apache.activemq.xbean.XBeanBrokerFactory$1.<init>(XBeanBrokerFact
ory.java:104)
at org.apache.activemq.xbean.XBeanBrokerFactory.createApplicationContext
(XBeanBrokerFactory.java:104)
at org.apache.activemq.xbean.XBeanBrokerFactory.createBroker(XBeanBroker
Factory.java:67)
at org.apache.activemq.broker.BrokerFactory.createBroker(BrokerFactory.j
ava:71)
at org.apache.activemq.broker.BrokerFactory.createBroker(BrokerFactory.j
ava:54)
at org.apache.activemq.console.command.StartCommand.runTask(StartCommand
.java:87)
at org.apache.activemq.console.command.AbstractCommand.execute(AbstractC
ommand.java:57)
at org.apache.activemq.console.command.ShellCommand.runTask(ShellCommand
.java:150)
at org.apache.activemq.console.command.AbstractCommand.execute(AbstractC
ommand.java:57)
at org.apache.activemq.console.command.ShellCommand.main(ShellCommand.ja
va:104)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at org.apache.activemq.console.Main.runTaskClass(Main.java:262)
at org.apache.activemq.console.Main.main(Main.java:115)
ERROR: java.lang.RuntimeException: Failed to execute start task. Reason: java.la
ng.IllegalStateException: BeanFactory not initialized or already closed - call '
refresh' before accessing beans via the ApplicationContext
java.lang.RuntimeException: Failed to execute start task. Reason: java.lang.Ille
galStateException: BeanFactory not initialized or already closed - call 'refresh
' before accessing beans via the ApplicationContext
at org.apache.activemq.console.command.StartCommand.runTask(StartCommand
.java:91)
at org.apache.activemq.console.command.AbstractCommand.execute(AbstractC
ommand.java:57)
at org.apache.activemq.console.command.ShellCommand.runTask(ShellCommand
.java:150)
at org.apache.activemq.console.command.AbstractCommand.execute(AbstractC
ommand.java:57)
at org.apache.activemq.console.command.ShellCommand.main(ShellCommand.ja
va:104)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at org.apache.activemq.console.Main.runTaskClass(Main.java:262)
at org.apache.activemq.console.Main.main(Main.java:115)
Caused by: java.lang.IllegalStateException: BeanFactory not initialized or alrea
dy closed - call 'refresh' before accessing beans via the ApplicationContext
at org.springframework.context.support.AbstractRefreshableApplicationCon
text.getBeanFactory(AbstractRefreshableApplicationContext.java:171)
at org.springframework.context.support.AbstractApplicationContext.destro
yBeans(AbstractApplicationContext.java:1090)
at org.springframework.context.support.AbstractApplicationContext.refres
h(AbstractApplicationContext.java:487)
at org.apache.xbean.spring.context.ResourceXmlApplicationContext.<init>(
ResourceXmlApplicationContext.java:64)
at org.apache.xbean.spring.context.ResourceXmlApplicationContext.<init>(
ResourceXmlApplicationContext.java:52)
at org.apache.activemq.xbean.XBeanBrokerFactory$1.<init>(XBeanBrokerFact
ory.java:104)
at org.apache.activemq.xbean.XBeanBrokerFactory.createApplicationContext
(XBeanBrokerFactory.java:104)
at org.apache.activemq.xbean.XBeanBrokerFactory.createBroker(XBeanBroker
Factory.java:67)
at org.apache.activemq.broker.BrokerFactory.createBroker(BrokerFactory.j
ava:71)
at org.apache.activemq.broker.BrokerFactory.createBroker(BrokerFactory.j
ava:54)
at org.apache.activemq.console.command.StartCommand.runTask(StartCommand
.java:87)
... 10 more
ERROR: java.lang.IllegalStateException: BeanFactory not initialized or already c
losed - call 'refresh' before accessing beans via the ApplicationContext
java.lang.IllegalStateException: BeanFactory not initialized or already closed -
call 'refresh' before accessing beans via the ApplicationContext
at org.springframework.context.support.AbstractRefreshableApplicationCon
text.getBeanFactory(AbstractRefreshableApplicationContext.java:171)
at org.springframework.context.support.AbstractApplicationContext.destro
yBeans(AbstractApplicationContext.java:1090)
at org.springframework.context.support.AbstractApplicationContext.refres
h(AbstractApplicationContext.java:487)
at org.apache.xbean.spring.context.ResourceXmlApplicationContext.<init>(
ResourceXmlApplicationContext.java:64)
at org.apache.xbean.spring.context.ResourceXmlApplicationContext.<init>(
ResourceXmlApplicationContext.java:52)
at org.apache.activemq.xbean.XBeanBrokerFactory$1.<init>(XBeanBrokerFact
ory.java:104)
at org.apache.activemq.xbean.XBeanBrokerFactory.createApplicationContext
(XBeanBrokerFactory.java:104)
at org.apache.activemq.xbean.XBeanBrokerFactory.createBroker(XBeanBroker
Factory.java:67)
at org.apache.activemq.broker.BrokerFactory.createBroker(BrokerFactory.j
ava:71)
at org.apache.activemq.broker.BrokerFactory.createBroker(BrokerFactory.j
ava:54)
at org.apache.activemq.console.command.StartCommand.runTask(StartCommand
.java:87)
at org.apache.activemq.console.command.AbstractCommand.execute(AbstractC
ommand.java:57)
at org.apache.activemq.console.command.ShellCommand.runTask(ShellCommand
.java:150)
at org.apache.activemq.console.command.AbstractCommand.execute(AbstractC
ommand.java:57)
at org.apache.activemq.console.command.ShellCommand.main(ShellCommand.ja
va:104)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at org.apache.activemq.console.Main.runTaskClass(Main.java:262)
at org.apache.activemq.console.Main.main(Main.java:115)
C:\apache_activemq>
My %SystemRoot%\system32\drivers\etc\hosts looks like this
127.0.0.1 localhost
127.0.0.1 mpa.one.microsoft.com
My activemq.xml looks like this
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<!-- START SNIPPET: example -->
<beans
xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://activemq.apache.org/schema/core http://activemq.apache.org/schema/core/activemq-core.xsd">
<!-- Allows us to use system properties as variables in this configuration file -->
<bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="locations">
<value>file:${activemq.conf}/credentials.properties</value>
</property>
</bean>
<!-- Allows log searching in hawtio console -->
<bean id="logQuery" class="org.fusesource.insight.log.log4j.Log4jLogQuery"
lazy-init="false" scope="singleton"
init-method="start" destroy-method="stop">
</bean>
<!--
The <broker> element is used to configure the ActiveMQ broker.
-->
<broker xmlns="http://activemq.apache.org/schema/core" brokerName="localhost" dataDirectory="${activemq.data}">
<destinationPolicy>
<policyMap>
<policyEntries>
<policyEntry topic=">" >
<!-- The constantPendingMessageLimitStrategy is used to prevent
slow topic consumers to block producers and affect other consumers
by limiting the number of messages that are retained
For more information, see:
http://activemq.apache.org/slow-consumer-handling.html
-->
<pendingMessageLimitStrategy>
<constantPendingMessageLimitStrategy limit="1000"/>
</pendingMessageLimitStrategy>
</policyEntry>
</policyEntries>
</policyMap>
</destinationPolicy>
<!--
The managementContext is used to configure how ActiveMQ is exposed in
JMX. By default, ActiveMQ uses the MBean server that is started by
the JVM. For more information, see:
http://activemq.apache.org/jmx.html
-->
<managementContext>
<managementContext createConnector="true"/>
</managementContext>
<!--
Configure message persistence for the broker. The default persistence
mechanism is the KahaDB store (identified by the kahaDB tag).
For more information, see:
http://activemq.apache.org/persistence.html
-->
<persistenceAdapter>
<kahaDB directory="${activemq.data}/kahadb"/>
</persistenceAdapter>
<!--
The systemUsage controls the maximum amount of space the broker will
use before disabling caching and/or slowing down producers. For more information, see:
http://activemq.apache.org/producer-flow-control.html
-->
<systemUsage>
<systemUsage>
<memoryUsage>
<memoryUsage percentOfJvmHeap="70" />
</memoryUsage>
<storeUsage>
<storeUsage limit="100 gb"/>
</storeUsage>
<tempUsage>
<tempUsage limit="50 gb"/>
</tempUsage>
</systemUsage>
</systemUsage>
<!--
The transport connectors expose ActiveMQ over a given protocol to
clients and other brokers. For more information, see:
http://activemq.apache.org/configuring-transports.html
-->
<transportConnectors>
<!-- DOS protection, limit concurrent connections to 1000 and frame size to 100MB -->
<transportConnector name="openwire" uri="tcp://0.0.0.0:61616?maximumConnections=1000&wireFormat.maxFrameSize=104857600"/>
<transportConnector name="amqp" uri="amqp://0.0.0.0:5672?maximumConnections=1000&wireFormat.maxFrameSize=104857600"/>
<transportConnector name="stomp" uri="stomp://0.0.0.0:61613?maximumConnections=1000&wireFormat.maxFrameSize=104857600"/>
<transportConnector name="mqtt" uri="mqtt://0.0.0.0:1883?maximumConnections=1000&wireFormat.maxFrameSize=104857600"/>
<transportConnector name="ws" uri="ws://0.0.0.0:61614?maximumConnections=1000&wireFormat.maxFrameSize=104857600"/>
</transportConnectors>
<!-- destroy the spring context on shutdown to stop jetty -->
<shutdownHooks>
<bean xmlns="http://www.springframework.org/schema/beans" class="org.apache.activemq.hooks.SpringContextHook" />
</shutdownHooks>
</broker>
<!--
Enable web consoles, REST and Ajax APIs and demos
The web consoles requires by default login, you can disable this in the jetty.xml file
Take a look at ${ACTIVEMQ_HOME}/conf/jetty.xml for more details
-->
<import resource="jetty.xml"/>
</beans>
<!-- END SNIPPET: example -->
How should i fix this error?.
I had similar problem. The problem gone after reboot. Try to reboot PC and start activemq first.
Probably it related that some ports were already taken.
My hostname which is localhost did not contain any underscores.The only underscore was in my computer name.My old name was computer_1 but i changed it to computer1 and now i am able to use localhost:8161 activemq web console.
To know how to change the computer name when on windows,do google it or refer to windows documentation.This error has nothing to do with hostname proper but rather the computer name.
Check your "activemq.log" in your "data" folder, in my case I obtain this error because I was using a "redeliveryPlugin" and it requires a schedulerSupport="true" in broker definition.

JBoss: can not connect to MySQL database

I am running JBoss as standalone version. I would like to connect to my local mysql database
I copied the mysql connector in modules folder
me#air~/Downloads/jboss/standalone/configuration - 10:56:18 $ ls ../../modules/org/mysql/main/
mysql-connector-java-5.1.22-bin.jar
Next I changed the standalone.xml in jboss/standalone/configuration as
<drivers>
<driver name="com.mysql" module="org.mysql" />
<driver name="h2" module="com.h2database.h2"> <!-- default provided-->
<xa-datasource-class>org.h2.jdbcx.JdbcDataSource</xa-datasource-class>
</driver>
</drivers>
Then I added the datasource as
<datasource jndi-name="java:/bb" pool-name="bb-pool" enabled="true" use-java-context="true" use-ccm="true">
<connection-url>jdbc:mysql://127.0.0.1:3306/mydb</connection-url>
<driver>mysql</driver>
<pool>
<min-pool-size>10</min-pool-size>
<max-pool-size>100</max-pool-size>
<prefill>true</prefill>
</pool>
<security>
<user-name>bb</user-name>
<password>bb</password>
</security>
<statement>
<prepared-statement-cache-size>100</prepared-statement-cache-size>
<share-prepared-statements>true</share-prepared-statements>
</statement>
</datasource>
I am using JBoss AS 7.1.
When I start the server on console, I see errors
10:54:47,458 INFO [org.jboss.as.connector.subsystems.datasources] (MSC service thread 1-1) JBAS010400: Bound data source [java:jboss/datasources/ExampleDS]
10:54:47,671 INFO [org.jboss.as.controller] (Controller Boot Thread) JBAS014774: Service status report
JBAS014775: New missing/unsatisfied dependencies:
service jboss.jdbc-driver.mysql (missing) dependents: [service jboss.data-source.java:/bb]
10:54:47,676 INFO [org.jboss.as] (Controller Boot Thread) JBAS015951: Admin console listening on http://127.0.0.1:9990
10:54:47,676 ERROR [org.jboss.as] (Controller Boot Thread) JBAS015875: JBoss AS 7.1.1.Final "Brontes" started (with errors) in 2000ms - Started 134 of 212 services (2 services failed or missing dependencies, 74 services are passive or on-demand)
and when I hit Ctrl+C, I see
^C10:54:54,998 INFO [org.jboss.as.osgi] (MSC service thread 1-8) JBAS011942: Stopping OSGi Framework
10:54:55,004 INFO [org.jboss.as.logging] JBAS011503: Restored bootstrap log handlers
10:54:55,007 INFO [com.arjuna.ats.jbossatx] ARJUNA032018: Destroying TransactionManagerService
10:54:55,008 INFO [com.arjuna.ats.jbossatx] ARJUNA032014: Stopping transaction recovery manager
10:54:55,010 INFO [org.apache.catalina.core.StandardContext] Container org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/] has not been started
10:54:55,039 INFO [org.apache.coyote.http11.Http11Protocol] Pausing Coyote HTTP/1.1 on http--127.0.0.1-8080
10:54:55,039 INFO [org.apache.coyote.http11.Http11Protocol] Stopping Coyote HTTP/1.1 on http--127.0.0.1-8080
10:54:55,043 INFO [org.jboss.as.controller] JBAS014774: Service status report
JBAS014776: Newly corrected services:
service jboss.jdbc-driver.mysql (new available)
10:54:55,044 INFO [org.jboss.as] JBAS015950: JBoss AS 7.1.1.Final "Brontes" stopped in 47ms
I am new to JBoss and don't know how to fix this issue or to understand what is that I am doing wrong here
I think in your datasource you are referencing the driver mysql, but you named the driver com.mysql.
Try changing one the driver name to mysql.
Just a note: it is best to use the CLI to install the drivers and use the CLI or Web Console to build your datasources. The intention with AS7 is that these tools are used for all of your config and there are very few reasons why you should touch the XML yourself.
I had exactly the same mistake. Took me hours to find out how dumb it was.
In my case I was running jboss as a service under the jboss-as user, nice and easy. Except that when I created the mysql/main directory, along with the files within, I was under another user. No permissions there for jboss-as guy.
A simple chown on modules/ directory did the job.
First of all, your driver definition name doesn't match the driver name under the <datasource> definition. Replace <driver name="com.mysql" ... with <driver name="mysql" ... for it to work.
Second, have you added the module.xml file? It's not enough to copy the MySQL connector jar in the ./modules/com/mysql/main folder, you also have to add the module.xml file:
<?xml version="1.0" encoding="UTF-8"?>
<module xmlns="urn:jboss:module:1.1" name="com.mysql">
<resources>
<resource-root path="mysql-connector-java-5.1.26-bin.jar"/>
</resources>
<dependencies>
<module name="javax.api"/>
<module name="javax.transaction.api"/>
</dependencies>
</module>
Also, I had a strage similar problem when using the MySQL connector version 5.0.8, where the driver was not found / recognized. It disappeared when I switched to the newer 5.1.26 version.
Make sure you are using latest version of mysql jdbc connector , i solve same issue of mine with replacing latest mysql connetor

Categories

Resources