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" <dk...@att.com> on 2012/11/26 19:54:52 UTC

Suddenly getting "class ... nor any of its super class is known to this context" for existing code

Using CXF 2.5.1.

I have an existing REST server that had two controllers with a handful of simple GET services.  In the last few days I added a third controller with a simple service.  I verified that was working, but I'm not sure if I tried the two existing services at the time.

Today I made some additional minor changes to the third service and verified it was ok.  I then discovered that one of the original two services is now failing with an error like this (the other original service is fine):

WARNING: javax.xml.bind.JAXBException: class <foo> nor any of its super class is known to this context.
	at com.sun.xml.bind.v2.runtime.JAXBContextImpl.getBeanInfo(JAXBContextImpl.java:596)
	at com.sun.xml.bind.v2.runtime.XMLSerializer.childAsRoot(XMLSerializer.java:482)
	at com.sun.xml.bind.v2.runtime.MarshallerImpl.write(MarshallerImpl.java:315)

As far as I can tell, nothing obvious has changed in that controller or the classes that it uses.  I verified that class "foo" hasn't changed and is still in the deployed WAR file.  I turned on "-verbose:class" and when my test ran I found the "Loaded" message for that specific class.

My controllers are very simple.  The controller method in question just returns an instance of "foo".

What might I be doing wrong?  Remember that this service has been working fine.  I haven't changed it.  I must have changed something associated with it that is causing an unexpected side effect.

RE: Suddenly getting "class ... nor any of its super class is known to this context" for existing code

Posted by "KARR, DAVID" <dk...@att.com>.
> -----Original Message-----
> From: Sergey Beryozkin [mailto:sberyozkin@gmail.com]
> Sent: Monday, November 26, 2012 11:51 AM
> To: users@cxf.apache.org
> Subject: Re: Suddenly getting "class ... nor any of its super class is
> known to this context" for existing code
> 
> On 26/11/12 19:47, KARR, DAVID wrote:
> >> -----Original Message-----
> >> From: KARR, DAVID
> >> Sent: Monday, November 26, 2012 10:55 AM
> >> To: users@cxf.apache.org
> >> Subject: Suddenly getting "class ... nor any of its super class is
> >> known to this context" for existing code
> >>
> >> Using CXF 2.5.1.
> >>
> >> I have an existing REST server that had two controllers with a
> handful
> >> of simple GET services.  In the last few days I added a third
> >> controller with a simple service.  I verified that was working, but
> I'm
> >> not sure if I tried the two existing services at the time.
> >>
> >> Today I made some additional minor changes to the third service and
> >> verified it was ok.  I then discovered that one of the original two
> >> services is now failing with an error like this (the other original
> >> service is fine):
> >>
> >> WARNING: javax.xml.bind.JAXBException: class<foo>  nor any of its
> super
> >> class is known to this context.
> >
> > I discovered the need to create a JAXBElementProvider, but this is
> only fixing this for XML responses.  If I make it generate JSON, I
> still get that error.  I have an instance of
> "org.apache.cxf.jaxrs.provider.JSONProvider" specified already.  Is
> there something additional I have to add to it to get it to work with
> JSON?
> I'm assuming you are configuring JAXBElementProvider to treat 'foo' as
> JAXBElement or set some other property which can help the provider
> marshall it ? If yes, then the same property can be most likely set on
> JSONProvider which shares the same common code with JAXBElementProvider

If I understand you correctly, I added the "extraClass" property to my JSON provider, and the two beans now look like the following.  Unfortunately, this didn't help.  XML output works fine, JSON gets the error.

    <bean id="jaxbElementProvider" class="org.apache.cxf.jaxrs.provider.JAXBElementProvider" p:singleJaxbContext="true">
        <property name="extraClass">
            <list>
                <value>....Foo</value>
                <value>...OtherFoo</value>
                <value>...AnotherFoo</value>
            </list>
        </property>
    </bean>
    
    <bean id="jsonProvider" class="org.apache.cxf.jaxrs.provider.JSONProvider">
        <property name="serializeAsArray" value="true"/>
        <property name="arrayKeys">
            <list>
                <value>...</value>
                <value>...</value>
		...
            </list>
        </property>
        <property name="namespaceMap">
            <map>
                <entry key=".../schema/fooSchema/v1.0" value="sl"/>
                <entry key=".../schema/otherFooSchema/v1.0" value="sar"/>
                <entry key=".../schema/anotherFooSchema/v1.0" value="dss"/>
            </map>
        </property>
        <property name="extraClass">
            <list>
                <value>....Foo</value>
                <value>...OtherFoo</value>
                <value>...AnotherFoo</value>
            </list>
        </property>
    </bean>

RE: Suddenly getting "class ... nor any of its super class is known to this context" for existing code

Posted by "KARR, DAVID" <dk...@att.com>.
> -----Original Message-----
> From: Sergey Beryozkin [mailto:sberyozkin@gmail.com]
> Sent: Tuesday, November 27, 2012 8:27 AM
> To: users@cxf.apache.org
> Subject: Re: Suddenly getting "class ... nor any of its super class is
> known to this context" for existing code
> 
> On 27/11/12 16:09, KARR, DAVID wrote:
> >> -----Original Message-----
> >> From: Sergey Beryozkin [mailto:sberyozkin@gmail.com]
> >> Sent: Monday, November 26, 2012 11:51 AM
> >> To: users@cxf.apache.org
> >> Subject: Re: Suddenly getting "class ... nor any of its super class
> is
> >> known to this context" for existing code
> >>
> >> On 26/11/12 19:47, KARR, DAVID wrote:
> >>>> -----Original Message-----
> >>>> From: KARR, DAVID
> >>>> Sent: Monday, November 26, 2012 10:55 AM
> >>>> To: users@cxf.apache.org
> >>>> Subject: Suddenly getting "class ... nor any of its super class is
> >>>> known to this context" for existing code
> >>>>
> >>>> Using CXF 2.5.1.
> >>>>
> >>>> I have an existing REST server that had two controllers with a
> >> handful
> >>>> of simple GET services.  In the last few days I added a third
> >>>> controller with a simple service.  I verified that was working,
> but
> >> I'm
> >>>> not sure if I tried the two existing services at the time.
> >>>>
> >>>> Today I made some additional minor changes to the third service
> and
> >>>> verified it was ok.  I then discovered that one of the original
> two
> >>>> services is now failing with an error like this (the other
> original
> >>>> service is fine):
> >>>>
> >>>> WARNING: javax.xml.bind.JAXBException: class<foo>   nor any of its
> >> super
> >>>> class is known to this context.
> >>>
> >>> I discovered the need to create a JAXBElementProvider, but this is
> >> only fixing this for XML responses.  If I make it generate JSON, I
> >> still get that error.  I have an instance of
> >> "org.apache.cxf.jaxrs.provider.JSONProvider" specified already.  Is
> >> there something additional I have to add to it to get it to work
> with
> >> JSON?
> >> I'm assuming you are configuring JAXBElementProvider to treat 'foo'
> as
> >> JAXBElement or set some other property which can help the provider
> >> marshall it ? If yes, then the same property can be most likely set
> on
> >> JSONProvider which shares the same common code with
> JAXBElementProvider
> >
> > This fixed the problem.  I set both the "extraClass" and
> "singleJaxbContext" properties on the JSONProvider bean.
> >
> 
> Thanks for the confirmation David, I was still thinking of trying to
> reproduce the issue with JSONProvider somehow :-)

Me too.  I don't understand why I didn't need this from the start.  Some obscure transition made those classes not being included by default.

Re: Suddenly getting "class ... nor any of its super class is known to this context" for existing code

Posted by Sergey Beryozkin <sb...@gmail.com>.
On 27/11/12 16:09, KARR, DAVID wrote:
>> -----Original Message-----
>> From: Sergey Beryozkin [mailto:sberyozkin@gmail.com]
>> Sent: Monday, November 26, 2012 11:51 AM
>> To: users@cxf.apache.org
>> Subject: Re: Suddenly getting "class ... nor any of its super class is
>> known to this context" for existing code
>>
>> On 26/11/12 19:47, KARR, DAVID wrote:
>>>> -----Original Message-----
>>>> From: KARR, DAVID
>>>> Sent: Monday, November 26, 2012 10:55 AM
>>>> To: users@cxf.apache.org
>>>> Subject: Suddenly getting "class ... nor any of its super class is
>>>> known to this context" for existing code
>>>>
>>>> Using CXF 2.5.1.
>>>>
>>>> I have an existing REST server that had two controllers with a
>> handful
>>>> of simple GET services.  In the last few days I added a third
>>>> controller with a simple service.  I verified that was working, but
>> I'm
>>>> not sure if I tried the two existing services at the time.
>>>>
>>>> Today I made some additional minor changes to the third service and
>>>> verified it was ok.  I then discovered that one of the original two
>>>> services is now failing with an error like this (the other original
>>>> service is fine):
>>>>
>>>> WARNING: javax.xml.bind.JAXBException: class<foo>   nor any of its
>> super
>>>> class is known to this context.
>>>
>>> I discovered the need to create a JAXBElementProvider, but this is
>> only fixing this for XML responses.  If I make it generate JSON, I
>> still get that error.  I have an instance of
>> "org.apache.cxf.jaxrs.provider.JSONProvider" specified already.  Is
>> there something additional I have to add to it to get it to work with
>> JSON?
>> I'm assuming you are configuring JAXBElementProvider to treat 'foo' as
>> JAXBElement or set some other property which can help the provider
>> marshall it ? If yes, then the same property can be most likely set on
>> JSONProvider which shares the same common code with JAXBElementProvider
>
> This fixed the problem.  I set both the "extraClass" and "singleJaxbContext" properties on the JSONProvider bean.
>

Thanks for the confirmation David, I was still thinking of trying to 
reproduce the issue with JSONProvider somehow :-)

Cheers, Sergey

RE: Suddenly getting "class ... nor any of its super class is known to this context" for existing code

Posted by "KARR, DAVID" <dk...@att.com>.
> -----Original Message-----
> From: Sergey Beryozkin [mailto:sberyozkin@gmail.com]
> Sent: Monday, November 26, 2012 11:51 AM
> To: users@cxf.apache.org
> Subject: Re: Suddenly getting "class ... nor any of its super class is
> known to this context" for existing code
> 
> On 26/11/12 19:47, KARR, DAVID wrote:
> >> -----Original Message-----
> >> From: KARR, DAVID
> >> Sent: Monday, November 26, 2012 10:55 AM
> >> To: users@cxf.apache.org
> >> Subject: Suddenly getting "class ... nor any of its super class is
> >> known to this context" for existing code
> >>
> >> Using CXF 2.5.1.
> >>
> >> I have an existing REST server that had two controllers with a
> handful
> >> of simple GET services.  In the last few days I added a third
> >> controller with a simple service.  I verified that was working, but
> I'm
> >> not sure if I tried the two existing services at the time.
> >>
> >> Today I made some additional minor changes to the third service and
> >> verified it was ok.  I then discovered that one of the original two
> >> services is now failing with an error like this (the other original
> >> service is fine):
> >>
> >> WARNING: javax.xml.bind.JAXBException: class<foo>  nor any of its
> super
> >> class is known to this context.
> >
> > I discovered the need to create a JAXBElementProvider, but this is
> only fixing this for XML responses.  If I make it generate JSON, I
> still get that error.  I have an instance of
> "org.apache.cxf.jaxrs.provider.JSONProvider" specified already.  Is
> there something additional I have to add to it to get it to work with
> JSON?
> I'm assuming you are configuring JAXBElementProvider to treat 'foo' as
> JAXBElement or set some other property which can help the provider
> marshall it ? If yes, then the same property can be most likely set on
> JSONProvider which shares the same common code with JAXBElementProvider

This fixed the problem.  I set both the "extraClass" and "singleJaxbContext" properties on the JSONProvider bean.


Re: Suddenly getting "class ... nor any of its super class is known to this context" for existing code

Posted by Sergey Beryozkin <sb...@gmail.com>.
On 26/11/12 19:47, KARR, DAVID wrote:
>> -----Original Message-----
>> From: KARR, DAVID
>> Sent: Monday, November 26, 2012 10:55 AM
>> To: users@cxf.apache.org
>> Subject: Suddenly getting "class ... nor any of its super class is
>> known to this context" for existing code
>>
>> Using CXF 2.5.1.
>>
>> I have an existing REST server that had two controllers with a handful
>> of simple GET services.  In the last few days I added a third
>> controller with a simple service.  I verified that was working, but I'm
>> not sure if I tried the two existing services at the time.
>>
>> Today I made some additional minor changes to the third service and
>> verified it was ok.  I then discovered that one of the original two
>> services is now failing with an error like this (the other original
>> service is fine):
>>
>> WARNING: javax.xml.bind.JAXBException: class<foo>  nor any of its super
>> class is known to this context.
>
> I discovered the need to create a JAXBElementProvider, but this is only fixing this for XML responses.  If I make it generate JSON, I still get that error.  I have an instance of "org.apache.cxf.jaxrs.provider.JSONProvider" specified already.  Is there something additional I have to add to it to get it to work with JSON?
I'm assuming you are configuring JAXBElementProvider to treat 'foo' as 
JAXBElement or set some other property which can help the provider 
marshall it ? If yes, then the same property can be most likely set on 
JSONProvider which shares the same common code with JAXBElementProvider

Cheers, Sergey

RE: Suddenly getting "class ... nor any of its super class is known to this context" for existing code

Posted by "KARR, DAVID" <dk...@att.com>.
> -----Original Message-----
> From: KARR, DAVID
> Sent: Monday, November 26, 2012 10:55 AM
> To: users@cxf.apache.org
> Subject: Suddenly getting "class ... nor any of its super class is
> known to this context" for existing code
> 
> Using CXF 2.5.1.
> 
> I have an existing REST server that had two controllers with a handful
> of simple GET services.  In the last few days I added a third
> controller with a simple service.  I verified that was working, but I'm
> not sure if I tried the two existing services at the time.
> 
> Today I made some additional minor changes to the third service and
> verified it was ok.  I then discovered that one of the original two
> services is now failing with an error like this (the other original
> service is fine):
> 
> WARNING: javax.xml.bind.JAXBException: class <foo> nor any of its super
> class is known to this context.

I discovered the need to create a JAXBElementProvider, but this is only fixing this for XML responses.  If I make it generate JSON, I still get that error.  I have an instance of "org.apache.cxf.jaxrs.provider.JSONProvider" specified already.  Is there something additional I have to add to it to get it to work with JSON?

Re: Suddenly getting "class ... nor any of its super class is known to this context" for existing code

Posted by Sergey Beryozkin <sb...@gmail.com>.
Hi David
On 26/11/12 18:54, KARR, DAVID wrote:
> Using CXF 2.5.1.
>
> I have an existing REST server that had two controllers with a handful of simple GET services.  In the last few days I added a third controller with a simple service.  I verified that was working, but I'm not sure if I tried the two existing services at the time.
>
> Today I made some additional minor changes to the third service and verified it was ok.  I then discovered that one of the original two services is now failing with an error like this (the other original service is fine):
>
> WARNING: javax.xml.bind.JAXBException: class<foo>  nor any of its super class is known to this context.
> 	at com.sun.xml.bind.v2.runtime.JAXBContextImpl.getBeanInfo(JAXBContextImpl.java:596)
> 	at com.sun.xml.bind.v2.runtime.XMLSerializer.childAsRoot(XMLSerializer.java:482)
> 	at com.sun.xml.bind.v2.runtime.MarshallerImpl.write(MarshallerImpl.java:315)
>
> As far as I can tell, nothing obvious has changed in that controller or the classes that it uses.  I verified that class "foo" hasn't changed and is still in the deployed WAR file.  I turned on "-verbose:class" and when my test ran I found the "Loaded" message for that specific class.
>
> My controllers are very simple.  The controller method in question just returns an instance of "foo".
>
> What might I be doing wrong?  Remember that this service has been working fine.  I haven't changed it.  I must have changed something associated with it that is causing an unexpected side effect.
It is difficult to advice something...If you can send me some test 
project helping to reproduce the issue then I can have a look.
Does it work before a 3rd controller has been introduced - I'm assuming 
yes ?

Thanks, Sergey