You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@axis.apache.org by Periklis Tsirakidis <pe...@mayflower.de> on 2007/08/16 15:22:21 UTC

Axis 1.3: Classloading Issue with WEB-INF/lib jars in aar

Hi,

i am currently working on a service, that is deployed in a service
archive, as described in the documentation. This service needs access on
a library which is located under WEB-INF/lib, due to further usage of
this library out of my service.

I am using axis 1.3 deployed as a war on a Tomcat 5.5.12.

The jar structure of mylib.jar is:
mylib.jar
-- META-INF
---- MANIFEST.MF
-- lib
--- ...couple of libs here
-- com
---- ...classes in package hierarchy

My service archive myservice.aar is located in the WEB-INF/services and
i have hotupdate in my axis2.xml configuration enabled.

The code i am trying to access classes from the jar file in my service
implementation class is following:

> MessageContext msgCtx = MessageContext.getCurrentMessageContext();
> 			
> AxisService serviceHandler = msgCtx.getAxisService();
> 			
> ClassLoader serviceLoader = serviceHandler.getClassLoader();
> 			
> //Class serviceClass = serviceLoader.loadClass(service);
> 		
> Class serviceClass = Class.forName(service, true, serviceLoader);
> 			
> MyClass srv = (MyClass) serviceClass.newInstance();

The deployment of the service is working fine, but when i call some
function of my service implementation class that itselfs needs an
instance of the mylib.jar i get a ClassNotFoundException.

I have tried also the setOperationContext way, but as i read in the
mailing list, this way is not thread safe.

Has anybody an idea?

Thanks in advance.

Periklis

---------------------------------------------------------------------
To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-user-help@ws.apache.org


Re: Axis 1.3: Classloading Issue with WEB-INF/lib jars in aar

Posted by Periklis Tsirakidis <pe...@mayflower.de>.
Hi Ants,

thank you for your help, but our classloading problems don't think to be so 
similar, because the classes i am trying to load are for sure not in 
WEB-INF/lib. This classes are part of an third party sofware.

This Third-Party software is using their own old version of xerces and cocoon, 
so i am loading them into the aar, so that the Axis2-Xerces is not getting 
mixed with the old one of the Third-Party libraries.

The mysterious thing now is that i put all the third party jars in my 
service's lib directory (without nested jars) and every workaround of loading 
one of the classes of this jar through one of the possible Classloader isn't 
working. But instantiation of this classes directly in my Service 
implementation class is possible, just not classloading.

As far as my small know-how about Axis2 goes, the service has his own 
classloader and in the deployment phase it loads with this exactly 
classloader the service's libraries under the service's lib directory.

*frustating*

Periklis


On Sunday 19 August 2007, Anthony Bull wrote:
> Hi Periklis,
>
> I had a lot of similar classpath issues with Axis 2 1.2 recently and
> managed to sort them out.  I tried all the tricks like exploding the
> .aar file, but in the end none of it was necessary.
>
> My .aar file is the same structure as yours - and I'm using the
> following to load my log4j.properties using the service classloader:
>
> ServiceSkeleton.class.getClassLoader().getResourceAsStream(
> "log4j.properties");
>
> This picks up the class file from the root of my .aar file, fine.
>
> The main thing that was causing me problems was that some of the classes
> I was trying to load (e.g. Log4j.jar in particular) were also in jars or
> the classes area of the main axis2/WEB-INF area as well as being in the
> .aar files.  Axis 2 was picking them up before looking in my .aar files
> and then loading them with a different classloader - hence my service
> wouldn't load them, but it would still get Class Def Not Found errors.
> Simply clearing these jars out of the axis2/WEB-INF/lib folder fixed
> this all up for me.
>
> cheers,
> Ants.
>
> Periklis Tsirakidis wrote:
> > I noticed that my topic is referring to Axis 1.3, but i meant Axis2 1.3.
> >
> > Periklis
> >
> > Periklis Tsirakidis wrote:
> >> Hi again,
> >>
> >> after couple of different packaging experiments and still not working
> >> solution, i stepped in a weird situation.
> >>
> >> My Service now has the following structure:
> >>
> >> myservice.aar
> >> -- META-INF
> >> ---- service.xml
> >> -- lib
> >> ---- lib1.jar
> >> ---- lib2.jar
> >> ---- lib3.jar
> >> ---- lib4.jar
> >> -- com
> >> ---- ....my classes here incl. the service impl class
> >>
> >> The weird situation now is, that if try to load a class included in com
> >> inside my service implementation class, with following code, i get still
> >> a ClassNotFoundException.
> >>
> >>> ClassLoader loader = getClass().getClassLoader();
> >>>
> >>> Class myclass = Class.forName('classname', true, loader);
> >>
> >> or even with
> >>
> >>> MessageContext msgCtx = MessageContext.getCurrentMessageContext();
> >>>
> >>> AxisService serviceHandler = msgCtx.getAxisService();
> >>>
> >>> ClassLoader serviceLoader = serviceHandler.getClassLoader();
> >>>
> >>> //Class serviceClass = serviceLoader.loadClass(service);
> >>>
> >>> Class serviceClass = Class.forName(service, true, serviceLoader);
> >>>
> >>> MyClass srv = (MyClass) serviceClass.newInstance();
> >>
> >> still ClassNotFoundException.
> >>
> >> If i import the class and instatiate it, then everything works fine.
> >>
> >> The Class i am trying to load with the Classloader doesn't use any class
> >> from the jars included in the lib directory.
> >>
> >> I tried also all the workarounds above with an unpacked aar.
> >>
> >> Anybody an idea?
> >>
> >> Periklis
> >>
> >> Periklis Tsirakidis wrote:
> >>> Hi,
> >>>
> >>> i am currently working on a service, that is deployed in a service
> >>> archive, as described in the documentation. This service needs access
> >>> on a library which is located under WEB-INF/lib, due to further usage
> >>> of this library out of my service.
> >>>
> >>> I am using axis 1.3 deployed as a war on a Tomcat 5.5.12.
> >>>
> >>> The jar structure of mylib.jar is:
> >>> mylib.jar
> >>> -- META-INF
> >>> ---- MANIFEST.MF
> >>> -- lib
> >>> --- ...couple of libs here
> >>> -- com
> >>> ---- ...classes in package hierarchy
> >>>
> >>> My service archive myservice.aar is located in the WEB-INF/services and
> >>> i have hotupdate in my axis2.xml configuration enabled.
> >>>
> >>> The code i am trying to access classes from the jar file in my service
> >>>
> >>> implementation class is following:
> >>>> MessageContext msgCtx = MessageContext.getCurrentMessageContext();
> >>>>
> >>>> AxisService serviceHandler = msgCtx.getAxisService();
> >>>>
> >>>> ClassLoader serviceLoader = serviceHandler.getClassLoader();
> >>>>
> >>>> //Class serviceClass = serviceLoader.loadClass(service);
> >>>>
> >>>> Class serviceClass = Class.forName(service, true, serviceLoader);
> >>>>
> >>>> MyClass srv = (MyClass) serviceClass.newInstance();
> >>>
> >>> The deployment of the service is working fine, but when i call some
> >>> function of my service implementation class that itselfs needs an
> >>> instance of the mylib.jar i get a ClassNotFoundException.
> >>>
> >>> I have tried also the setOperationContext way, but as i read in the
> >>> mailing list, this way is not thread safe.
> >>>
> >>> Has anybody an idea?
> >>>
> >>> Thanks in advance.
> >>>
> >>> Periklis
> >>>
> >>> ---------------------------------------------------------------------
> >>> To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
> >>> For additional commands, e-mail: axis-user-help@ws.apache.org
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
> >> For additional commands, e-mail: axis-user-help@ws.apache.org
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
> > For additional commands, e-mail: axis-user-help@ws.apache.org

---------------------------------------------------------------------
To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-user-help@ws.apache.org


Re: Axis 1.3: Classloading Issue with WEB-INF/lib jars in aar

Posted by p....@almerys.com.
Hi, 
Thanks for you annalysis Anthony.
You say that if the same library is in WEB-INF/lib and in the .aar, Axis2 
picks up the one in WEB-INF/lib.
How can I configure Axis2 so that it picks up the jar in the .aar file? I 
can't remove the jar from the WEB-INF/lib folder.
Thanks in advance,

Pierre




Anthony Bull <an...@bcsoft.co.nz> 
19/08/2007 23:10
Veuillez répondre à
axis-user@ws.apache.org


A
axis-user@ws.apache.org
cc

Objet
Re: Axis 1.3: Classloading Issue with WEB-INF/lib jars in aar






Hi Periklis,

I had a lot of similar classpath issues with Axis 2 1.2 recently and 
managed to sort them out.  I tried all the tricks like exploding the 
.aar file, but in the end none of it was necessary.

My .aar file is the same structure as yours - and I'm using the 
following to load my log4j.properties using the service classloader:

ServiceSkeleton.class.getClassLoader().getResourceAsStream( 
"log4j.properties");

This picks up the class file from the root of my .aar file, fine.

The main thing that was causing me problems was that some of the classes 
I was trying to load (e.g. Log4j.jar in particular) were also in jars or 
the classes area of the main axis2/WEB-INF area as well as being in the 
.aar files.  Axis 2 was picking them up before looking in my .aar files 
and then loading them with a different classloader - hence my service 
wouldn't load them, but it would still get Class Def Not Found errors. 
Simply clearing these jars out of the axis2/WEB-INF/lib folder fixed 
this all up for me.

cheers,
Ants.

Periklis Tsirakidis wrote:
> I noticed that my topic is referring to Axis 1.3, but i meant Axis2 1.3.
>
> Periklis
>
> Periklis Tsirakidis wrote:
> 
>> Hi again,
>>
>> after couple of different packaging experiments and still not working
>> solution, i stepped in a weird situation.
>>
>> My Service now has the following structure:
>>
>> myservice.aar
>> -- META-INF
>> ---- service.xml
>> -- lib
>> ---- lib1.jar
>> ---- lib2.jar
>> ---- lib3.jar
>> ---- lib4.jar
>> -- com
>> ---- ....my classes here incl. the service impl class
>>
>> The weird situation now is, that if try to load a class included in com
>> inside my service implementation class, with following code, i get 
still
>> a ClassNotFoundException.
>>
>> 
>>> ClassLoader loader = getClass().getClassLoader();
>>>
>>> Class myclass = Class.forName('classname', true, loader);
>>>
>>> 
>> or even with
>>
>> 
>>> MessageContext msgCtx = MessageContext.getCurrentMessageContext();
>>> 
>>> AxisService serviceHandler = msgCtx.getAxisService();
>>> 
>>> ClassLoader serviceLoader = serviceHandler.getClassLoader();
>>> 
>>> //Class serviceClass = serviceLoader.loadClass(service);
>>> 
>>> Class serviceClass = Class.forName(service, true, serviceLoader);
>>> 
>>> MyClass srv = (MyClass) serviceClass.newInstance();
>>> 
>> still ClassNotFoundException.
>>
>> If i import the class and instatiate it, then everything works fine.
>>
>> The Class i am trying to load with the Classloader doesn't use any 
class
>> from the jars included in the lib directory.
>>
>> I tried also all the workarounds above with an unpacked aar.
>>
>> Anybody an idea?
>>
>> Periklis
>>
>>
>> Periklis Tsirakidis wrote:
>> 
>>> Hi,
>>>
>>> i am currently working on a service, that is deployed in a service
>>> archive, as described in the documentation. This service needs access 
on
>>> a library which is located under WEB-INF/lib, due to further usage of
>>> this library out of my service.
>>>
>>> I am using axis 1.3 deployed as a war on a Tomcat 5.5.12.
>>>
>>> The jar structure of mylib.jar is:
>>> mylib.jar
>>> -- META-INF
>>> ---- MANIFEST.MF
>>> -- lib
>>> --- ...couple of libs here
>>> -- com
>>> ---- ...classes in package hierarchy
>>>
>>> My service archive myservice.aar is located in the WEB-INF/services 
and
>>> i have hotupdate in my axis2.xml configuration enabled.
>>>
>>> The code i am trying to access classes from the jar file in my service
>>> implementation class is following:
>>>
>>> 
>>>> MessageContext msgCtx = MessageContext.getCurrentMessageContext();
>>>> 
>>>> AxisService serviceHandler = msgCtx.getAxisService();
>>>> 
>>>> ClassLoader serviceLoader = serviceHandler.getClassLoader();
>>>> 
>>>> //Class serviceClass = serviceLoader.loadClass(service);
>>>> 
>>>> Class serviceClass = Class.forName(service, true, serviceLoader);
>>>> 
>>>> MyClass srv = (MyClass) serviceClass.newInstance();
>>>> 
>>> The deployment of the service is working fine, but when i call some
>>> function of my service implementation class that itselfs needs an
>>> instance of the mylib.jar i get a ClassNotFoundException.
>>>
>>> I have tried also the setOperationContext way, but as i read in the
>>> mailing list, this way is not thread safe.
>>>
>>> Has anybody an idea?
>>>
>>> Thanks in advance.
>>>
>>> Periklis
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
>>> For additional commands, e-mail: axis-user-help@ws.apache.org
>>>
>>> 
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
>> For additional commands, e-mail: axis-user-help@ws.apache.org
>>
>> 
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
> For additional commands, e-mail: axis-user-help@ws.apache.org
>
>
>
> 


-- 
Anthony
-------------------------------------
Anthony Bull
Senior Developer
Black Coffee Software Ltd
PO Box 10-192 The Terrace
Wellington, New Zealand

anthony.bull@bcsoft.co.nz
Ph  +64 4 472 8818
Fax +64 4 472 8811
Mobile 021 303 692
-------------------------------------
www.bcsoft.co.nz
---------------------------------------------------------------
This email may contain confidential or privileged information,
and is intended for use only by the addressee, or addressees.
If you are not the intended recipient please advise the sender
immediately and do not copy, use or disclose the contents to
any other person or organisation.
Black Coffee Software Ltd accepts no responsibility for viruses
received with this email, or to any changes made to the original
content. Any views or opinions expressed in this email may be
personal to the sender and are not necessarily those of Black
Coffee Software Ltd.
---------------------------------------------------------------



---------------------------------------------------------------------
To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-user-help@ws.apache.org



Re: Axis 1.3: Classloading Issue with WEB-INF/lib jars in aar

Posted by Anthony Bull <an...@bcsoft.co.nz>.
Hi Periklis,

I had a lot of similar classpath issues with Axis 2 1.2 recently and 
managed to sort them out.  I tried all the tricks like exploding the 
.aar file, but in the end none of it was necessary.

My .aar file is the same structure as yours - and I'm using the 
following to load my log4j.properties using the service classloader:

ServiceSkeleton.class.getClassLoader().getResourceAsStream( 
"log4j.properties");

This picks up the class file from the root of my .aar file, fine.

The main thing that was causing me problems was that some of the classes 
I was trying to load (e.g. Log4j.jar in particular) were also in jars or 
the classes area of the main axis2/WEB-INF area as well as being in the 
.aar files.  Axis 2 was picking them up before looking in my .aar files 
and then loading them with a different classloader - hence my service 
wouldn't load them, but it would still get Class Def Not Found errors.  
Simply clearing these jars out of the axis2/WEB-INF/lib folder fixed 
this all up for me.

cheers,
Ants.

Periklis Tsirakidis wrote:
> I noticed that my topic is referring to Axis 1.3, but i meant Axis2 1.3.
>
> Periklis
>
> Periklis Tsirakidis wrote:
>   
>> Hi again,
>>
>> after couple of different packaging experiments and still not working
>> solution, i stepped in a weird situation.
>>
>> My Service now has the following structure:
>>
>> myservice.aar
>> -- META-INF
>> ---- service.xml
>> -- lib
>> ---- lib1.jar
>> ---- lib2.jar
>> ---- lib3.jar
>> ---- lib4.jar
>> -- com
>> ---- ....my classes here incl. the service impl class
>>
>> The weird situation now is, that if try to load a class included in com
>> inside my service implementation class, with following code, i get still
>> a ClassNotFoundException.
>>
>>     
>>> ClassLoader loader = getClass().getClassLoader();
>>>
>>> Class myclass = Class.forName('classname', true, loader);
>>>
>>>       
>> or even with
>>
>>     
>>> MessageContext msgCtx = MessageContext.getCurrentMessageContext();
>>> 			
>>> AxisService serviceHandler = msgCtx.getAxisService();
>>> 			
>>> ClassLoader serviceLoader = serviceHandler.getClassLoader();
>>> 			
>>> //Class serviceClass = serviceLoader.loadClass(service);
>>> 		
>>> Class serviceClass = Class.forName(service, true, serviceLoader);
>>> 			
>>> MyClass srv = (MyClass) serviceClass.newInstance();
>>>       
>> still ClassNotFoundException.
>>
>> If i import the class and instatiate it, then everything works fine.
>>
>> The Class i am trying to load with the Classloader doesn't use any class
>> from the jars included in the lib directory.
>>
>> I tried also all the workarounds above with an unpacked aar.
>>
>> Anybody an idea?
>>
>> Periklis
>>
>>
>> Periklis Tsirakidis wrote:
>>     
>>> Hi,
>>>
>>> i am currently working on a service, that is deployed in a service
>>> archive, as described in the documentation. This service needs access on
>>> a library which is located under WEB-INF/lib, due to further usage of
>>> this library out of my service.
>>>
>>> I am using axis 1.3 deployed as a war on a Tomcat 5.5.12.
>>>
>>> The jar structure of mylib.jar is:
>>> mylib.jar
>>> -- META-INF
>>> ---- MANIFEST.MF
>>> -- lib
>>> --- ...couple of libs here
>>> -- com
>>> ---- ...classes in package hierarchy
>>>
>>> My service archive myservice.aar is located in the WEB-INF/services and
>>> i have hotupdate in my axis2.xml configuration enabled.
>>>
>>> The code i am trying to access classes from the jar file in my service
>>> implementation class is following:
>>>
>>>       
>>>> MessageContext msgCtx = MessageContext.getCurrentMessageContext();
>>>> 			
>>>> AxisService serviceHandler = msgCtx.getAxisService();
>>>> 			
>>>> ClassLoader serviceLoader = serviceHandler.getClassLoader();
>>>> 			
>>>> //Class serviceClass = serviceLoader.loadClass(service);
>>>> 		
>>>> Class serviceClass = Class.forName(service, true, serviceLoader);
>>>> 			
>>>> MyClass srv = (MyClass) serviceClass.newInstance();
>>>>         
>>> The deployment of the service is working fine, but when i call some
>>> function of my service implementation class that itselfs needs an
>>> instance of the mylib.jar i get a ClassNotFoundException.
>>>
>>> I have tried also the setOperationContext way, but as i read in the
>>> mailing list, this way is not thread safe.
>>>
>>> Has anybody an idea?
>>>
>>> Thanks in advance.
>>>
>>> Periklis
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
>>> For additional commands, e-mail: axis-user-help@ws.apache.org
>>>
>>>       
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
>> For additional commands, e-mail: axis-user-help@ws.apache.org
>>
>>     
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
> For additional commands, e-mail: axis-user-help@ws.apache.org
>
>
>
>   


-- 
Anthony
-------------------------------------
Anthony Bull
Senior Developer
Black Coffee Software Ltd
PO Box 10-192 The Terrace
Wellington, New Zealand

anthony.bull@bcsoft.co.nz
Ph  +64 4 472 8818
Fax +64 4 472 8811
Mobile 021 303 692
-------------------------------------
www.bcsoft.co.nz
---------------------------------------------------------------
This email may contain confidential or privileged information,
and is intended for use only by the addressee, or addressees.
If you are not the intended recipient please advise the sender
immediately and do not copy, use or disclose the contents to
any other person or organisation.
Black Coffee Software Ltd accepts no responsibility for viruses
received with this email, or to any changes made to the original
content. Any views or opinions expressed in this email may be
personal to the sender and are not necessarily those of Black
Coffee Software Ltd.
---------------------------------------------------------------



---------------------------------------------------------------------
To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-user-help@ws.apache.org


Re: Axis 1.3: Classloading Issue with WEB-INF/lib jars in aar

Posted by Periklis Tsirakidis <pe...@mayflower.de>.
I noticed that my topic is referring to Axis 1.3, but i meant Axis2 1.3.

Periklis

Periklis Tsirakidis wrote:
> Hi again,
> 
> after couple of different packaging experiments and still not working
> solution, i stepped in a weird situation.
> 
> My Service now has the following structure:
> 
> myservice.aar
> -- META-INF
> ---- service.xml
> -- lib
> ---- lib1.jar
> ---- lib2.jar
> ---- lib3.jar
> ---- lib4.jar
> -- com
> ---- ....my classes here incl. the service impl class
> 
> The weird situation now is, that if try to load a class included in com
> inside my service implementation class, with following code, i get still
> a ClassNotFoundException.
> 
>> ClassLoader loader = getClass().getClassLoader();
>>
>> Class myclass = Class.forName('classname', true, loader);
>>
> 
> or even with
> 
>> MessageContext msgCtx = MessageContext.getCurrentMessageContext();
>> 			
>> AxisService serviceHandler = msgCtx.getAxisService();
>> 			
>> ClassLoader serviceLoader = serviceHandler.getClassLoader();
>> 			
>> //Class serviceClass = serviceLoader.loadClass(service);
>> 		
>> Class serviceClass = Class.forName(service, true, serviceLoader);
>> 			
>> MyClass srv = (MyClass) serviceClass.newInstance();
> 
> still ClassNotFoundException.
> 
> If i import the class and instatiate it, then everything works fine.
> 
> The Class i am trying to load with the Classloader doesn't use any class
> from the jars included in the lib directory.
> 
> I tried also all the workarounds above with an unpacked aar.
> 
> Anybody an idea?
> 
> Periklis
> 
> 
> Periklis Tsirakidis wrote:
>> Hi,
>>
>> i am currently working on a service, that is deployed in a service
>> archive, as described in the documentation. This service needs access on
>> a library which is located under WEB-INF/lib, due to further usage of
>> this library out of my service.
>>
>> I am using axis 1.3 deployed as a war on a Tomcat 5.5.12.
>>
>> The jar structure of mylib.jar is:
>> mylib.jar
>> -- META-INF
>> ---- MANIFEST.MF
>> -- lib
>> --- ...couple of libs here
>> -- com
>> ---- ...classes in package hierarchy
>>
>> My service archive myservice.aar is located in the WEB-INF/services and
>> i have hotupdate in my axis2.xml configuration enabled.
>>
>> The code i am trying to access classes from the jar file in my service
>> implementation class is following:
>>
>>> MessageContext msgCtx = MessageContext.getCurrentMessageContext();
>>> 			
>>> AxisService serviceHandler = msgCtx.getAxisService();
>>> 			
>>> ClassLoader serviceLoader = serviceHandler.getClassLoader();
>>> 			
>>> //Class serviceClass = serviceLoader.loadClass(service);
>>> 		
>>> Class serviceClass = Class.forName(service, true, serviceLoader);
>>> 			
>>> MyClass srv = (MyClass) serviceClass.newInstance();
>> The deployment of the service is working fine, but when i call some
>> function of my service implementation class that itselfs needs an
>> instance of the mylib.jar i get a ClassNotFoundException.
>>
>> I have tried also the setOperationContext way, but as i read in the
>> mailing list, this way is not thread safe.
>>
>> Has anybody an idea?
>>
>> Thanks in advance.
>>
>> Periklis
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
>> For additional commands, e-mail: axis-user-help@ws.apache.org
>>
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
> For additional commands, e-mail: axis-user-help@ws.apache.org
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-user-help@ws.apache.org


Re: Axis 1.3: Classloading Issue with WEB-INF/lib jars in aar

Posted by Periklis Tsirakidis <pe...@mayflower.de>.
Hi again,

after couple of different packaging experiments and still not working
solution, i stepped in a weird situation.

My Service now has the following structure:

myservice.aar
-- META-INF
---- service.xml
-- lib
---- lib1.jar
---- lib2.jar
---- lib3.jar
---- lib4.jar
-- com
---- ....my classes here incl. the service impl class

The weird situation now is, that if try to load a class included in com
inside my service implementation class, with following code, i get still
a ClassNotFoundException.

>
> ClassLoader loader = getClass().getClassLoader();
>
> Class myclass = Class.forName('classname', true, loader);
>

or even with

> MessageContext msgCtx = MessageContext.getCurrentMessageContext();
> 			
> AxisService serviceHandler = msgCtx.getAxisService();
> 			
> ClassLoader serviceLoader = serviceHandler.getClassLoader();
> 			
> //Class serviceClass = serviceLoader.loadClass(service);
> 		
> Class serviceClass = Class.forName(service, true, serviceLoader);
> 			
> MyClass srv = (MyClass) serviceClass.newInstance();

still ClassNotFoundException.

If i import the class and instatiate it, then everything works fine.

The Class i am trying to load with the Classloader doesn't use any class
from the jars included in the lib directory.

I tried also all the workarounds above with an unpacked aar.

Anybody an idea?

Periklis


Periklis Tsirakidis wrote:
> Hi,
> 
> i am currently working on a service, that is deployed in a service
> archive, as described in the documentation. This service needs access on
> a library which is located under WEB-INF/lib, due to further usage of
> this library out of my service.
> 
> I am using axis 1.3 deployed as a war on a Tomcat 5.5.12.
> 
> The jar structure of mylib.jar is:
> mylib.jar
> -- META-INF
> ---- MANIFEST.MF
> -- lib
> --- ...couple of libs here
> -- com
> ---- ...classes in package hierarchy
> 
> My service archive myservice.aar is located in the WEB-INF/services and
> i have hotupdate in my axis2.xml configuration enabled.
> 
> The code i am trying to access classes from the jar file in my service
> implementation class is following:
> 
>> MessageContext msgCtx = MessageContext.getCurrentMessageContext();
>> 			
>> AxisService serviceHandler = msgCtx.getAxisService();
>> 			
>> ClassLoader serviceLoader = serviceHandler.getClassLoader();
>> 			
>> //Class serviceClass = serviceLoader.loadClass(service);
>> 		
>> Class serviceClass = Class.forName(service, true, serviceLoader);
>> 			
>> MyClass srv = (MyClass) serviceClass.newInstance();
> 
> The deployment of the service is working fine, but when i call some
> function of my service implementation class that itselfs needs an
> instance of the mylib.jar i get a ClassNotFoundException.
> 
> I have tried also the setOperationContext way, but as i read in the
> mailing list, this way is not thread safe.
> 
> Has anybody an idea?
> 
> Thanks in advance.
> 
> Periklis
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
> For additional commands, e-mail: axis-user-help@ws.apache.org
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-user-help@ws.apache.org