You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Markus Wolf <ma...@nmmn.com> on 2009/02/24 14:34:24 UTC

Camel + ActiveMQ in Tomcat6

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi,

I try to deploy a camel context using spring inside Tomcat6 with ActiveMQ.

We have the following setup:
  CATALINA_HOME
    /lib/ext/activemq.jar
    /lib/ext/camel-core.jar
    /webapp/ROOT/WEB-INF/lib/camel-jms.jar
    /webapp/ROOT/WEB-INF/lib/camel-spring.jar
    /webapp/ROOT/WEB-INF/lib/spring-and-dependencies.jar

When we start our tomcat we get a ClassNotFoundException for the
org.apache.camel.component.jms.JmsComponent. And now I'm unsure how to
deploy the whole thing 'the right way'.
When we put activemq with camel-core into our webapp we have classloader
leaks and cannot undeploy our application.
When we put camel-jms into the lib/ext folder of tomcat we are forced to
place the whole spring and dependencies there also. That seems wrong to
me also.

Can anyone give me a hint about the deployment?
Thanks
Markus Wolf
- --
NMMN - New Media Markets & Networks GmbH
Geschäftsführung: Kfm. Michael Schütt
Finanzamt HH-Altona UStID DE 812 699 852  HRB 71102 Hamburg
HypoVereinsbank  -   BLZ 200 300 00  -  Konto-Nr. 156 29 82

http://www.nmmn.com               Tel.: +49 40 284 118 -0
Langbehnstrasse 6                 Entwicklung:         -720
22761 Hamburg                     Fax:                 -999

Rufen Sie uns kostenlos an: http://www.nmmn.com/call/software
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkmj91gACgkQDBHISU1oEKFSYACfUsgx01wj1UcLbQr2trc8m/Gv
gVUAn22zloCis2pjVjSlLPz6fBLyqghs
=7swM
-----END PGP SIGNATURE-----

Re: Camel + ActiveMQ in Tomcat6

Posted by Gert Vanthienen <ge...@skynet.be>.
Markus,

Could you verify that it is not a thread leak that is causing the 
PermGen memory leak?  If you have threads being left behind when 
undeploying the WAR file (e.g. a JMS connection not closed properly), 
these threads will probably hang on to the classloader. 

Regards,

Gert

James Strachan wrote:
> 2009/2/24 Markus Wolf <ma...@nmmn.com>:
>   
>> -----BEGIN PGP SIGNED MESSAGE-----
>> Hash: SHA1
>>
>>     
>>>> this approach does not help me, since when the ActiveMQ is created by
>>>> tomcats webapplication classloader it cannot be undeployed.
>>>>         
>>> You don't have to create the broker in the WAR (or you could put it in
>>> another WAR). This approach works totally fine if you are using the
>>> ActiveMQ JMS client with Camel.
>>>
>>>       
>> But it requires to put the activemq-core dependency to the webapp for
>> creating the ConnectionFactory for ActiveMQ, doesn't it? Or am I missing
>> something here.
>>     
>
> Yes. How else could you use ActiveMQ from a web app?
>
>
>   
>> Even starting the ConnectionFactory produce memory leaks in the webapp
>> classloader.
>>     
>
> Not sure what you mean by "memory leak in the web app class loader".
> Do you consider adding a class to a class loader a leak? :)
>
>   


Re: Camel + ActiveMQ in Tomcat6

Posted by Markus Wolf <ma...@nmmn.com>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

>>>> this approach does not help me, since when the ActiveMQ is created by
>>>> tomcats webapplication classloader it cannot be undeployed.
>>> You don't have to create the broker in the WAR (or you could put it in
>>> another WAR). This approach works totally fine if you are using the
>>> ActiveMQ JMS client with Camel.
>>>
>> But it requires to put the activemq-core dependency to the webapp for
>> creating the ConnectionFactory for ActiveMQ, doesn't it? Or am I missing
>> something here.
> 
> Yes. How else could you use ActiveMQ from a web app?
> 
Ok, then at least I do not have missunderstood ActiveMQ. :-)

>> Even starting the ConnectionFactory produce memory leaks in the webapp
>> classloader.
> 
> Not sure what you mean by "memory leak in the web app class loader".
> Do you consider adding a class to a class loader a leak? :)
> 
As I described earlier the thread pool usage of ActiveMQ (the
ActiveMQConnectionFactory and TcpTransport use them) keep references
which cause the webapp classloader not to get garbage collected at
undeployment of the webapp.

It is the following way when look at a memory dump:

ActiveMQConnectionFactory creates
java.util.concurrent.ScheduledThreadPoolExecutor with a custom
ThreadFactory.
When the webapp is undeployed the ActiveMQConnectionFactory could not be
garbage collected because the ThreadPool keeps a reference to the
ThreadFactory. This is caused by the following classloader dependencies:
* The ThreadPool is loaded by the bootstrap classloder
* The ThreadFactory is loaded by the webapp classloader
The reference in the ThreadPool (to the ThreadFactory) is not reset to
null (or a class loaded by the bootstrap classloader). So the ThreadPool
held by the bootstrap classloader references the thread factory which
references the webapp classloader.
Thats the leak.

Markus

- --
NMMN - New Media Markets & Networks GmbH
Geschäftsführung: Kfm. Michael Schütt
Finanzamt HH-Altona UStID DE 812 699 852  HRB 71102 Hamburg
HypoVereinsbank  -   BLZ 200 300 00  -  Konto-Nr. 156 29 82

http://www.nmmn.com               Tel.: +49 40 284 118 -0
Langbehnstrasse 6                 Entwicklung:         -720
22761 Hamburg                     Fax:                 -999

Rufen Sie uns kostenlos an: http://www.nmmn.com/call/software
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkmkA/AACgkQDBHISU1oEKGRfACgzCuKooGJ2NcHVgBiJeXqb2oO
x+YAoIS9JDpOWA5wMhIpdk/sq9gFpukn
=JamU
-----END PGP SIGNATURE-----

Re: Camel + ActiveMQ in Tomcat6

Posted by James Strachan <ja...@gmail.com>.
2009/2/24 Markus Wolf <ma...@nmmn.com>:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
>>> this approach does not help me, since when the ActiveMQ is created by
>>> tomcats webapplication classloader it cannot be undeployed.
>>
>> You don't have to create the broker in the WAR (or you could put it in
>> another WAR). This approach works totally fine if you are using the
>> ActiveMQ JMS client with Camel.
>>
> But it requires to put the activemq-core dependency to the webapp for
> creating the ConnectionFactory for ActiveMQ, doesn't it? Or am I missing
> something here.

Yes. How else could you use ActiveMQ from a web app?


> Even starting the ConnectionFactory produce memory leaks in the webapp
> classloader.

Not sure what you mean by "memory leak in the web app class loader".
Do you consider adding a class to a class loader a leak? :)

-- 
James
-------
http://macstrac.blogspot.com/

Open Source Integration
http://fusesource.com/

Re: Camel + ActiveMQ in Tomcat6

Posted by Markus Wolf <ma...@nmmn.com>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

>> this approach does not help me, since when the ActiveMQ is created by
>> tomcats webapplication classloader it cannot be undeployed.
> 
> You don't have to create the broker in the WAR (or you could put it in
> another WAR). This approach works totally fine if you are using the
> ActiveMQ JMS client with Camel.
> 
But it requires to put the activemq-core dependency to the webapp for
creating the ConnectionFactory for ActiveMQ, doesn't it? Or am I missing
something here.
Even starting the ConnectionFactory produce memory leaks in the webapp
classloader.

Markus
- --
NMMN - New Media Markets & Networks GmbH
Geschäftsführung: Kfm. Michael Schütt
Finanzamt HH-Altona UStID DE 812 699 852  HRB 71102 Hamburg
HypoVereinsbank  -   BLZ 200 300 00  -  Konto-Nr. 156 29 82

http://www.nmmn.com               Tel.: +49 40 284 118 -0
Langbehnstrasse 6                 Entwicklung:         -720
22761 Hamburg                     Fax:                 -999

Rufen Sie uns kostenlos an: http://www.nmmn.com/call/software
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkmkAM4ACgkQDBHISU1oEKHziwCcC22oLbH6eesbfC6tKvefB8yh
bo4AoILeSJp1v/k99vKAWl/g7Ut8O0Wz
=fmv8
-----END PGP SIGNATURE-----

Re: Camel + ActiveMQ in Tomcat6

Posted by James Strachan <ja...@gmail.com>.
2009/2/24 Markus Wolf <ma...@nmmn.com>:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Hi James,
>
> this approach does not help me, since when the ActiveMQ is created by
> tomcats webapplication classloader it cannot be undeployed.

You don't have to create the broker in the WAR (or you could put it in
another WAR). This approach works totally fine if you are using the
ActiveMQ JMS client with Camel.

-- 
James
-------
http://macstrac.blogspot.com/

Open Source Integration
http://fusesource.com/

Re: Camel + ActiveMQ in Tomcat6

Posted by Markus Wolf <ma...@nmmn.com>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi James,

this approach does not help me, since when the ActiveMQ is created by
tomcats webapplication classloader it cannot be undeployed. There are
many ThreadPools in ActiveMQ which keep strong references to
ThreadPoolFactories. The ThreadPools are loaded by the bootstrap
classloader of the jvm and the ThreadPoolFactories are loaded by the
webappclassloader. There is currently no cleanup of this leaks (we are
using activemq 5.1.0).

Markus

> BTW there is a WAR I've been using for testing that creates a camel
> context and uses ActiveMQ - then creating a web console to let you
> interact with ActiveMQ endpoints (sending messages and browsing queues
> etc)...
> https://svn.apache.org/repos/asf/camel/trunk/components/camel-activemq-web/
> 
> for more information see
> http://camel.apache.org/web-console.html
> 
> though it does depend on trunk though! But once 2.0 is out you'll be
> able to reuse this - and use it as a base to create your own WAR
> complete with the Camel web console
> 
> 
> 2009/2/24 Markus Wolf <ma...@nmmn.com>:
> Hi,
> 
> I try to deploy a camel context using spring inside Tomcat6 with ActiveMQ.
> 
> We have the following setup:
>  CATALINA_HOME
>    /lib/ext/activemq.jar
>    /lib/ext/camel-core.jar
>    /webapp/ROOT/WEB-INF/lib/camel-jms.jar
>    /webapp/ROOT/WEB-INF/lib/camel-spring.jar
>    /webapp/ROOT/WEB-INF/lib/spring-and-dependencies.jar
> 
> When we start our tomcat we get a ClassNotFoundException for the
> org.apache.camel.component.jms.JmsComponent. And now I'm unsure how to
> deploy the whole thing 'the right way'.
> When we put activemq with camel-core into our webapp we have classloader
> leaks and cannot undeploy our application.
> When we put camel-jms into the lib/ext folder of tomcat we are forced to
> place the whole spring and dependencies there also. That seems wrong to
> me also.
> 
> Can anyone give me a hint about the deployment?
> Thanks
> Markus Wolf
>>

- --
NMMN - New Media Markets & Networks GmbH
Geschäftsführung: Kfm. Michael Schütt
Finanzamt HH-Altona UStID DE 812 699 852  HRB 71102 Hamburg
HypoVereinsbank  -   BLZ 200 300 00  -  Konto-Nr. 156 29 82

http://www.nmmn.com               Tel.: +49 40 284 118 -0
Langbehnstrasse 6                 Entwicklung:         -720
22761 Hamburg                     Fax:                 -999

Rufen Sie uns kostenlos an: http://www.nmmn.com/call/software
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkmj/iUACgkQDBHISU1oEKGtmgCgg7AYSkiIB0/EqUOdMy8LkbG6
er4AoKa4Q8RVcjzeyR6dSglKPbwvU/lk
=/wzB
-----END PGP SIGNATURE-----

Re: Camel + ActiveMQ in Tomcat6

Posted by James Strachan <ja...@gmail.com>.
BTW there is a WAR I've been using for testing that creates a camel
context and uses ActiveMQ - then creating a web console to let you
interact with ActiveMQ endpoints (sending messages and browsing queues
etc)...
https://svn.apache.org/repos/asf/camel/trunk/components/camel-activemq-web/

for more information see
http://camel.apache.org/web-console.html

though it does depend on trunk though! But once 2.0 is out you'll be
able to reuse this - and use it as a base to create your own WAR
complete with the Camel web console


2009/2/24 Markus Wolf <ma...@nmmn.com>:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Hi,
>
> I try to deploy a camel context using spring inside Tomcat6 with ActiveMQ.
>
> We have the following setup:
>  CATALINA_HOME
>    /lib/ext/activemq.jar
>    /lib/ext/camel-core.jar
>    /webapp/ROOT/WEB-INF/lib/camel-jms.jar
>    /webapp/ROOT/WEB-INF/lib/camel-spring.jar
>    /webapp/ROOT/WEB-INF/lib/spring-and-dependencies.jar
>
> When we start our tomcat we get a ClassNotFoundException for the
> org.apache.camel.component.jms.JmsComponent. And now I'm unsure how to
> deploy the whole thing 'the right way'.
> When we put activemq with camel-core into our webapp we have classloader
> leaks and cannot undeploy our application.
> When we put camel-jms into the lib/ext folder of tomcat we are forced to
> place the whole spring and dependencies there also. That seems wrong to
> me also.
>
> Can anyone give me a hint about the deployment?
> Thanks
> Markus Wolf
> - --
> NMMN - New Media Markets & Networks GmbH
> Geschäftsführung: Kfm. Michael Schütt
> Finanzamt HH-Altona UStID DE 812 699 852  HRB 71102 Hamburg
> HypoVereinsbank  -   BLZ 200 300 00  -  Konto-Nr. 156 29 82
>
> http://www.nmmn.com               Tel.: +49 40 284 118 -0
> Langbehnstrasse 6                 Entwicklung:         -720
> 22761 Hamburg                     Fax:                 -999
>
> Rufen Sie uns kostenlos an: http://www.nmmn.com/call/software
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.9 (GNU/Linux)
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
>
> iEYEARECAAYFAkmj91gACgkQDBHISU1oEKFSYACfUsgx01wj1UcLbQr2trc8m/Gv
> gVUAn22zloCis2pjVjSlLPz6fBLyqghs
> =7swM
> -----END PGP SIGNATURE-----
>



-- 
James
-------
http://macstrac.blogspot.com/

Open Source Integration
http://fusesource.com/

Re: Camel + ActiveMQ in Tomcat6

Posted by Markus Wolf <ma...@nmmn.com>.
I've updated our application to ActiveMQ 5.2 which is a bit better as
willem.jiang@gmail.com sugested in another mail.
With this version we could separate activemq-core and camel-core to the
common classloader and all other camel dependencies could reside in the
webapp classloader.

But there is still a memory leak IMHO.
I attached another screenshot where one can see that the context
classloader used for timer and threadpool creation is wrong.
I think the context classloader for this should be the common
classloader in our case and the webapp classloader if the jars reside in
the webapp.

Currently the webapp classloader could not be garbage collected, because
the inactivity timer is not properly shutdown.
I don't know how to do so when the connection factory is configured
through tomcat jndi.

>>> What does the path to the GC root look like for the classloader object
>>> that couldn't be unloaded in Eclipse MAT?
>> it may need a little to recreate the setup we had when I discovered the
>> leak but I will do so.
>> I will attach a jmap created memory dump then and describe the leak as
>> good as I can.
>>
> I've created a dump now. It was created the following way:
> 1) Start a plain tomcat without any webapp
> 2) Deploy our application (which creates an ActiveMQConnectionFactory)
> 3) Undeploy our application
> 4) Create the dump with jmap: jmap -dump:format=b,file=heap.bin <processid>
> 
> The gc-roots show a reference from the webapp classloader to an
> anonymous class created by the InactivyMonitor.
> I've attached a screenshot of this, because the dump is too big to send
> in a mail. I will upload it to a server where you can download and
> inspect it if you need. Send me a link if I should do so.
> 
> I've also opened a JIRA at ActiveMQ for this:
> https://issues.apache.org/activemq/browse/AMQ-2138
> 
> Regards,
> Markus
> 
>>
>>> Markus Wolf wrote:
>>>>>>> we tried this but it throws this Exception during creation of the
>>>>>>> ActiveMQConnectionFactory:
>>>>>>>       
>>>>>> Tried what exactly? Running the camel-activemq-web war works fine for
>>>>>> me.
>>>>>>
>>>>>>     
>>> I've tried to put only the activemq libraries into my tomcat common
>>> classpath and all camel dependencies including camel-core into my
>>> webapp. That caused the exeception I mentioned.
>>
>>>>>>> Caused by: java.lang.NoClassDefFoundError:
>>>>>>> org/apache/activemq/management/JMSStatsImpl
>>>>>>>       
>>>>>> Looks like missing dependencies. Are you using maven to resolve the
>>>>>> dependencies?
>>>>>>
>>>>>>     
>>> That file resides in the activemq-core.jar. I've checked that. And that
>>> file is inside the tomcat common classpath. Maybe I missconfigured
>>> something here... :/
>>
>>>>>> [snip]
>>>>>>
>>>>>>    
>>>>>>> I guess there is currently no way to use ActiveMQ in an embedded way
>>>>>>> which does not have classloader leaks.
>>>>>>>       
>>>>>> I don't see any evidence of a class loader leak?
>>>>>>
>>>>>>     
>>> Ok, let me explain it a bit more in detail.
>>> The ActiveMQConnectionFactory and the TcpTransport (some other classes
>>> also) create ThreadPools (to be excact ScheduledThreadPools from Java
>>> Concurrent). That thread pools are configured with custom
>>> ThreadFactories to set the created Threads to daemon behaviour.
>>> When we undeploy our application then the ThreadPool classes keep a
>>> reference to the ThreadFactories. This factories are loaded by tomcats
>>> webapp classloader whereas the ThreadPool classes are loaded by the
>>> bootstrap classloader of the JDK.
>>> Therefore the webapp classloader could not be unloaded.
>>> I'm not a classloader expert but I check this with the eclipse memory
>>> analyzer tool (http://www.eclipse.org/mat), because I wanted to see
>>> which part of our application keeps the PermGen.
>>> Markus
> 
> 
> ------------------------------------------------------------------------
> 


-- 
NMMN - New Media Markets & Networks GmbH
Geschäftsführung: Kfm. Michael Schütt
Finanzamt HH-Altona UStID DE 812 699 852  HRB 71102 Hamburg
HypoVereinsbank  -   BLZ 200 300 00  -  Konto-Nr. 156 29 82

http://www.nmmn.com               Tel.: +49 40 284 118 -0
Langbehnstrasse 6                 Entwicklung:         -720
22761 Hamburg                     Fax:                 -999

Rufen Sie uns kostenlos an: http://www.nmmn.com/call/software

Re: Camel + ActiveMQ in Tomcat6

Posted by Markus Wolf <ma...@nmmn.com>.
>> What does the path to the GC root look like for the classloader object
>> that couldn't be unloaded in Eclipse MAT?
> 
> it may need a little to recreate the setup we had when I discovered the
> leak but I will do so.
> I will attach a jmap created memory dump then and describe the leak as
> good as I can.
> 
I've created a dump now. It was created the following way:
1) Start a plain tomcat without any webapp
2) Deploy our application (which creates an ActiveMQConnectionFactory)
3) Undeploy our application
4) Create the dump with jmap: jmap -dump:format=b,file=heap.bin <processid>

The gc-roots show a reference from the webapp classloader to an
anonymous class created by the InactivyMonitor.
I've attached a screenshot of this, because the dump is too big to send
in a mail. I will upload it to a server where you can download and
inspect it if you need. Send me a link if I should do so.

I've also opened a JIRA at ActiveMQ for this:
https://issues.apache.org/activemq/browse/AMQ-2138

Regards,
Markus

> 
> 
>> Markus Wolf wrote:
> 
>>>>>> we tried this but it throws this Exception during creation of the
>>>>>> ActiveMQConnectionFactory:
>>>>>>       
>>>>> Tried what exactly? Running the camel-activemq-web war works fine for
>>>>> me.
>>>>>
>>>>>     
>> I've tried to put only the activemq libraries into my tomcat common
>> classpath and all camel dependencies including camel-core into my
>> webapp. That caused the exeception I mentioned.
> 
> 
>>>>>> Caused by: java.lang.NoClassDefFoundError:
>>>>>> org/apache/activemq/management/JMSStatsImpl
>>>>>>       
>>>>> Looks like missing dependencies. Are you using maven to resolve the
>>>>> dependencies?
>>>>>
>>>>>     
>> That file resides in the activemq-core.jar. I've checked that. And that
>> file is inside the tomcat common classpath. Maybe I missconfigured
>> something here... :/
> 
> 
>>>>> [snip]
>>>>>
>>>>>    
>>>>>> I guess there is currently no way to use ActiveMQ in an embedded way
>>>>>> which does not have classloader leaks.
>>>>>>       
>>>>> I don't see any evidence of a class loader leak?
>>>>>
>>>>>     
>> Ok, let me explain it a bit more in detail.
>> The ActiveMQConnectionFactory and the TcpTransport (some other classes
>> also) create ThreadPools (to be excact ScheduledThreadPools from Java
>> Concurrent). That thread pools are configured with custom
>> ThreadFactories to set the created Threads to daemon behaviour.
>> When we undeploy our application then the ThreadPool classes keep a
>> reference to the ThreadFactories. This factories are loaded by tomcats
>> webapp classloader whereas the ThreadPool classes are loaded by the
>> bootstrap classloader of the JDK.
>> Therefore the webapp classloader could not be unloaded.
> 
>> I'm not a classloader expert but I check this with the eclipse memory
>> analyzer tool (http://www.eclipse.org/mat), because I wanted to see
>> which part of our application keeps the PermGen.
> 
>> Markus
> 

-- 
NMMN - New Media Markets & Networks GmbH
Geschäftsführung: Kfm. Michael Schütt
Finanzamt HH-Altona UStID DE 812 699 852  HRB 71102 Hamburg
HypoVereinsbank  -   BLZ 200 300 00  -  Konto-Nr. 156 29 82

http://www.nmmn.com               Tel.: +49 40 284 118 -0
Langbehnstrasse 6                 Entwicklung:         -720
22761 Hamburg                     Fax:                 -999

Rufen Sie uns kostenlos an: http://www.nmmn.com/call/software

Re: Camel + ActiveMQ in Tomcat6

Posted by Markus Wolf <ma...@nmmn.com>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi Gert,

> What does the path to the GC root look like for the classloader object
> that couldn't be unloaded in Eclipse MAT?
> 
it may need a little to recreate the setup we had when I discovered the
leak but I will do so.
I will attach a jmap created memory dump then and describe the leak as
good as I can.

Markus

> Regards,
> 
> Gert
> 
> 
> Markus Wolf wrote:
>  
>>>>> we tried this but it throws this Exception during creation of the
>>>>> ActiveMQConnectionFactory:
>>>>>       
>>>> Tried what exactly? Running the camel-activemq-web war works fine for
>>>> me.
>>>>
>>>>     
> I've tried to put only the activemq libraries into my tomcat common
> classpath and all camel dependencies including camel-core into my
> webapp. That caused the exeception I mentioned.
> 
>  
>>>>> Caused by: java.lang.NoClassDefFoundError:
>>>>> org/apache/activemq/management/JMSStatsImpl
>>>>>       
>>>> Looks like missing dependencies. Are you using maven to resolve the
>>>> dependencies?
>>>>
>>>>     
> That file resides in the activemq-core.jar. I've checked that. And that
> file is inside the tomcat common classpath. Maybe I missconfigured
> something here... :/
> 
>  
>>>> [snip]
>>>>
>>>>    
>>>>> I guess there is currently no way to use ActiveMQ in an embedded way
>>>>> which does not have classloader leaks.
>>>>>       
>>>> I don't see any evidence of a class loader leak?
>>>>
>>>>     
> Ok, let me explain it a bit more in detail.
> The ActiveMQConnectionFactory and the TcpTransport (some other classes
> also) create ThreadPools (to be excact ScheduledThreadPools from Java
> Concurrent). That thread pools are configured with custom
> ThreadFactories to set the created Threads to daemon behaviour.
> When we undeploy our application then the ThreadPool classes keep a
> reference to the ThreadFactories. This factories are loaded by tomcats
> webapp classloader whereas the ThreadPool classes are loaded by the
> bootstrap classloader of the JDK.
> Therefore the webapp classloader could not be unloaded.
> 
> I'm not a classloader expert but I check this with the eclipse memory
> analyzer tool (http://www.eclipse.org/mat), because I wanted to see
> which part of our application keeps the PermGen.
> 
> Markus
>>

- --
NMMN - New Media Markets & Networks GmbH
Geschäftsführung: Kfm. Michael Schütt
Finanzamt HH-Altona UStID DE 812 699 852  HRB 71102 Hamburg
HypoVereinsbank  -   BLZ 200 300 00  -  Konto-Nr. 156 29 82

http://www.nmmn.com               Tel.: +49 40 284 118 -0
Langbehnstrasse 6                 Entwicklung:         -720
22761 Hamburg                     Fax:                 -999

Rufen Sie uns kostenlos an: http://www.nmmn.com/call/software
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkmkBaoACgkQDBHISU1oEKG92wCguOJ5ENbBC2s3MkSKc+hQ3KNM
W8EAoMDE25NUzdca9AbLjKAMqqsnvcY/
=9NAI
-----END PGP SIGNATURE-----

Re: Camel + ActiveMQ in Tomcat6

Posted by Gert Vanthienen <ge...@skynet.be>.
Markus,

What does the path to the GC root look like for the classloader object 
that couldn't be unloaded in Eclipse MAT?

Regards,

Gert


Markus Wolf wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
>   
>>> we tried this but it throws this Exception during creation of the
>>> ActiveMQConnectionFactory:
>>>       
>> Tried what exactly? Running the camel-activemq-web war works fine for me.
>>
>>     
> I've tried to put only the activemq libraries into my tomcat common
> classpath and all camel dependencies including camel-core into my
> webapp. That caused the exeception I mentioned.
>
>   
>>> Caused by: java.lang.NoClassDefFoundError:
>>> org/apache/activemq/management/JMSStatsImpl
>>>       
>> Looks like missing dependencies. Are you using maven to resolve the
>> dependencies?
>>
>>     
> That file resides in the activemq-core.jar. I've checked that. And that
> file is inside the tomcat common classpath. Maybe I missconfigured
> something here... :/
>
>   
>> [snip]
>>
>>     
>>> I guess there is currently no way to use ActiveMQ in an embedded way
>>> which does not have classloader leaks.
>>>       
>> I don't see any evidence of a class loader leak?
>>
>>     
> Ok, let me explain it a bit more in detail.
> The ActiveMQConnectionFactory and the TcpTransport (some other classes
> also) create ThreadPools (to be excact ScheduledThreadPools from Java
> Concurrent). That thread pools are configured with custom
> ThreadFactories to set the created Threads to daemon behaviour.
> When we undeploy our application then the ThreadPool classes keep a
> reference to the ThreadFactories. This factories are loaded by tomcats
> webapp classloader whereas the ThreadPool classes are loaded by the
> bootstrap classloader of the JDK.
> Therefore the webapp classloader could not be unloaded.
>
> I'm not a classloader expert but I check this with the eclipse memory
> analyzer tool (http://www.eclipse.org/mat), because I wanted to see
> which part of our application keeps the PermGen.
>
> Markus
> - --
> NMMN - New Media Markets & Networks GmbH
> Geschäftsführung: Kfm. Michael Schütt
> Finanzamt HH-Altona UStID DE 812 699 852  HRB 71102 Hamburg
> HypoVereinsbank  -   BLZ 200 300 00  -  Konto-Nr. 156 29 82
>
> http://www.nmmn.com               Tel.: +49 40 284 118 -0
> Langbehnstrasse 6                 Entwicklung:         -720
> 22761 Hamburg                     Fax:                 -999
>
> Rufen Sie uns kostenlos an: http://www.nmmn.com/call/software
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.9 (GNU/Linux)
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
>
> iEYEARECAAYFAkmkAksACgkQDBHISU1oEKHELACfcKfNvdgRQ4WguvQmX1V9DZJE
> IjAAoJpO6qGDd43epV9UsnZ30z7V7AaK
> =a7vE
> -----END PGP SIGNATURE-----
>
>   


Re: Camel + ActiveMQ in Tomcat6

Posted by Markus Wolf <ma...@nmmn.com>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

>> we tried this but it throws this Exception during creation of the
>> ActiveMQConnectionFactory:
> 
> Tried what exactly? Running the camel-activemq-web war works fine for me.
> 
I've tried to put only the activemq libraries into my tomcat common
classpath and all camel dependencies including camel-core into my
webapp. That caused the exeception I mentioned.

>> Caused by: java.lang.NoClassDefFoundError:
>> org/apache/activemq/management/JMSStatsImpl
> 
> Looks like missing dependencies. Are you using maven to resolve the
> dependencies?
> 
That file resides in the activemq-core.jar. I've checked that. And that
file is inside the tomcat common classpath. Maybe I missconfigured
something here... :/

> 
> [snip]
> 
>> I guess there is currently no way to use ActiveMQ in an embedded way
>> which does not have classloader leaks.
> 
> I don't see any evidence of a class loader leak?
> 
Ok, let me explain it a bit more in detail.
The ActiveMQConnectionFactory and the TcpTransport (some other classes
also) create ThreadPools (to be excact ScheduledThreadPools from Java
Concurrent). That thread pools are configured with custom
ThreadFactories to set the created Threads to daemon behaviour.
When we undeploy our application then the ThreadPool classes keep a
reference to the ThreadFactories. This factories are loaded by tomcats
webapp classloader whereas the ThreadPool classes are loaded by the
bootstrap classloader of the JDK.
Therefore the webapp classloader could not be unloaded.

I'm not a classloader expert but I check this with the eclipse memory
analyzer tool (http://www.eclipse.org/mat), because I wanted to see
which part of our application keeps the PermGen.

Markus
- --
NMMN - New Media Markets & Networks GmbH
Geschäftsführung: Kfm. Michael Schütt
Finanzamt HH-Altona UStID DE 812 699 852  HRB 71102 Hamburg
HypoVereinsbank  -   BLZ 200 300 00  -  Konto-Nr. 156 29 82

http://www.nmmn.com               Tel.: +49 40 284 118 -0
Langbehnstrasse 6                 Entwicklung:         -720
22761 Hamburg                     Fax:                 -999

Rufen Sie uns kostenlos an: http://www.nmmn.com/call/software
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkmkAksACgkQDBHISU1oEKHELACfcKfNvdgRQ4WguvQmX1V9DZJE
IjAAoJpO6qGDd43epV9UsnZ30z7V7AaK
=a7vE
-----END PGP SIGNATURE-----

Re: Camel + ActiveMQ in Tomcat6

Posted by James Strachan <ja...@gmail.com>.
2009/2/24 Markus Wolf <ma...@nmmn.com>:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Hi Claus,
>
> we tried this but it throws this Exception during creation of the
> ActiveMQConnectionFactory:

Tried what exactly? Running the camel-activemq-web war works fine for me.

>
> Caused by: java.lang.NoClassDefFoundError:
> org/apache/activemq/management/JMSStatsImpl

Looks like missing dependencies. Are you using maven to resolve the
dependencies?


[snip]

> I guess there is currently no way to use ActiveMQ in an embedded way
> which does not have classloader leaks.

I don't see any evidence of a class loader leak?

-- 
James
-------
http://macstrac.blogspot.com/

Open Source Integration
http://fusesource.com/

Re: Camel + ActiveMQ in Tomcat6

Posted by Markus Wolf <ma...@nmmn.com>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi Claus,

we tried this but it throws this Exception during creation of the
ActiveMQConnectionFactory:

Caused by: java.lang.NoClassDefFoundError:
org/apache/activemq/management/JMSStatsImpl
	at
org.apache.activemq.ActiveMQConnectionFactory.<init>(ActiveMQConnectionFactory.java:83)
	at
org.apache.activemq.ActiveMQConnectionFactory.<init>(ActiveMQConnectionFactory.java:123)
	at
org.apache.activemq.ActiveMQConnectionFactory.<init>(ActiveMQConnectionFactory.java:119)
	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
	at
sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
	at
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
	at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
	at java.lang.Class.newInstance0(Class.java:355)
	at java.lang.Class.newInstance(Class.java:308)
	at
org.apache.activemq.jndi.JNDIReferenceFactory.getObjectInstance(JNDIReferenceFactory.java:65)
	at
org.apache.naming.factory.ResourceFactory.getObjectInstance(ResourceFactory.java:140)
	at javax.naming.spi.NamingManager.getObjectInstance(NamingManager.java:304)
	at org.apache.naming.NamingContext.lookup(NamingContext.java:793)
	at org.apache.naming.NamingContext.lookup(NamingContext.java:140)
	at org.apache.naming.NamingContext.lookup(NamingContext.java:781)
	at org.apache.naming.NamingContext.lookup(NamingContext.java:140)
	at org.apache.naming.NamingContext.lookup(NamingContext.java:781)
	at org.apache.naming.NamingContext.lookup(NamingContext.java:140)
	at org.apache.naming.NamingContext.lookup(NamingContext.java:781)
	at org.apache.naming.NamingContext.lookup(NamingContext.java:153)
	at org.apache.naming.SelectorContext.lookup(SelectorContext.java:137)
	at javax.naming.InitialContext.lookup(InitialContext.java:392)
	at
org.springframework.jndi.JndiTemplate$1.doInContext(JndiTemplate.java:155)
	at org.springframework.jndi.JndiTemplate.execute(JndiTemplate.java:88)
	at org.springframework.jndi.JndiTemplate.lookup(JndiTemplate.java:153)
	at org.springframework.jndi.JndiTemplate.lookup(JndiTemplate.java:178)
	at
org.springframework.jndi.JndiLocatorSupport.lookup(JndiLocatorSupport.java:95)
	at
org.springframework.jndi.JndiObjectLocator.lookup(JndiObjectLocator.java:105)
	at
org.springframework.jndi.JndiObjectFactoryBean.lookupWithFallback(JndiObjectFactoryBean.java:200)
	at
org.springframework.jndi.JndiObjectFactoryBean.afterPropertiesSet(JndiObjectFactoryBean.java:186)
	at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1369)
	at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1335)
	... 44 common frames omitted



I guess there is currently no way to use ActiveMQ in an embedded way
which does not have classloader leaks. It's a pitty, since we only need
the activemq dependency to create a connection factory to a remove
broker. There is no configuration of activemq involved (i guess that
would make it even harder)...


But thanks for your help. If you have any other idea I would be glad to
hear.

Markus


> Hi
> 
> Have you tried NOT having camel-core.jar in /lib/ext, but putting all
> the camel jars in the WEB-INF/lib
> 
> 
> On Tue, Feb 24, 2009 at 2:34 PM, Markus Wolf <ma...@nmmn.com> wrote:
> Hi,
> 
> I try to deploy a camel context using spring inside Tomcat6 with ActiveMQ.
> 
> We have the following setup:
>  CATALINA_HOME
>    /lib/ext/activemq.jar
>    /lib/ext/camel-core.jar
>    /webapp/ROOT/WEB-INF/lib/camel-jms.jar
>    /webapp/ROOT/WEB-INF/lib/camel-spring.jar
>    /webapp/ROOT/WEB-INF/lib/spring-and-dependencies.jar
> 
> When we start our tomcat we get a ClassNotFoundException for the
> org.apache.camel.component.jms.JmsComponent. And now I'm unsure how to
> deploy the whole thing 'the right way'.
> When we put activemq with camel-core into our webapp we have classloader
> leaks and cannot undeploy our application.
> When we put camel-jms into the lib/ext folder of tomcat we are forced to
> place the whole spring and dependencies there also. That seems wrong to
> me also.
> 
> Can anyone give me a hint about the deployment?
> Thanks
> Markus Wolf
>>

- --
NMMN - New Media Markets & Networks GmbH
Geschäftsführung: Kfm. Michael Schütt
Finanzamt HH-Altona UStID DE 812 699 852  HRB 71102 Hamburg
HypoVereinsbank  -   BLZ 200 300 00  -  Konto-Nr. 156 29 82

http://www.nmmn.com               Tel.: +49 40 284 118 -0
Langbehnstrasse 6                 Entwicklung:         -720
22761 Hamburg                     Fax:                 -999

Rufen Sie uns kostenlos an: http://www.nmmn.com/call/software
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkmj/5MACgkQDBHISU1oEKGMEACdEazF6KXY53jS///qKcj8jw2f
K5YAn2PhmQY19P8BaXkdzHJhLu+q4mo5
=FNUe
-----END PGP SIGNATURE-----

Re: Camel + ActiveMQ in Tomcat6

Posted by Claus Ibsen <cl...@gmail.com>.
Hi

Have you tried NOT having camel-core.jar in /lib/ext, but putting all
the camel jars in the WEB-INF/lib


On Tue, Feb 24, 2009 at 2:34 PM, Markus Wolf <ma...@nmmn.com> wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Hi,
>
> I try to deploy a camel context using spring inside Tomcat6 with ActiveMQ.
>
> We have the following setup:
>  CATALINA_HOME
>    /lib/ext/activemq.jar
>    /lib/ext/camel-core.jar
>    /webapp/ROOT/WEB-INF/lib/camel-jms.jar
>    /webapp/ROOT/WEB-INF/lib/camel-spring.jar
>    /webapp/ROOT/WEB-INF/lib/spring-and-dependencies.jar
>
> When we start our tomcat we get a ClassNotFoundException for the
> org.apache.camel.component.jms.JmsComponent. And now I'm unsure how to
> deploy the whole thing 'the right way'.
> When we put activemq with camel-core into our webapp we have classloader
> leaks and cannot undeploy our application.
> When we put camel-jms into the lib/ext folder of tomcat we are forced to
> place the whole spring and dependencies there also. That seems wrong to
> me also.
>
> Can anyone give me a hint about the deployment?
> Thanks
> Markus Wolf
> - --
> NMMN - New Media Markets & Networks GmbH
> Geschäftsführung: Kfm. Michael Schütt
> Finanzamt HH-Altona UStID DE 812 699 852  HRB 71102 Hamburg
> HypoVereinsbank  -   BLZ 200 300 00  -  Konto-Nr. 156 29 82
>
> http://www.nmmn.com               Tel.: +49 40 284 118 -0
> Langbehnstrasse 6                 Entwicklung:         -720
> 22761 Hamburg                     Fax:                 -999
>
> Rufen Sie uns kostenlos an: http://www.nmmn.com/call/software
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.9 (GNU/Linux)
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
>
> iEYEARECAAYFAkmj91gACgkQDBHISU1oEKFSYACfUsgx01wj1UcLbQr2trc8m/Gv
> gVUAn22zloCis2pjVjSlLPz6fBLyqghs
> =7swM
> -----END PGP SIGNATURE-----
>



-- 
Claus Ibsen
Apache Camel Committer

Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/

Re: Camel + ActiveMQ in Tomcat6

Posted by Markus Wolf <ma...@nmmn.com>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi Willem,

> Which version of activemq are you using ?
> We take out the activemq component from activemq-core in Activemq 5.2.
> 
we are currently using ActiveMQ 5.1.0.
Maybe we should consider an upgrade if the camel component is better
separated in the 5.2 version.

We will try that. :-)

Markus
- --
NMMN - New Media Markets & Networks GmbH
Geschäftsführung: Kfm. Michael Schütt
Finanzamt HH-Altona UStID DE 812 699 852  HRB 71102 Hamburg
HypoVereinsbank  -   BLZ 200 300 00  -  Konto-Nr. 156 29 82

http://www.nmmn.com               Tel.: +49 40 284 118 -0
Langbehnstrasse 6                 Entwicklung:         -720
22761 Hamburg                     Fax:                 -999

Rufen Sie uns kostenlos an: http://www.nmmn.com/call/software
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkmkBMoACgkQDBHISU1oEKEsHACfcNzsWsaSMGtIY1wBE7AIW/OJ
xcAAoMfOuUj8v7QgikrjgZg4PCOAIzyK
=gO+8
-----END PGP SIGNATURE-----

Re: Camel + ActiveMQ in Tomcat6

Posted by Willem Jiang <wi...@gmail.com>.
Which version of activemq are you using ?

We take out the activemq component from activemq-core in Activemq 5.2.

I suggest you to use that verion so you could have this kind of setup:

 CATALINA_HOME
   /lib/ext/activemq-core.jar
   /lib/ext/camel-core.jar
   /webapp/ROOT/WEB-INF/lib/activemq-camel.jar
   /webapp/ROOT/WEB-INF/lib/camel-jms.jar
   /webapp/ROOT/WEB-INF/lib/camel-spring.jar
   /webapp/ROOT/WEB-INF/lib/spring-and-dependencies.jar

Willem

On Tue, Feb 24, 2009 at 9:34 PM, Markus Wolf <ma...@nmmn.com> wrote:

> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Hi,
>
> I try to deploy a camel context using spring inside Tomcat6 with ActiveMQ.
>
> We have the following setup:
>  CATALINA_HOME
>    /lib/ext/activemq.jar
>    /lib/ext/camel-core.jar
>    /webapp/ROOT/WEB-INF/lib/camel-jms.jar
>    /webapp/ROOT/WEB-INF/lib/camel-spring.jar
>    /webapp/ROOT/WEB-INF/lib/spring-and-dependencies.jar
>
> When we start our tomcat we get a ClassNotFoundException for the
> org.apache.camel.component.jms.JmsComponent. And now I'm unsure how to
> deploy the whole thing 'the right way'.
> When we put activemq with camel-core into our webapp we have classloader
> leaks and cannot undeploy our application.
> When we put camel-jms into the lib/ext folder of tomcat we are forced to
> place the whole spring and dependencies there also. That seems wrong to
> me also.
>
> Can anyone give me a hint about the deployment?
> Thanks
> Markus Wolf
> - --
> NMMN - New Media Markets & Networks GmbH
> Geschäftsführung: Kfm. Michael Schütt
> Finanzamt HH-Altona UStID DE 812 699 852  HRB 71102 Hamburg
> HypoVereinsbank  -   BLZ 200 300 00  -  Konto-Nr. 156 29 82
>
> http://www.nmmn.com               Tel.: +49 40 284 118 -0
> Langbehnstrasse 6                 Entwicklung:         -720
> 22761 Hamburg                     Fax:                 -999
>
> Rufen Sie uns kostenlos an: http://www.nmmn.com/call/software
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.9 (GNU/Linux)
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
>
> iEYEARECAAYFAkmj91gACgkQDBHISU1oEKFSYACfUsgx01wj1UcLbQr2trc8m/Gv
> gVUAn22zloCis2pjVjSlLPz6fBLyqghs
> =7swM
> -----END PGP SIGNATURE-----
>