Axis2 / Spring3 / .aar file

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

Axis2 / Spring3 / .aar file

simone
Hi,

I try to deploy a webservice with axis2 and spring 3.2.

I wrote a SpringInit:
  ClassLoader classLoader = service.getClassLoader();
             ClassPathXmlApplicationContext appCtx = new
ClassPathXmlApplicationContext(
                     new String[] { "application.xml" }, false);
             appCtx.setClassLoader(classLoader);
             appCtx.refresh();

Added following lines to my application.xml

<bean id="applicationContext"
class="org.apache.axis2.extensions.spring.receivers.ApplicationContextHolder"
/>
     <bean id="springAwareService"
class="com.ids.dam.impl.DAMServiceSkeleton">
     </bean>

and this is my services.xml

<service name="SpringInit" class="com.ids.dam.impl.SpringInit">
         <description>
             This web service initializes Spring.
         </description>
         <parameter name="ServiceClass">com.ids.dam.impl.SpringInit
         </parameter>
         <parameter name="ServiceTCCL">composite</parameter>
         <parameter name="load-on-startup">true</parameter>
         <operation name="sprintInit">
             <messageReceiver
class="org.apache.axis2.receivers.RawXMLINOutMessageReceiver" />
         </operation>
     </service>

.

At the start of tomcat I get the following error:

  java.lang.NoClassDefFoundError:
org/springframework/context/ApplicationContextAware



But all spring jars exists in .aar/lib folder.

Please help :-)

Kind regards, SImone




---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Axis2 / Spring3 / .aar file

robertlazarski .
On Tue, Oct 15, 2013 at 7:03 AM, Simone <[hidden email]> wrote:

> Hi,
>
> I try to deploy a webservice with axis2 and spring 3.2.
>
> I wrote a SpringInit:
>  ClassLoader classLoader = service.getClassLoader();
>             ClassPathXmlApplicationContext appCtx = new
> ClassPathXmlApplicationContext(
>                     new String[] { "application.xml" }, false);
>             appCtx.setClassLoader(classLoader);
>             appCtx.refresh();
>
> Added following lines to my application.xml
>
> <bean id="applicationContext"
> class="org.apache.axis2.extensions.spring.receivers.ApplicationContextHolder"
> />
>     <bean id="springAwareService"
> class="com.ids.dam.impl.DAMServiceSkeleton">
>     </bean>
>
> and this is my services.xml
>
> <service name="SpringInit" class="com.ids.dam.impl.SpringInit">
>         <description>
>             This web service initializes Spring.
>         </description>
>         <parameter name="ServiceClass">com.ids.dam.impl.SpringInit
>         </parameter>
>         <parameter name="ServiceTCCL">composite</parameter>
>         <parameter name="load-on-startup">true</parameter>
>         <operation name="sprintInit">
>             <messageReceiver
> class="org.apache.axis2.receivers.RawXMLINOutMessageReceiver" />
>         </operation>
>     </service>
>
> .
>
> At the start of tomcat I get the following error:
>
>  java.lang.NoClassDefFoundError:
> org/springframework/context/ApplicationContextAware
>
>
>
> But all spring jars exists in .aar/lib folder.
>
> Please help :-)
>
> Kind regards, SImone

Did you do this step?

"move the axis2-spring-*.jar from WEB-INF/lib to inside the AAR, as
shown below - it will not work otherwise."

Make sure that jar is only in the aar. Also, try expanding your
springframework jar to verify
org/springframework/context/ApplicationContextAware is inside. A quick
look at the springframework docs indicates that the class is still in
the distro, but we need to double check.

- R

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Axis2 / Spring3 / .aar file

simone
Did you do this step? "move the axis2-spring-*.jar from WEB-INF/lib to
inside the AAR, as shown below - it will not work otherwise." Make sure
that jar is only in the aar. Also, try expanding your springframework
jar to verify org/springframework/context/ApplicationContextAware is
inside. A quick look at the springframework docs indicates that the
class is still in the distro, but we need to double check. - R
--------------------------------------------------------------------- To
unsubscribe, e-mail: [hidden email] For
additional commands, e-mail: [hidden email]



Hi,

the jars have been in the lib folder of the .aar file.
I copied the jars to the axis2/WEB-INF/lib folder and now it works. But
I don`t understand why?
The next problem (using hibernate with spring) :

[INFO] Loaded JDBC driver: com.mysql.jdbc.Driver
[INFO] HCANN000001: Hibernate Commons Annotations {4.0.2.Final}
[INFO] HHH000412: Hibernate Core {4.2.5.Final}
[INFO] HHH000206: hibernate.properties not found
[INFO] HHH000021: Bytecode provider name : javassist
[WARN] HHH000342: Could not obtain connection to query metadata : No
suitable driver found for jdbc:mysql://xxxx:3306/dam_sr
[INFO] HHH000400: Using dialect: org.hibernate.dialect.MySQLDialect
[INFO] HHH000422: Disabling contextual LOB creation as connection was null
[INFO] HHH000399: Using default transaction strategy (direct JDBC
transactions)
[INFO] HHH000397: Using ASTQueryTranslatorFactory
[INFO] Using DataSource
[org.springframework.jdbc.datasource.DriverManagerDataSource@69c290fe]
of Hibernate SessionFactory for HibernateTransactionManager
spring loaded


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

RE: Axis2 / Spring3 / .aar file

Martin Gainty
In reply to this post by robertlazarski .
Simone and Robert
 
i dont know how many times Ive been bitten by CNFE by Spring Injector
 
http://www.grepcode.com/search/?query=org/springframework/context/ApplicationContextAware
 
reveals ApplicationContextAware is located in spring-context-3.x.jar
but spring-core-3.x.jar is a dependency of spring-context so add spring-core-3.x.jar
to distro

Robert is right in that Injector will  *always* find a class thats in the distro (.aar)

but you *should* be able to flip classLoaders and have the new CL find it in its classpath...
Nota Bene:same CNFE error happens when guice implements Spring injector 
IMHO this is incorrect behaviour and the Injector *should* implement the requested CL to locate all requested classes

I've looked into this *problem* and I'll post findings and workaround on maven-dev

Obrigado,
Martin 

 

> Date: Tue, 15 Oct 2013 07:50:08 -0300

> Subject: Re: Axis2 / Spring3 / .aar file
> From: [hidden email]
> To: [hidden email]
>
> On Tue, Oct 15, 2013 at 7:03 AM, Simone <[hidden email]> wrote:
> > Hi,
> >
> > I try to deploy a webservice with axis2 and spring 3.2.
> >
> > I wrote a SpringInit:
> > ClassLoader classLoader = service.getClassLoader();
> > ClassPathXmlApplicationContext appCtx = new
> > ClassPathXmlApplicationContext(
> > new String[] { "application.xml" }, false);
> > appCtx.setClassLoader(classLoader);
> > appCtx.refresh();
> >
> > Added following lines to my application.xml
> >
> > <bean id="applicationContext"
> > class="org.apache.axis2.extensions.spring.receivers.ApplicationContextHolder"
> > />
> > <bean id="springAwareService"
> > class="com.ids.dam.impl.DAMServiceSkeleton">
> > </bean>
> >
> > and this is my services.xml
> >
> > <service name="SpringInit" class="com.ids.dam.impl.SpringInit">
> > <description>
> > This web service initializes Spring.
> > </description>
> > <parameter name="ServiceClass">com.ids.dam.impl.SpringInit
> > </parameter>
> > <parameter name="ServiceTCCL">composite</parameter>
> > <parameter name="load-on-startup">true</parameter>
> > <operation name="sprintInit">
> > <messageReceiver
> > class="org.apache.axis2.receivers.RawXMLINOutMessageReceiver" />
> > </operation>
> > </service>
> >
> > .
> >
> > At the start of tomcat I get the following error:
> >
> > java.lang.NoClassDefFoundError:
> > org/springframework/context/ApplicationContextAware
> >
> >
> >
> > But all spring jars exists in .aar/lib folder.
> >
> > Please help :-)
> >
> > Kind regards, SImone
>
> Did you do this step?
>
> "move the axis2-spring-*.jar from WEB-INF/lib to inside the AAR, as
> shown below - it will not work otherwise."
>
> Make sure that jar is only in the aar. Also, try expanding your
> springframework jar to verify
> org/springframework/context/ApplicationContextAware is inside. A quick
> look at the springframework docs indicates that the class is still in
> the distro, but we need to double check.
>
> - R
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
Reply | Threaded
Open this post in threaded view
|

Re: Axis2 / Spring3 / .aar file

simone
But it works now, after I added the jars into the web-inf/lib folder of axis2.
I thought because of the: <parameter name="ServiceTCCL">composite</parameter>, spring is "inside" of the .aar ?

As I wrote in my previous e-mail the next problem is hibernate with spring:

[INFO] Loaded JDBC driver: com.mysql.jdbc.Driver
[INFO] HCANN000001: Hibernate Commons Annotations {4.0.2.Final}
[INFO] HHH000412: Hibernate Core {4.2.5.Final}
[INFO] HHH000206: hibernate.properties not found
[INFO] HHH000021: Bytecode provider name : javassist
[WARN] HHH000342: Could not obtain connection to query metadata : No suitable driver found for jdbc:mysql://xxxx:3306/dam_sr
[INFO] HHH000400: Using dialect: org.hibernate.dialect.MySQLDialect
[INFO] HHH000422: Disabling contextual LOB creation as connection was null
[INFO] HHH000399: Using default transaction strategy (direct JDBC transactions)
[INFO] HHH000397: Using ASTQueryTranslatorFactory
[INFO] Using DataSource [org.springframework.jdbc.datasource.DriverManagerDataSource@69c290fe] of Hibernate SessionFactory for HibernateTransactionManager


Thx

Am 15.10.2013 13:24, schrieb Martin Gainty:
Simone and Robert
 
i dont know how many times Ive been bitten by CNFE by Spring Injector
 
http://www.grepcode.com/search/?query=org/springframework/context/ApplicationContextAware
 
reveals ApplicationContextAware is located in spring-context-3.x.jar
but spring-core-3.x.jar is a dependency of spring-context so add spring-core-3.x.jar
to distro

Robert is right in that Injector will  *always* find a class thats in the distro (.aar)

but you *should* be able to flip classLoaders and have the new CL find it in its classpath...
Nota Bene:same CNFE error happens when guice implements Spring injector 
IMHO this is incorrect behaviour and the Injector *should* implement the requested CL to locate all requested classes

I've looked into this *problem* and I'll post findings and workaround on maven-dev

Obrigado,
Martin 

 

> Date: Tue, 15 Oct 2013 07:50:08 -0300
> Subject: Re: Axis2 / Spring3 / .aar file
> From: [hidden email]
> To: [hidden email]
>
> On Tue, Oct 15, 2013 at 7:03 AM, Simone [hidden email] wrote:
> > Hi,
> >
> > I try to deploy a webservice with axis2 and spring 3.2.
> >
> > I wrote a SpringInit:
> > ClassLoader classLoader = service.getClassLoader();
> > ClassPathXmlApplicationContext appCtx = new
> > ClassPathXmlApplicationContext(
> > new String[] { "application.xml" }, false);
> > appCtx.setClassLoader(classLoader);
> > appCtx.refresh();
> >
> > Added following lines to my application.xml
> >
> > <bean id="applicationContext"
> > class="org.apache.axis2.extensions.spring.receivers.ApplicationContextHolder"
> > />
> > <bean id="springAwareService"
> > class="com.ids.dam.impl.DAMServiceSkeleton">
> > </bean>
> >
> > and this is my services.xml
> >
> > <service name="SpringInit" class="com.ids.dam.impl.SpringInit">
> > <description>
> > This web service initializes Spring.
> > </description>
> > <parameter name="ServiceClass">com.ids.dam.impl.SpringInit
> > </parameter>
> > <parameter name="ServiceTCCL">composite</parameter>
> > <parameter name="load-on-startup">true</parameter>
> > <operation name="sprintInit">
> > <messageReceiver
> > class="org.apache.axis2.receivers.RawXMLINOutMessageReceiver" />
> > </operation>
> > </service>
> >
> > .
> >
> > At the start of tomcat I get the following error:
> >
> > java.lang.NoClassDefFoundError:
> > org/springframework/context/ApplicationContextAware
> >
> >
> >
> > But all spring jars exists in .aar/lib folder.
> >
> > Please help :-)
> >
> > Kind regards, SImone
>
> Did you do this step?
>
> "move the axis2-spring-*.jar from WEB-INF/lib to inside the AAR, as
> shown below - it will not work otherwise."
>
> Make sure that jar is only in the aar. Also, try expanding your
> springframework jar to verify
> org/springframework/context/ApplicationContextAware is inside. A quick
> look at the springframework docs indicates that the class is still in
> the distro, but we need to double check.
>
> - R
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>

Reply | Threaded
Open this post in threaded view
|

Re: Axis2 / Spring3 / .aar file

simone
In reply to this post by Martin Gainty
I copied the mysql connector jar to the web-inf/lib folder... now it
works. But I prefer that it's using the jars from the .aar file.
Is the lib folder the correct place for the jars in the .aar file???

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Axis2 / Spring3 / .aar file

robertlazarski .
On Tue, Oct 15, 2013 at 8:48 AM, Simone <[hidden email]> wrote:
> I copied the mysql connector jar to the web-inf/lib folder... now it works.
> But I prefer that it's using the jars from the .aar file.
> Is the lib folder the correct place for the jars in the .aar file???
>
>

Some libs like hibernate and DB drivers must be loaded from  the
Thread Context ClassLoader (TCCL) of the Servlet container, ie
WEB-INF/lib. Hibernate in particular AFAIK requires the TCCL.

I went thru my email history on this from way back around the axis2
1.0 days, and the conclusion was that some things cannot be loaded
from the AAR.

- R

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]