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 nhcoder <an...@hotmail.com> on 2009/12/01 21:18:08 UTC

Axis2 and ApplicationContext

Hi,

I tried searching for ApplicationContext on the this site and found this
thread:

http://old.nabble.com/Axis2-service-and-spring-problem%2C-can%27t-find-Spring%27s-ApplicationContext.-ts22842176.html#a22842176

Basically I have an Axis2 skeleton class. In that class is the following
code:

ApplicationContext ctx = new
ClassPathXmlApplicationContext("my-beans2.xml");

myDAO theDAO = (myDAO) ctx.getBean("myDAO");


The problem is that this doesn't apparently work if in Axis2. Standalone
this code worked fine.

I know that the Spring jars are in the classpath so I can't think of any
reason why I would get this error. Since this is a textbook way of getting
the application context I don't understand why this is happening.

The problem that appears in the log is:

[ERROR] org/springframework/context/ApplicationContext
java.lang.NoClassDefFoundError:
org/springframework/context/ApplicationContext
at java.lang.Class.getDeclaredConstructors0(Native Method)
at java.lang.Class.privateGetDeclaredConstructors(Unk nown Source)
at java.lang.Class.getConstructor0(Unknown Source)
at java.lang.Class.newInstance0(Unknown Source)
etc etc

So at the end of the other thread there was the suggestion to create your
own ApplicationContextHolder class.  The problem is if I have my beans in a
file, such as my-beans2.xml, how can I create an ApplicationContextHolder
that reads from that file and gives me access to the beans?


Thanks,

Andy 

-- 
View this message in context: http://old.nabble.com/Axis2-and-ApplicationContext-tp26598402p26598402.html
Sent from the Axis - User mailing list archive at Nabble.com.


Re: Axis2 and ApplicationContext

Posted by nhcoder <an...@hotmail.com>.
Top marks on that one.  I had to manually move the jar files into the
WEB-INF/lib directory even though I had them imported into my Eclipse
project.  My mistake for thinking Eclipse would move them for me when it
autodeployed to Tomcat.

Thanks,

Andy 



iksrazal wrote:
> 
> On Wed, Dec 2, 2009 at 12:52 PM, nhcoder <an...@hotmail.com>
> wrote:
>>
>> Thanks for replying, though I know the jars are in the right place.  This
>> is
>> apparently an issue between Spring and Axis2 working together.
>>
>>
> 
> The NoClassDefFoundError you have makes me highly suspicious of that.
> That should never happen if the jars are in the right place and you
> try to get a reference to that class from the same classloader. Spring
> and Axis2 working together does just that perfectly fine for plenty of
> people. Be sure to follow the docs carefully:
> 
> http://ws.apache.org/axis2/1_5_1/spring.html
> 
> - R
> 
> 

-- 
View this message in context: http://old.nabble.com/Axis2-and-ApplicationContext-tp26598402p26614411.html
Sent from the Axis - User mailing list archive at Nabble.com.


Re: Axis2 and ApplicationContext

Posted by robert lazarski <ro...@gmail.com>.
On Wed, Dec 2, 2009 at 12:52 PM, nhcoder <an...@hotmail.com> wrote:
>
> Thanks for replying, though I know the jars are in the right place.  This is
> apparently an issue between Spring and Axis2 working together.
>
>

The NoClassDefFoundError you have makes me highly suspicious of that.
That should never happen if the jars are in the right place and you
try to get a reference to that class from the same classloader. Spring
and Axis2 working together does just that perfectly fine for plenty of
people. Be sure to follow the docs carefully:

http://ws.apache.org/axis2/1_5_1/spring.html

- R

Re: Axis2 and ApplicationContext

Posted by nhcoder <an...@hotmail.com>.
Thanks for replying, though I know the jars are in the right place.  This is
apparently an issue between Spring and Axis2 working together.  


iksrazal wrote:
> 
> On Tue, Dec 1, 2009 at 5:18 PM, nhcoder <an...@hotmail.com>
> wrote:
>>
>> The problem that appears in the log is:
>>
>> [ERROR] org/springframework/context/ApplicationContext
>> java.lang.NoClassDefFoundError:
>> org/springframework/context/ApplicationContext
>> at java.lang.Class.getDeclaredConstructors0(Native Method)
>> at java.lang.Class.privateGetDeclaredConstructors(Unk nown Source)
>> at java.lang.Class.getConstructor0(Unknown Source)
>> at java.lang.Class.newInstance0(Unknown Source)
>> etc etc
>>
> 
> First step here I think is to put the spring jars in your WEB-INF/lib,
> as you would in any other spring app. Then try to get a reference to
> it as you are doing. From there you can get on to more fancy stuff.
> Let us know how that goes.
> 
> - R
> 
> 

-- 
View this message in context: http://old.nabble.com/Axis2-and-ApplicationContext-tp26598402p26611192.html
Sent from the Axis - User mailing list archive at Nabble.com.


Re: Axis2 and ApplicationContext

Posted by robert lazarski <ro...@gmail.com>.
On Tue, Dec 1, 2009 at 5:18 PM, nhcoder <an...@hotmail.com> wrote:
>
> The problem that appears in the log is:
>
> [ERROR] org/springframework/context/ApplicationContext
> java.lang.NoClassDefFoundError:
> org/springframework/context/ApplicationContext
> at java.lang.Class.getDeclaredConstructors0(Native Method)
> at java.lang.Class.privateGetDeclaredConstructors(Unk nown Source)
> at java.lang.Class.getConstructor0(Unknown Source)
> at java.lang.Class.newInstance0(Unknown Source)
> etc etc
>

First step here I think is to put the spring jars in your WEB-INF/lib,
as you would in any other spring app. Then try to get a reference to
it as you are doing. From there you can get on to more fancy stuff.
Let us know how that goes.

- R

RE: Axis2 and ApplicationContext

Posted by nhcoder <an...@hotmail.com>.
Martin,

Thanks for replying, though I am confused.  It looks like the code below has
to do with jax-ws and not Axis2?

Thanks,

Andy


mgainty wrote:
> 
> 
> obtain the MessageContext first ..then get the ServletContext from the
> MessageContext e.g.
> 
>         org.apache.axis2.context.MessageContext msgContext
> =jaxwsMessageContext.getAxisMessageContext();
> 
>         // If we are running within a servlet container, then JAX-WS
> requires that the
>         // servlet related properties be set on the MessageContext
>         javax.servlet.ServletContext servletContext =
> (ServletContext)jaxwsMessageContext.getProperty(HTTPConstants.MC_HTTP_SERVLETCONTEXT);
> 
> //then if you want the context name
>  String context= servletContext.getServletContextName(); //Returns the
> name of this web application corresponding to this ServletContext as
> specified in the deployment
>  descriptor for     
>                                                                               
> //this web  application by the display-name element.
> 
> Martin 
> ______________________________________________ 
> Verzicht und Vertraulichkeitanmerkung/Note de déni et de confidentialité
>  
> Diese Nachricht ist vertraulich. Sollten Sie nicht der vorgesehene
> Empfaenger sein, so bitten wir hoeflich um eine Mitteilung. Jede unbefugte
> Weiterleitung oder Fertigung einer Kopie ist unzulaessig. Diese Nachricht
> dient lediglich dem Austausch von Informationen und entfaltet keine
> rechtliche Bindungswirkung. Aufgrund der leichten Manipulierbarkeit von
> E-Mails koennen wir keine Haftung fuer den Inhalt uebernehmen.
> Ce message est confidentiel et peut être privilégié. Si vous n'êtes pas le
> destinataire prévu, nous te demandons avec bonté que pour satisfaire
> informez l'expéditeur. N'importe quelle diffusion non autorisée ou la
> copie de ceci est interdite. Ce message sert à l'information seulement et
> n'aura pas n'importe quel effet légalement obligatoire. Étant donné que
> les email peuvent facilement être sujets à la manipulation, nous ne
> pouvons accepter aucune responsabilité pour le contenu fourni.
> 
> 
> 
> 
>> Date: Tue, 1 Dec 2009 12:18:08 -0800
>> From: andrewnbenjamin@hotmail.com
>> To: axis-user@ws.apache.org
>> Subject: Axis2 and ApplicationContext
>> 
>> 
>> Hi,
>> 
>> I tried searching for ApplicationContext on the this site and found this
>> thread:
>> 
>> http://old.nabble.com/Axis2-service-and-spring-problem%2C-can%27t-find-Spring%27s-ApplicationContext.-ts22842176.html#a22842176
>> 
>> Basically I have an Axis2 skeleton class. In that class is the following
>> code:
>> 
>> ApplicationContext ctx = new
>> ClassPathXmlApplicationContext("my-beans2.xml");
>> 
>> myDAO theDAO = (myDAO) ctx.getBean("myDAO");
>> 
>> 
>> The problem is that this doesn't apparently work if in Axis2. Standalone
>> this code worked fine.
>> 
>> I know that the Spring jars are in the classpath so I can't think of any
>> reason why I would get this error. Since this is a textbook way of
>> getting
>> the application context I don't understand why this is happening.
>> 
>> The problem that appears in the log is:
>> 
>> [ERROR] org/springframework/context/ApplicationContext
>> java.lang.NoClassDefFoundError:
>> org/springframework/context/ApplicationContext
>> at java.lang.Class.getDeclaredConstructors0(Native Method)
>> at java.lang.Class.privateGetDeclaredConstructors(Unk nown Source)
>> at java.lang.Class.getConstructor0(Unknown Source)
>> at java.lang.Class.newInstance0(Unknown Source)
>> etc etc
>> 
>> So at the end of the other thread there was the suggestion to create your
>> own ApplicationContextHolder class.  The problem is if I have my beans in
>> a
>> file, such as my-beans2.xml, how can I create an ApplicationContextHolder
>> that reads from that file and gives me access to the beans?
>> 
>> 
>> Thanks,
>> 
>> Andy 
>> 
>> -- 
>> View this message in context:
>> http://old.nabble.com/Axis2-and-ApplicationContext-tp26598402p26598402.html
>> Sent from the Axis - User mailing list archive at Nabble.com.
>> 
>  		 	   		  
> _________________________________________________________________
> Get gifts for them and cashback for you. Try Bing now.
> http://www.bing.com/shopping/search?q=xbox+games&scope=cashback&form=MSHYCB&publ=WLHMTAG&crea=TEXT_MSHYCB_Shopping_Giftsforthem_cashback_1x1
> 

-- 
View this message in context: http://old.nabble.com/Axis2-and-ApplicationContext-tp26598402p26611264.html
Sent from the Axis - User mailing list archive at Nabble.com.


RE: Axis2 and ApplicationContext

Posted by Martin Gainty <mg...@hotmail.com>.
obtain the MessageContext first ..then get the ServletContext from the MessageContext e.g.

        org.apache.axis2.context.MessageContext msgContext =jaxwsMessageContext.getAxisMessageContext();

        // If we are running within a servlet container, then JAX-WS requires that the
        // servlet related properties be set on the MessageContext
        javax.servlet.ServletContext servletContext = (ServletContext)jaxwsMessageContext.getProperty(HTTPConstants.MC_HTTP_SERVLETCONTEXT);

//then if you want the context name
 String context= servletContext.getServletContextName(); //Returns the name of this web application corresponding to this ServletContext as specified in the deployment
 descriptor for     
                                                                               //this web  application by the display-name element.

Martin 
______________________________________________ 
Verzicht und Vertraulichkeitanmerkung/Note de déni et de confidentialité
 
Diese Nachricht ist vertraulich. Sollten Sie nicht der vorgesehene Empfaenger sein, so bitten wir hoeflich um eine Mitteilung. Jede unbefugte Weiterleitung oder Fertigung einer Kopie ist unzulaessig. Diese Nachricht dient lediglich dem Austausch von Informationen und entfaltet keine rechtliche Bindungswirkung. Aufgrund der leichten Manipulierbarkeit von E-Mails koennen wir keine Haftung fuer den Inhalt uebernehmen.
Ce message est confidentiel et peut être privilégié. Si vous n'êtes pas le destinataire prévu, nous te demandons avec bonté que pour satisfaire informez l'expéditeur. N'importe quelle diffusion non autorisée ou la copie de ceci est interdite. Ce message sert à l'information seulement et n'aura pas n'importe quel effet légalement obligatoire. Étant donné que les email peuvent facilement être sujets à la manipulation, nous ne pouvons accepter aucune responsabilité pour le contenu fourni.




> Date: Tue, 1 Dec 2009 12:18:08 -0800
> From: andrewnbenjamin@hotmail.com
> To: axis-user@ws.apache.org
> Subject: Axis2 and ApplicationContext
> 
> 
> Hi,
> 
> I tried searching for ApplicationContext on the this site and found this
> thread:
> 
> http://old.nabble.com/Axis2-service-and-spring-problem%2C-can%27t-find-Spring%27s-ApplicationContext.-ts22842176.html#a22842176
> 
> Basically I have an Axis2 skeleton class. In that class is the following
> code:
> 
> ApplicationContext ctx = new
> ClassPathXmlApplicationContext("my-beans2.xml");
> 
> myDAO theDAO = (myDAO) ctx.getBean("myDAO");
> 
> 
> The problem is that this doesn't apparently work if in Axis2. Standalone
> this code worked fine.
> 
> I know that the Spring jars are in the classpath so I can't think of any
> reason why I would get this error. Since this is a textbook way of getting
> the application context I don't understand why this is happening.
> 
> The problem that appears in the log is:
> 
> [ERROR] org/springframework/context/ApplicationContext
> java.lang.NoClassDefFoundError:
> org/springframework/context/ApplicationContext
> at java.lang.Class.getDeclaredConstructors0(Native Method)
> at java.lang.Class.privateGetDeclaredConstructors(Unk nown Source)
> at java.lang.Class.getConstructor0(Unknown Source)
> at java.lang.Class.newInstance0(Unknown Source)
> etc etc
> 
> So at the end of the other thread there was the suggestion to create your
> own ApplicationContextHolder class.  The problem is if I have my beans in a
> file, such as my-beans2.xml, how can I create an ApplicationContextHolder
> that reads from that file and gives me access to the beans?
> 
> 
> Thanks,
> 
> Andy 
> 
> -- 
> View this message in context: http://old.nabble.com/Axis2-and-ApplicationContext-tp26598402p26598402.html
> Sent from the Axis - User mailing list archive at Nabble.com.
> 
 		 	   		  
_________________________________________________________________
Get gifts for them and cashback for you. Try Bing now.
http://www.bing.com/shopping/search?q=xbox+games&scope=cashback&form=MSHYCB&publ=WLHMTAG&crea=TEXT_MSHYCB_Shopping_Giftsforthem_cashback_1x1