> -----Original Message-----
> From: Sergey Beryozkin [mailto:[email protected]]
> Sent: Monday, November 26, 2012 11:51 AM
> To: [email protected]
> 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: [email protected]
> >> 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>