You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by "bastien.legras" <ba...@capgemini.com> on 2007/10/24 23:54:49 UTC

CXF + Spring : Bean outside WebApp have empty properties

Hello,

First of all, my application is an EAR having 3 modules :
- App.war
- AppEJBClient.jar
- AppEJB.jar

App.war has several CXF Web Services working fine.

Problems appear when I move my Beans (generated by WSDL2Java) from App.war
to AppEJBClient.jar.

Each time I call the Web Services I get Beans with null properties.

AppEJBClient.jar is referenced in the App.war's MANIFEST, so I can't think
my issue has anything to do with class visibility as other Classes from
AppEJBClient.jar are well instanciated from App.war.

Finally, I don't get any Exception logged by the CXF framework. I'm using
CXF 2.0.2.

Thanks for your help.

Regards,

Bastien LEGRAS
-- 
View this message in context: http://www.nabble.com/CXF-%2B-Spring-%3A-Bean-outside-WebApp-have-empty-properties-tf4687334.html#a13396024
Sent from the cxf-user mailing list archive at Nabble.com.


Re: CXF + Spring : Bean outside WebApp have empty properties

Posted by Glen Mazza <gl...@verizon.net>.
Am Mittwoch, den 24.10.2007, 15:52 -0700 schrieb bastien.legras:
> 
> Glen Mazza-2 wrote:
> > 
> > Am Mittwoch, den 24.10.2007, 14:54 -0700 schrieb bastien.legras:
> > 
> > Am Mittwoch, den 24.10.2007, 14:54 -0700 schrieb bastien.legras:
> > But can the server access those Beans?  It has to work with them too, 
> > correct?
> > 
> 
> Yes, the JAXB beans reside in the AppEJBClient to be instanciable by both
> the AppWeb and the AppEJB.
> ...
> 
> Just to make it very simple : when I move back the JAXB Beans from
> EJBClient.jar to App.war and redeploy the EAR, everything works again.
> 

Where is your spring configuration file kept--is the basic issue that
Spring configuration is not working when the beans are kept in
EJBClient.jar?

I may not be understanding the problem completely, but I'd like to see
if we can separate CXF from the problem here.  Let's have another
test--can you modify your Spring configuration file to initialize any
bean where (1) the class is within the same JAR as the context config
file and (2) where the class is in a different JAR.  If you can get a
initialized bean from (1) but not from (2), you may have a question for
the Spring forum instead of us.  

But before going to them, if you can get it working in (1) but not in
(2), then I would test on another app server (Geronimo or Glassfish) to
see if you can reproduce the problem.  You may have a JBoss forum
question instead of a Spring one if you can get both initialized on
another app server.

Glen



Re: [FIXED] RE: CXF + Spring : Bean outside WebApp have empty properties

Posted by Jeff Yu <je...@iona.com>.
Hi,

Instead of putting jars in the endorsed folder, could you try to put the 
below jboss-app.xml in your $ear/META-INF to see if it works.

jboss-app.xml:

<?xml version="1.0" encoding="UTF-8"?>
<jboss-app>
    <loader-repository>
        org.apache.cxf:loader=your ear name (such as spring_http.ear)
        <loader-repository-config>
            java2ParentDelegation=false
        </loader-repository-config>
    </loader-repository>
</jboss-app>


Detail please refer to: 
http://www.jboss.org/wiki/Wiki.jsp?page=ClassLoadingConfiguration

Let me know if it works or not...

Thanks
Jeff

bastien.legras wrote:
> After hours of bloody debugging /tracing through CXF code, I found the root
> cause of my issue :
>
> It has to do with my JBOSS 4.0.4 GA environment I forgot to mention :(
>
> For the one who care, I wrote below a detailed explanation + solution
>
> Detailed Explanation :
> JAXBContext is already "classloaded" via jboss-j2ee.jar
> (/server/default/lib) prior the one packaged with CXF (jaxb-api-2.0.jar).
> Jboss's JABXBContext works fine for CXF as long as your JAX Beans are
> packaged  inside the web services application. But once you move your JAX
> Beans outside the application, things changes in the JAXBEncoderDecoder :
>
> line 388 (for CXF 2.0.2) :
> obj = unmarshalWithClass ? u.unmarshal((XMLStreamReader)source, clazz) : u
>
> return an object with null properties as the Unmarshaller is not the right
> one as its implementor comes from Jboss instead of CXF.
>
>
> Solution :
> To fix the issue I found no other solution than copying the following jars
> to JBOSS_HOME/lib/endorsed directory (server/default/lib is not enough) :
> jaxb-api-2.0.jar
> jaxb-impl-2.0.5.jar
> geronimo-activation_1.1_spec-1.0-M1.jar
> stax-api-1.0.1.jar
>
>
> Hope this will help others !
>
> Cheers,
>
> Bastien LEGRAS
>
>   

[FIXED] RE: CXF + Spring : Bean outside WebApp have empty properties

Posted by "bastien.legras" <ba...@capgemini.com>.
After hours of bloody debugging /tracing through CXF code, I found the root
cause of my issue :

It has to do with my JBOSS 4.0.4 GA environment I forgot to mention :(

For the one who care, I wrote below a detailed explanation + solution

Detailed Explanation :
JAXBContext is already "classloaded" via jboss-j2ee.jar
(/server/default/lib) prior the one packaged with CXF (jaxb-api-2.0.jar).
Jboss's JABXBContext works fine for CXF as long as your JAX Beans are
packaged  inside the web services application. But once you move your JAX
Beans outside the application, things changes in the JAXBEncoderDecoder :

line 388 (for CXF 2.0.2) :
obj = unmarshalWithClass ? u.unmarshal((XMLStreamReader)source, clazz) : u

return an object with null properties as the Unmarshaller is not the right
one as its implementor comes from Jboss instead of CXF.


Solution :
To fix the issue I found no other solution than copying the following jars
to JBOSS_HOME/lib/endorsed directory (server/default/lib is not enough) :
jaxb-api-2.0.jar
jaxb-impl-2.0.5.jar
geronimo-activation_1.1_spec-1.0-M1.jar
stax-api-1.0.1.jar


Hope this will help others !

Cheers,

Bastien LEGRAS

-- 
View this message in context: http://www.nabble.com/CXF-%2B-Spring-%3A-Bean-outside-WebApp-have-empty-properties-tf4687334.html#a13419394
Sent from the cxf-user mailing list archive at Nabble.com.


RE: CXF + Spring : Bean outside WebApp have empty properties

Posted by Benson Margulies <bi...@basistech.com>.
Sure, all the time.

> -----Original Message-----
> From: bastien.legras [mailto:bastien.legras@capgemini.com]
> Sent: Wednesday, October 24, 2007 7:36 PM
> To: cxf-user@incubator.apache.org
> Subject: Re: CXF + Spring : Bean outside WebApp have empty properties
> 
> 
> ... So the point is : has anyone managed to move the JAX Beans outsite
the
> web services' application (i.e : external jar) ?
> 
> --
> View this message in context:
http://www.nabble.com/CXF-%2B-Spring-%3A-
> Bean-outside-WebApp-have-empty-properties-tf4687334.html#a13397362
> Sent from the cxf-user mailing list archive at Nabble.com.


Re: CXF + Spring : Bean outside WebApp have empty properties

Posted by "bastien.legras" <ba...@capgemini.com>.
... So the point is : has anyone managed to move the JAX Beans outsite the
web services' application (i.e : external jar) ?

-- 
View this message in context: http://www.nabble.com/CXF-%2B-Spring-%3A-Bean-outside-WebApp-have-empty-properties-tf4687334.html#a13397362
Sent from the cxf-user mailing list archive at Nabble.com.


Re: CXF + Spring : Bean outside WebApp have empty properties

Posted by "bastien.legras" <ba...@capgemini.com>.

Glen Mazza-2 wrote:
> 
> Am Mittwoch, den 24.10.2007, 14:54 -0700 schrieb bastien.legras:
> 
> Can you forget about the web service for the moment, and just try to
> initialize/instantiate some of the JAXB beans within the AppEJBClient
> code?  I would like to see if we can separate web service issues vs.
> 

I wrote a test class into EJBClient instanciating and returning one of the
JAXBean via a static method.

I call that test class from the EndPoint implementor. When I call the web
service, I can call from App.war the test class of EJBClient.jar which
returns a JAXB Bean instance.


Glen Mazza-2 wrote:
> 
> Am Mittwoch, den 24.10.2007, 14:54 -0700 schrieb bastien.legras:
> 
> Am Mittwoch, den 24.10.2007, 14:54 -0700 schrieb bastien.legras:
> But can the server access those Beans?  It has to work with them too, 
> correct?
> 

Yes, the JAXB beans reside in the AppEJBClient to be instanciable by both
the AppWeb and the AppEJB.
...

Just to make it very simple : when I move back the JAXB Beans from
EJBClient.jar to App.war and redeploy the EAR, everything works again.

-- 
View this message in context: http://www.nabble.com/CXF-%2B-Spring-%3A-Bean-outside-WebApp-have-empty-properties-tf4687334.html#a13396876
Sent from the cxf-user mailing list archive at Nabble.com.


Re: CXF + Spring : Bean outside WebApp have empty properties

Posted by Glen Mazza <gl...@verizon.net>.
Am Mittwoch, den 24.10.2007, 14:54 -0700 schrieb bastien.legras:
> Hello,
> 
> First of all, my application is an EAR having 3 modules :
> - App.war
> - AppEJBClient.jar
> - AppEJB.jar
> 
> App.war has several CXF Web Services working fine.
> 
> Problems appear when I move my Beans (generated by WSDL2Java) from App.war
> to AppEJBClient.jar.
> 
> Each time I call the Web Services I get Beans with null properties.
> 

Can you forget about the web service for the moment, and just try to
initialize/instantiate some of the JAXB beans within the AppEJBClient
code?  I would like to see if we can separate web service issues vs.
classloader issues.


> AppEJBClient.jar is referenced in the App.war's MANIFEST, so I can't think
> my issue has anything to do with class visibility as other Classes from
> AppEJBClient.jar are well instanciated from App.war.
> 

But can the server access those Beans?  It has to work with them too,
correct?

HTH,
Glen

> Finally, I don't get any Exception logged by the CXF framework. I'm using
> CXF 2.0.2.
> 
> Thanks for your help.
> 
> Regards,
> 
> Bastien LEGRAS