Re: Camel + ActiveMQ in Tomcat6

2009-02-24 Thread Claus Ibsen
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 markus.w...@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

2009-02-24 Thread James Strachan
2009/2/24 Markus Wolf markus.w...@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

2009-02-24 Thread Markus Wolf
-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 markus.w...@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

Re: Camel + ActiveMQ in Tomcat6

2009-02-24 Thread Markus Wolf
-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

2009-02-24 Thread Markus Wolf
-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

2009-02-24 Thread Gert Vanthienen

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

2009-02-24 Thread Markus Wolf
-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

2009-02-24 Thread Markus Wolf
-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-