You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by tolina <di...@tolina.de> on 2008/02/19 22:58:12 UTC

2 Webapps sharing classloader ?

I have a webapp which contains a class which methods should also exposed as
webservice.
What I would do would be to create an axis2 webservice out of it and put
this inside an axis2.war.

I then would have 2 webapps - the actual webapp and the axis2-webapp whcih
contains the WS-access.
The problem is that each Webapp gets loaded by its own classloader, so I
would have 2 instances of my class.

How can I tell tomcat to use the same classloader for both webapps ?

Can I put a single *.class inside of catalina.properties?  E.g. 
  shared.loader=my.special.Clazz.class

(I cannot reference the *.jar because its inside the wepapp and inside an
axis2 archive an *.aar)

-- 
View this message in context: http://www.nabble.com/2-Webapps-sharing-classloader---tp15571888p15571888.html
Sent from the Tomcat - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: 2 Webapps sharing classloader ?

Posted by Johnny Kewl <jo...@kewlstuff.co.za>.
---------------------------------------------------------------------------
HARBOR: http://coolharbor.100free.com/index.htm
The most powerful application server on earth.
The only real POJO Application Server.
Making the Java dream come true.
---------------------------------------------------------------------------
----- Original Message ----- 
From: "tolina" <ol...@yahoo.de>
To: <us...@tomcat.apache.org>
Sent: Wednesday, February 20, 2008 1:09 AM
Subject: Re: 2 Webapps sharing classloader ?



tolina I used axix a million years ago and have forgotten it...
but I think you reading the application server installation stuff... not the 
servlet stuff.

If I remember its just a war, or a few classes in your webapp, and each 
webapp does its own axis,
but when its an application server, because of class conflicts one has to do 
special stuff to make sure
the axis classes are used and not the app servers classes... something like 
that.

Just put it in each webapp and see what happens... in theory it cant break 
that way... maybe?


> As far as i know this is the way to do axis2 webservices.
> I happily would create a WS from my class and let that live inside of my
> webapp.
> I cannot think of away to do that with axis2.
>
> I actually did the classloaderthing before.. with an embedded tomcat5.5.
> I just set the rootClassloader to my own classloader programmatically.
>
> Now i have to use tomcat6 which is not embedded. I dont know where to set
> the rootclassloader in configs.
> So its still the question:
>
> How can I tell tomcat to use the same classloader for both webapps ?
> Can I put a single *.class inside of catalina.properties?  E.g.
>   shared.loader=my.special.Clazz.class
>
>
>
> David Delbecq-2 wrote:
>>
>> Is there any special reason you would need to put that in 2 separate
>> webapps? I would suggest to stuff all in one webapp and be happy with
>> it. Crossing boundaries of webapp sandbox might prove cumbersome, prone
>> to errors and over engineering....
>>
>
> -- 
> View this message in context: 
> http://www.nabble.com/2-Webapps-sharing-classloader---tp15571888p15578421.html
> Sent from the Tomcat - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
> 


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: 2 Webapps sharing classloader ?

Posted by tolina <ol...@yahoo.de>.
As far as i know this is the way to do axis2 webservices.
I happily would create a WS from my class and let that live inside of my
webapp. 
I cannot think of away to do that with axis2.

I actually did the classloaderthing before.. with an embedded tomcat5.5. 
I just set the rootClassloader to my own classloader programmatically.

Now i have to use tomcat6 which is not embedded. I dont know where to set
the rootclassloader in configs.
So its still the question:

How can I tell tomcat to use the same classloader for both webapps ?
Can I put a single *.class inside of catalina.properties?  E.g.
   shared.loader=my.special.Clazz.class 



David Delbecq-2 wrote:
> 
> Is there any special reason you would need to put that in 2 separate 
> webapps? I would suggest to stuff all in one webapp and be happy with 
> it. Crossing boundaries of webapp sandbox might prove cumbersome, prone 
> to errors and over engineering....
> 

-- 
View this message in context: http://www.nabble.com/2-Webapps-sharing-classloader---tp15571888p15578421.html
Sent from the Tomcat - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: 2 Webapps sharing classloader ?

Posted by david delbecq <de...@oma.be>.
Is there any special reason you would need to put that in 2 separate 
webapps? I would suggest to stuff all in one webapp and be happy with 
it. Crossing boundaries of webapp sandbox might prove cumbersome, prone 
to errors and over engineering....
tolina a écrit :
> I have a webapp which contains a class which methods should also exposed as
> webservice.
> What I would do would be to create an axis2 webservice out of it and put
> this inside an axis2.war.
>
> I then would have 2 webapps - the actual webapp and the axis2-webapp whcih
> contains the WS-access.
> The problem is that each Webapp gets loaded by its own classloader, so I
> would have 2 instances of my class.
>
> How can I tell tomcat to use the same classloader for both webapps ?
>
> Can I put a single *.class inside of catalina.properties?  E.g. 
>   shared.loader=my.special.Clazz.class
>
> (I cannot reference the *.jar because its inside the wepapp and inside an
> axis2 archive an *.aar)
>
>   


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: 2 Webapps sharing classloader ?

Posted by Johnny Kewl <jo...@kewlstuff.co.za>.
---------------------------------------------------------------------------
HARBOR: http://coolharbor.100free.com/index.htm
The most powerful application server on earth.
The only real POJO Application Server.
Making the Java dream come true.
---------------------------------------------------------------------------
----- Original Message ----- 
From: "tolina" <di...@tolina.de>
To: <us...@tomcat.apache.org>
Sent: Tuesday, February 19, 2008 11:58 PM
Subject: 2 Webapps sharing classloader ?


Hi tolina, sorry I didnt understand your question... ignore my previous 
comment
I think you either have to combine it, and even then there are multiple 
class loaders ie this stuff applies
http://ws.apache.org/axis2/faq.html#b1
I had a quick look and I dont even recognize axis since that very first 
release... a second opinion would be good ;)
I think it must be possible to combine servlet and Axis...

If that Jar is not holding info, ie its just because you dont want 2 jars... 
all this is not worth the effort, just let each have its own jar.

Alternatively I guess one could get the WebApp to call the web service 
jar... thru a webservice clnt

I would go for combining first... daves suggestion..
This page here shows the binary and war... I think you should be able to set 
that war up in your IDE (from the binary stuff), or just unzip the war.
Or find the source...
And then ad the web app stuff to it... but even then, there are 2 
classloaders involved and you have to do that forname stuff above, and then
even then... it will have to be thread safe and all that stuff...

Have fun...

> I have a webapp which contains a class which methods should also exposed 
> as
> webservice.
> What I would do would be to create an axis2 webservice out of it and put
> this inside an axis2.war.
>
> I then would have 2 webapps - the actual webapp and the axis2-webapp whcih
> contains the WS-access.
> The problem is that each Webapp gets loaded by its own classloader, so I
> would have 2 instances of my class.
>
> How can I tell tomcat to use the same classloader for both webapps ?
>
> Can I put a single *.class inside of catalina.properties?  E.g.
>  shared.loader=my.special.Clazz.class
>
> (I cannot reference the *.jar because its inside the wepapp and inside an
> axis2 archive an *.aar)
>
> -- 
> View this message in context: 
> http://www.nabble.com/2-Webapps-sharing-classloader---tp15571888p15571888.html
> Sent from the Tomcat - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
> 


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org