You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by "KARR, DAVID (ATTCINW)" <dk...@att.com> on 2009/09/05 02:17:24 UTC

Need help writing JAXBElementProvider that uses "jaxbElementClassMap"

I noticed in the following thread
<http://www.mail-archive.com/users@cxf.apache.org/msg09175.html> that
there are some changes in the trunk to allow JAXBElementProvider to have
a "jaxbElementClassMap" property, which will allow me to bind my REST
services to classes I don't control (or are generated), so I can't add
"@XmlRootElement" to them.  Sergey mentioned in that thread that it
would be straightforward to build that JAXBElementProvider before the
next release it's available in.  Would that be possible?

RE: Need help writing JAXBElementProvider that uses "jaxbElementClassMap"

Posted by "KARR, DAVID (ATTCINW)" <dk...@att.com>.
> -----Original Message-----
> From: Sergey Beryozkin [mailto:sergey.beryozkin@iona.com]
> 
> You can extend JaxbElementProvider and override
> AbstractJAXBProvider.convertToJaxbElemenIfNeeded() and implement it
the
> way
> it's done on the trunk [1].

The "jaxbElementClassMap" map is referenced in more than just the
"AbstractJAXBProvider.convertToJaxbElementIfNeeded()" method. It's also
referenced in "AbstractJAXBProvider.isSupported()" and
"JAXBElementProvider.readFrom()".

It appears that I'll need to create my new subclass in the same package
as JAXBElementProvider, at least for the reason that
"org.apache.cxf.jaxrs.provider.AbstractJAXBProvider.CollectionWrapper"
is defined as a protected class in "AbstractJAXBProvider".

I'm not sure whether it will be easier to just define my subclass
identical to JAXBElementProvider and then try to remove pieces, or start
from the minimal side and add pieces.

> 
> let me know please how it goes
> 
> cheers, SErgey
> 
> [1]
>
http://svn.apache.org/repos/asf/cxf/trunk/rt/frontend/jaxrs/src/main/ja
> va/org/apache/cxf/jaxrs/provider/AbstractJAXBProvider.java
> 
> 
> KARR, DAVID (ATTCINW) wrote:
> >
> > I noticed in the following thread
> > <http://www.mail-archive.com/users@cxf.apache.org/msg09175.html>
that
> > there are some changes in the trunk to allow JAXBElementProvider to
> have
> > a "jaxbElementClassMap" property, which will allow me to bind my
REST
> > services to classes I don't control (or are generated), so I can't
> add
> > "@XmlRootElement" to them.  Sergey mentioned in that thread that it
> > would be straightforward to build that JAXBElementProvider before
the
> > next release it's available in.  Would that be possible?
> >
> >
> 
> --
> View this message in context: http://www.nabble.com/Need-help-writing-
> JAXBElementProvider-that-uses-%22jaxbElementClassMap%22-
> tp25303787p25312013.html
> Sent from the cxf-user mailing list archive at Nabble.com.


RE: Need help writing JAXBElementProvider that uses "jaxbElementClassMap"

Posted by "KARR, DAVID (ATTCINW)" <dk...@att.com>.
> -----Original Message-----
> From: Sergey Beryozkin [mailto:sergey.beryozkin@iona.com]
> 
> May be you need to add a cxf bundle jar into your WEB-APP/lib ? May be
> it
> will help a (WebLogic) classloader to resolve CXF classes ?

I think one problem is that this EAR file that the WAR is in already
uses an older version of JAXB, and I don't have any control over that.
If you can believe it, it appears to be implementation version 1.0.1,
from January of 2005.  I tried using the WebLogic incantation that
"prefers" the jars in the webapp as opposed to other jars in the
classloader, but it didn't help.  I don't think that works if there's a
conflict with other jars in the same EAR.

If anything, I'll try removing the JAXB jar that CXF loads, and see if I
at least fix my classloader conflicts.  I know there's at least one line
in JAXBElementProvider that depends on a newer JAXB, but I don't know if
there's any critical functionality.

> KARR, DAVID (ATTCINW) wrote:
> >
> >> -----Original Message-----
> >> From: Sergey Beryozkin [mailto:sergey.beryozkin@iona.com]
> >> Sent: Saturday, September 05, 2009 1:23 PM
> >> To: users@cxf.apache.org
> >> Subject: Re: Need help writing JAXBElementProvider that uses
> >> "jaxbElementClassMap"
> >>
> >>
> >> Hi
> >>
> >> You can extend JaxbElementProvider and override
> >> AbstractJAXBProvider.convertToJaxbElemenIfNeeded() and implement it
> > the
> >> way
> >> it's done on the trunk [1].
> >>
> >> let me know please how it goes
> >
> > I'm getting a screwy error trying to implement a copy of
> > JAXBElementProvider as a subclass of the original
> JAXBElementProvider,
> > with the additional definition of the "jaxbElementClassMap"
property.
> >
> > Before making this change, I was just getting the error saying that
> > "jaxbElementClassMap" wasn't a property of "JAXBElementProvider",
> which
> > isn't surprising.
> >
> > I've defined a class "TempJAXBElementProvider" which extends
> > "org.apache.cxf.jaxrs.provider.JAXBElementProvider", and I have the
> > following bean in my beans.xml:
> >
> > <bean id="jaxbProvider"
> > class="org.apache.cxf.jaxrs.provider.TempJAXBElementProvider">
> >     <property name="jaxbElementClassMap" ref="jaxbElementClassMap"
/>
> > </bean>
> >
> > After implementing this class, I'm now getting the following Spring
> init
> > failure:
> >
> > ------
> > [ERROR] ContextLoader - -Context initialization failed
> > <org.springframework.beans.factory.BeanCreationException: Error
> creating
> > bean with name 'org.apache.cxf.resource.ResourceManager' defined in
> > class path resource [META-INF/cxf/cxf.xml]: Initialization of bean
> > failed; nested exception is
> > org.springframework.beans.factory.CannotLoadBeanClassException:
Error
> > loading class
[org.apache.cxf.jaxrs.provider.TempJAXBElementProvider]
> > for bean with name 'jaxbProvider' defined in ServletContext resource
> > [/WEB-INF/beans.xml]: problem with class file or dependent class;
> nested
> > exception is java.lang.NoClassDefFoundError:
> >
>
org/apache/cxf/jaxrs/provider/JAXBElementProvider>org.springframework.b
> e
> > ans.factory.BeanCreationException: Error creating bean with name
> > 'org.apache.cxf.resource.ResourceManager' defined in class path
> resource
> > [META-INF/cxf/cxf.xml]: Initialization of bean failed; nested
> exception
> > is org.springframework.beans.factory.CannotLoadBeanClassException:
> Error
> > loading class
[org.apache.cxf.jaxrs.provider.TempJAXBElementProvider]
> > for bean with name 'jaxbProvider' defined in ServletContext resource
> > [/WEB-INF/beans.xml]: problem with class file or dependent class;
> nested
> > exception is java.lang.NoClassDefFoundError:
> > org/apache/cxf/jaxrs/provider/JAXBElementProvider
> > ----------------
> >
> > It doesn't make sense that it can't find the class def for
> > "org/apache/cxf/jaxrs/provider/JAXBElementProvider".  The only
change
> I
> > made in what jars are supplied is that I added
> > "geronimo-stax-api_1.0_spec-1.0.1.jar" as that was apparently needed
> by
> > some constructs in the copied JAXBElementProvider class.  I'm
> obviously
> > still including the cxf-2.2.3.jar file in the WEB-INF/lib.
> >
> >>
> >> cheers, SErgey
> >>
> >> [1]
> >>
> >
>
http://svn.apache.org/repos/asf/cxf/trunk/rt/frontend/jaxrs/src/main/ja
> >> va/org/apache/cxf/jaxrs/provider/AbstractJAXBProvider.java
> >>
> >>
> >> KARR, DAVID (ATTCINW) wrote:
> >> >
> >> > I noticed in the following thread
> >> > <http://www.mail-archive.com/users@cxf.apache.org/msg09175.html>
> > that
> >> > there are some changes in the trunk to allow JAXBElementProvider
> to
> >> have
> >> > a "jaxbElementClassMap" property, which will allow me to bind my
> > REST
> >> > services to classes I don't control (or are generated), so I
can't
> >> add
> >> > "@XmlRootElement" to them.  Sergey mentioned in that thread that
> it
> >> > would be straightforward to build that JAXBElementProvider before
> > the
> >> > next release it's available in.  Would that be possible?
> >> >
> >> >
> >>
> >> --
> >> View this message in context: http://www.nabble.com/Need-help-
> writing-
> >> JAXBElementProvider-that-uses-%22jaxbElementClassMap%22-
> >> tp25303787p25312013.html
> >> Sent from the cxf-user mailing list archive at Nabble.com.
> >
> >
> >
> 
> --
> View this message in context: http://www.nabble.com/Need-help-writing-
> JAXBElementProvider-that-uses-%22jaxbElementClassMap%22-
> tp25303787p25365592.html
> Sent from the cxf-user mailing list archive at Nabble.com.


RE: Need help writing JAXBElementProvider that uses "jaxbElementClassMap"

Posted by Sergey Beryozkin <se...@iona.com>.
May be you need to add a cxf bundle jar into your WEB-APP/lib ? May be it
will help a (WebLogic) classloader to resolve CXF classes ?

cheers, Sergey
 

KARR, DAVID (ATTCINW) wrote:
> 
>> -----Original Message-----
>> From: Sergey Beryozkin [mailto:sergey.beryozkin@iona.com]
>> Sent: Saturday, September 05, 2009 1:23 PM
>> To: users@cxf.apache.org
>> Subject: Re: Need help writing JAXBElementProvider that uses
>> "jaxbElementClassMap"
>> 
>> 
>> Hi
>> 
>> You can extend JaxbElementProvider and override
>> AbstractJAXBProvider.convertToJaxbElemenIfNeeded() and implement it
> the
>> way
>> it's done on the trunk [1].
>> 
>> let me know please how it goes
> 
> I'm getting a screwy error trying to implement a copy of
> JAXBElementProvider as a subclass of the original JAXBElementProvider,
> with the additional definition of the "jaxbElementClassMap" property.
> 
> Before making this change, I was just getting the error saying that
> "jaxbElementClassMap" wasn't a property of "JAXBElementProvider", which
> isn't surprising.
> 
> I've defined a class "TempJAXBElementProvider" which extends
> "org.apache.cxf.jaxrs.provider.JAXBElementProvider", and I have the
> following bean in my beans.xml:
> 
> <bean id="jaxbProvider"
> class="org.apache.cxf.jaxrs.provider.TempJAXBElementProvider">
>     <property name="jaxbElementClassMap" ref="jaxbElementClassMap" />
> </bean>
> 
> After implementing this class, I'm now getting the following Spring init
> failure:
> 
> ------
> [ERROR] ContextLoader - -Context initialization failed
> <org.springframework.beans.factory.BeanCreationException: Error creating
> bean with name 'org.apache.cxf.resource.ResourceManager' defined in
> class path resource [META-INF/cxf/cxf.xml]: Initialization of bean
> failed; nested exception is
> org.springframework.beans.factory.CannotLoadBeanClassException: Error
> loading class [org.apache.cxf.jaxrs.provider.TempJAXBElementProvider]
> for bean with name 'jaxbProvider' defined in ServletContext resource
> [/WEB-INF/beans.xml]: problem with class file or dependent class; nested
> exception is java.lang.NoClassDefFoundError:
> org/apache/cxf/jaxrs/provider/JAXBElementProvider>org.springframework.be
> ans.factory.BeanCreationException: Error creating bean with name
> 'org.apache.cxf.resource.ResourceManager' defined in class path resource
> [META-INF/cxf/cxf.xml]: Initialization of bean failed; nested exception
> is org.springframework.beans.factory.CannotLoadBeanClassException: Error
> loading class [org.apache.cxf.jaxrs.provider.TempJAXBElementProvider]
> for bean with name 'jaxbProvider' defined in ServletContext resource
> [/WEB-INF/beans.xml]: problem with class file or dependent class; nested
> exception is java.lang.NoClassDefFoundError:
> org/apache/cxf/jaxrs/provider/JAXBElementProvider
> ----------------
> 
> It doesn't make sense that it can't find the class def for
> "org/apache/cxf/jaxrs/provider/JAXBElementProvider".  The only change I
> made in what jars are supplied is that I added
> "geronimo-stax-api_1.0_spec-1.0.1.jar" as that was apparently needed by
> some constructs in the copied JAXBElementProvider class.  I'm obviously
> still including the cxf-2.2.3.jar file in the WEB-INF/lib.
> 
>> 
>> cheers, SErgey
>> 
>> [1]
>>
> http://svn.apache.org/repos/asf/cxf/trunk/rt/frontend/jaxrs/src/main/ja
>> va/org/apache/cxf/jaxrs/provider/AbstractJAXBProvider.java
>> 
>> 
>> KARR, DAVID (ATTCINW) wrote:
>> >
>> > I noticed in the following thread
>> > <http://www.mail-archive.com/users@cxf.apache.org/msg09175.html>
> that
>> > there are some changes in the trunk to allow JAXBElementProvider to
>> have
>> > a "jaxbElementClassMap" property, which will allow me to bind my
> REST
>> > services to classes I don't control (or are generated), so I can't
>> add
>> > "@XmlRootElement" to them.  Sergey mentioned in that thread that it
>> > would be straightforward to build that JAXBElementProvider before
> the
>> > next release it's available in.  Would that be possible?
>> >
>> >
>> 
>> --
>> View this message in context: http://www.nabble.com/Need-help-writing-
>> JAXBElementProvider-that-uses-%22jaxbElementClassMap%22-
>> tp25303787p25312013.html
>> Sent from the cxf-user mailing list archive at Nabble.com.
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Need-help-writing-JAXBElementProvider-that-uses-%22jaxbElementClassMap%22-tp25303787p25365592.html
Sent from the cxf-user mailing list archive at Nabble.com.


RE: Need help writing JAXBElementProvider that uses "jaxbElementClassMap"

Posted by "KARR, DAVID (ATTCINW)" <dk...@att.com>.
> -----Original Message-----
> From: Sergey Beryozkin [mailto:sergey.beryozkin@iona.com]
> Sent: Saturday, September 05, 2009 1:23 PM
> To: users@cxf.apache.org
> Subject: Re: Need help writing JAXBElementProvider that uses
> "jaxbElementClassMap"
> 
> 
> Hi
> 
> You can extend JaxbElementProvider and override
> AbstractJAXBProvider.convertToJaxbElemenIfNeeded() and implement it
the
> way
> it's done on the trunk [1].
> 
> let me know please how it goes

I'm getting a screwy error trying to implement a copy of
JAXBElementProvider as a subclass of the original JAXBElementProvider,
with the additional definition of the "jaxbElementClassMap" property.

Before making this change, I was just getting the error saying that
"jaxbElementClassMap" wasn't a property of "JAXBElementProvider", which
isn't surprising.

I've defined a class "TempJAXBElementProvider" which extends
"org.apache.cxf.jaxrs.provider.JAXBElementProvider", and I have the
following bean in my beans.xml:

<bean id="jaxbProvider"
class="org.apache.cxf.jaxrs.provider.TempJAXBElementProvider">
    <property name="jaxbElementClassMap" ref="jaxbElementClassMap" />
</bean>

After implementing this class, I'm now getting the following Spring init
failure:

------
[ERROR] ContextLoader - -Context initialization failed
<org.springframework.beans.factory.BeanCreationException: Error creating
bean with name 'org.apache.cxf.resource.ResourceManager' defined in
class path resource [META-INF/cxf/cxf.xml]: Initialization of bean
failed; nested exception is
org.springframework.beans.factory.CannotLoadBeanClassException: Error
loading class [org.apache.cxf.jaxrs.provider.TempJAXBElementProvider]
for bean with name 'jaxbProvider' defined in ServletContext resource
[/WEB-INF/beans.xml]: problem with class file or dependent class; nested
exception is java.lang.NoClassDefFoundError:
org/apache/cxf/jaxrs/provider/JAXBElementProvider>org.springframework.be
ans.factory.BeanCreationException: Error creating bean with name
'org.apache.cxf.resource.ResourceManager' defined in class path resource
[META-INF/cxf/cxf.xml]: Initialization of bean failed; nested exception
is org.springframework.beans.factory.CannotLoadBeanClassException: Error
loading class [org.apache.cxf.jaxrs.provider.TempJAXBElementProvider]
for bean with name 'jaxbProvider' defined in ServletContext resource
[/WEB-INF/beans.xml]: problem with class file or dependent class; nested
exception is java.lang.NoClassDefFoundError:
org/apache/cxf/jaxrs/provider/JAXBElementProvider
----------------

It doesn't make sense that it can't find the class def for
"org/apache/cxf/jaxrs/provider/JAXBElementProvider".  The only change I
made in what jars are supplied is that I added
"geronimo-stax-api_1.0_spec-1.0.1.jar" as that was apparently needed by
some constructs in the copied JAXBElementProvider class.  I'm obviously
still including the cxf-2.2.3.jar file in the WEB-INF/lib.

> 
> cheers, SErgey
> 
> [1]
>
http://svn.apache.org/repos/asf/cxf/trunk/rt/frontend/jaxrs/src/main/ja
> va/org/apache/cxf/jaxrs/provider/AbstractJAXBProvider.java
> 
> 
> KARR, DAVID (ATTCINW) wrote:
> >
> > I noticed in the following thread
> > <http://www.mail-archive.com/users@cxf.apache.org/msg09175.html>
that
> > there are some changes in the trunk to allow JAXBElementProvider to
> have
> > a "jaxbElementClassMap" property, which will allow me to bind my
REST
> > services to classes I don't control (or are generated), so I can't
> add
> > "@XmlRootElement" to them.  Sergey mentioned in that thread that it
> > would be straightforward to build that JAXBElementProvider before
the
> > next release it's available in.  Would that be possible?
> >
> >
> 
> --
> View this message in context: http://www.nabble.com/Need-help-writing-
> JAXBElementProvider-that-uses-%22jaxbElementClassMap%22-
> tp25303787p25312013.html
> Sent from the cxf-user mailing list archive at Nabble.com.


Re: Need help writing JAXBElementProvider that uses "jaxbElementClassMap"

Posted by Sergey Beryozkin <se...@iona.com>.
Hi

You can extend JaxbElementProvider and override  
AbstractJAXBProvider.convertToJaxbElemenIfNeeded() and implement it the way
it's done on the trunk [1]. 

let me know please how it goes

cheers, SErgey 

[1]
http://svn.apache.org/repos/asf/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/AbstractJAXBProvider.java


KARR, DAVID (ATTCINW) wrote:
> 
> I noticed in the following thread
> <http://www.mail-archive.com/users@cxf.apache.org/msg09175.html> that
> there are some changes in the trunk to allow JAXBElementProvider to have
> a "jaxbElementClassMap" property, which will allow me to bind my REST
> services to classes I don't control (or are generated), so I can't add
> "@XmlRootElement" to them.  Sergey mentioned in that thread that it
> would be straightforward to build that JAXBElementProvider before the
> next release it's available in.  Would that be possible?
> 
> 

-- 
View this message in context: http://www.nabble.com/Need-help-writing-JAXBElementProvider-that-uses-%22jaxbElementClassMap%22-tp25303787p25312013.html
Sent from the cxf-user mailing list archive at Nabble.com.