You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@activemq.apache.org by msmith <ms...@denimgroup.com> on 2012/02/15 01:01:36 UTC

Re: Duplicate brokers created in Tomcat

Hello. I have a similar problem that I would greatly appreciate any guidance
towards resolving it. 

I divided up a Spring web application into two WAR files and deployed them
onto an Apache Tomcat 7 server. If either WAR is deployed I get no errors
and can view the associated web pages, but if both are deployed at the same
time the log states:         

INFO : org.apache.activemq.store.kahadb.plist.PListStore -
PListStore:..\activemq-data\localhost\tmp_storage started
INFO : org.apache.activemq.broker.BrokerService - Using Persistence Adapter:
KahaDBPersistenceAdapter[C:\Program Files\Apache Software Foundation\Tomcat
7.0\..\activemq-data\localhost\KahaDB]
INFO : org.apache.activemq.store.kahadb.MessageDatabase - Database
..\activemq-data\localhost\KahaDB\lock is locked... waiting 10 seconds for
the database to be unlocked. Reason: java.io.IOException: File
'..\activemq-data\localhost\KahaDB\lock' could not be locked as lock is
already held for this jvm.
INFO : org.apache.activemq.store.kahadb.MessageDatabase - Database
..\activemq-data\localhost\KahaDB\lock is locked... waiting 10 seconds for
the database to be unlocked. Reason: java.io.IOException: File
'..\activemq-data\localhost\KahaDB\lock' could not be locked as lock is
already held for this jvm.

The Tomcat server uses activemq-data and KahaDB as its file based
persistence database (not sure what version - my apologies). Both projects
contain the same (duplicate) ConnectionFactory bean:     
		
<bean id=&quot;connectionFactory&quot;
       
class=&quot;&lt;b>org.springframework.jms.connection.CachingConnectionFactory*"
        p:exceptionListener-ref="jmsExceptionListener"
p:sessionCacheSize="100">
        <constructor-arg ref="amqConnectionFactory" />
</bean>

Finally, the jms broker URL specified within each project is:
url=vm://localhost?broker.useJmx=false&broker.dataDirectory=../activemq-data

I have been reading up on embedded vs. standalone activemq servers and have
tried implementing both but have not met with success. My problem(s) here
may be an obvious one  - I have been looking too long at this and would
welcome any suggestions or thoughts.


--
View this message in context: http://activemq.2283324.n4.nabble.com/Duplicate-brokers-created-in-Tomcat-tp3003512p4389009.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.

RE: Duplicate brokers created in Tomcat

Posted by msmith <ms...@denimgroup.com>.
Thanks so much for your reply. Extremely helpful, and the external broker is the approach I'm taking.

From: Torsten Mielke-2 [via ActiveMQ] [mailto:ml-node+s2283324n4389954h47@n4.nabble.com]
Sent: Wednesday, February 15, 2012 3:59 AM
To: Mark Smith
Subject: Re: Duplicate brokers created in Tomcat

Hello,

Looks like you get two embedded broker instances created at runtime in the same JVM. As both instances use probably the same configuration, they both compete over the same lock on the same kahadb folder on the file system.
Both of your project use the same broker url vm://. As you know, the vm transport is for connecting to an embedded broker. Both projects are in their own war file with their own spring context and configuration. So at runtime each project does not know anything about a broker already being present in the other project.

Do you really want to use an embedded broker or is an external broker better suited? The easiest solution is to use an external broker and change the broker url to be tcp://localhost:61616, or whatever address the broker runs on.
That way the brokers lifetime isn't bound to the lifetime of Tomcat or your deployed web applications.

Hope this helps.



Torsten Mielke
[hidden email]</user/SendEmail.jtp?type=node&node=4389954&i=0>
[hidden email]</user/SendEmail.jtp?type=node&node=4389954&i=1>


On Feb 15, 2012, at 1:01 AM, msmith wrote:

> Hello. I have a similar problem that I would greatly appreciate any guidance
> towards resolving it.
>
> I divided up a Spring web application into two WAR files and deployed them
> onto an Apache Tomcat 7 server. If either WAR is deployed I get no errors
> and can view the associated web pages, but if both are deployed at the same
> time the log states:
>
> INFO : org.apache.activemq.store.kahadb.plist.PListStore -
> PListStore:..\activemq-data\localhost\tmp_storage started
> INFO : org.apache.activemq.broker.BrokerService - Using Persistence Adapter:
> KahaDBPersistenceAdapter[C:\Program Files\Apache Software Foundation\Tomcat
> 7.0\..\activemq-data\localhost\KahaDB]
> INFO : org.apache.activemq.store.kahadb.MessageDatabase - Database
> ..\activemq-data\localhost\KahaDB\lock is locked... waiting 10 seconds for
> the database to be unlocked. Reason: java.io.IOException: File
> '..\activemq-data\localhost\KahaDB\lock' could not be locked as lock is
> already held for this jvm.
> INFO : org.apache.activemq.store.kahadb.MessageDatabase - Database
> ..\activemq-data\localhost\KahaDB\lock is locked... waiting 10 seconds for
> the database to be unlocked. Reason: java.io.IOException: File
> '..\activemq-data\localhost\KahaDB\lock' could not be locked as lock is
> already held for this jvm.
>
> The Tomcat server uses activemq-data and KahaDB as its file based
> persistence database (not sure what version - my apologies). Both projects
> contain the same (duplicate) ConnectionFactory bean:
>
> <bean id=&quot;connectionFactory&quot;
>
> class=&quot;&lt;b>org.springframework.jms.connection.CachingConnectionFactory*"
>        p:exceptionListener-ref="jmsExceptionListener"
> p:sessionCacheSize="100">
>        <constructor-arg ref="amqConnectionFactory" />
> </bean>
>
> Finally, the jms broker URL specified within each project is:
> url=vm://localhost?broker.useJmx=false&broker.dataDirectory=../activemq-data
>
> I have been reading up on embedded vs. standalone activemq servers and have
> tried implementing both but have not met with success. My problem(s) here
> may be an obvious one  - I have been looking too long at this and would
> welcome any suggestions or thoughts.
>
>
> --
> View this message in context: http://activemq.2283324.n4.nabble.com/Duplicate-brokers-created-in-Tomcat-tp3003512p4389009.html
> Sent from the ActiveMQ - User mailing list archive at Nabble.com.




________________________________
If you reply to this email, your message will be added to the discussion below:
http://activemq.2283324.n4.nabble.com/Duplicate-brokers-created-in-Tomcat-tp3003512p4389954.html
To unsubscribe from Duplicate brokers created in Tomcat, click here<http://activemq.2283324.n4.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=3003512&code=bXNtaXRoQGRlbmltZ3JvdXAuY29tfDMwMDM1MTJ8MjY5OTY2NDgx>.
NAML<http://activemq.2283324.n4.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>


--
View this message in context: http://activemq.2283324.n4.nabble.com/Duplicate-brokers-created-in-Tomcat-tp3003512p4392252.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.

Re: Duplicate brokers created in Tomcat

Posted by Torsten Mielke <to...@fusesource.com>.
Hello,

Looks like you get two embedded broker instances created at runtime in the same JVM. As both instances use probably the same configuration, they both compete over the same lock on the same kahadb folder on the file system. 
Both of your project use the same broker url vm://. As you know, the vm transport is for connecting to an embedded broker. Both projects are in their own war file with their own spring context and configuration. So at runtime each project does not know anything about a broker already being present in the other project.

Do you really want to use an embedded broker or is an external broker better suited? The easiest solution is to use an external broker and change the broker url to be tcp://localhost:61616, or whatever address the broker runs on. 
That way the brokers lifetime isn't bound to the lifetime of Tomcat or your deployed web applications. 

Hope this helps.



Torsten Mielke
torsten@fusesource.com
tmielke@blogspot.com


On Feb 15, 2012, at 1:01 AM, msmith wrote:

> Hello. I have a similar problem that I would greatly appreciate any guidance
> towards resolving it. 
> 
> I divided up a Spring web application into two WAR files and deployed them
> onto an Apache Tomcat 7 server. If either WAR is deployed I get no errors
> and can view the associated web pages, but if both are deployed at the same
> time the log states:         
> 
> INFO : org.apache.activemq.store.kahadb.plist.PListStore -
> PListStore:..\activemq-data\localhost\tmp_storage started
> INFO : org.apache.activemq.broker.BrokerService - Using Persistence Adapter:
> KahaDBPersistenceAdapter[C:\Program Files\Apache Software Foundation\Tomcat
> 7.0\..\activemq-data\localhost\KahaDB]
> INFO : org.apache.activemq.store.kahadb.MessageDatabase - Database
> ..\activemq-data\localhost\KahaDB\lock is locked... waiting 10 seconds for
> the database to be unlocked. Reason: java.io.IOException: File
> '..\activemq-data\localhost\KahaDB\lock' could not be locked as lock is
> already held for this jvm.
> INFO : org.apache.activemq.store.kahadb.MessageDatabase - Database
> ..\activemq-data\localhost\KahaDB\lock is locked... waiting 10 seconds for
> the database to be unlocked. Reason: java.io.IOException: File
> '..\activemq-data\localhost\KahaDB\lock' could not be locked as lock is
> already held for this jvm.
> 
> The Tomcat server uses activemq-data and KahaDB as its file based
> persistence database (not sure what version - my apologies). Both projects
> contain the same (duplicate) ConnectionFactory bean:     
> 		
> <bean id=&quot;connectionFactory&quot;
> 
> class=&quot;&lt;b>org.springframework.jms.connection.CachingConnectionFactory*"
>        p:exceptionListener-ref="jmsExceptionListener"
> p:sessionCacheSize="100">
>        <constructor-arg ref="amqConnectionFactory" />
> </bean>
> 
> Finally, the jms broker URL specified within each project is:
> url=vm://localhost?broker.useJmx=false&broker.dataDirectory=../activemq-data
> 
> I have been reading up on embedded vs. standalone activemq servers and have
> tried implementing both but have not met with success. My problem(s) here
> may be an obvious one  - I have been looking too long at this and would
> welcome any suggestions or thoughts.
> 
> 
> --
> View this message in context: http://activemq.2283324.n4.nabble.com/Duplicate-brokers-created-in-Tomcat-tp3003512p4389009.html
> Sent from the ActiveMQ - User mailing list archive at Nabble.com.