Yes this error has to do with the changes I made  to use jsr-303 bean
validation.
ERROR:
java.lang.ClassCastException: Cannot cast
com.twc.ctg.ecp.model.csg.CsgEntitlementBase to
com.twc.ctg.ecp.model.csg.CsgEntitlement

Originally, before bean validation additions, we had one class that had 7
fields.  on a PUT only 5 were required, on a POST 2 additional (total of
 7) are required.  We did the validation manually in the rest service.
 This worked for json and xml.

Then I upgraded to cxf 3.0.0 to use Bean Validation.  I ended up spliting
the class into 2, one was the base had 5 required fields (for the PUT).
 Next class inherited from the base class and added the 2 other fields.
 BOTH classes have the same @XmlRootElement (our client wants it this way).
 I was getting a class cast exception when trying the xml request.  It
worked OK for json.

So is it that the marshaller doesn't like having the same @XmlRootElement
for 2 classes?

What is a better solution for this situation?


On Sun, Jul 27, 2014 at 12:42 PM, Sergey Beryozkin [via CXF] <
[email protected]> wrote:

> Hi
>
> It may be the validation related issue. Can you disable the validation
> and retry ?
>
> Sergey
> On 26/07/14 07:43, javaworkinggirl wrote:
>
> > Hi.
> >
> > I upgraded to cxf 3.0.0 and now my REST service works fine with json but
> > returns 400 bad request with xml.  Same test with xml and json on my
> > previous system with cxf 2.7.6 passes.
> >
> > What could I be missing?  Are there more/different .jars that need to be
> > included? Does an xml provider need to be specified?  Something else?
> >
> > Thanks.
> >
> > Response:
> > HTTP/1.1 400 Bad Request
> > Content-Length: 0
> > Date: Sat, 26 Jul 2014 04:37:21 GMT
> > Server: Jetty(8.1.15.v20140411)
> >
> >
> > pom.xml:
> >     <dependency>
> >              <groupId>org.apache.cxf</groupId>
> >              <artifactId>cxf-rt-frontend-jaxrs</artifactId>
> >              <version>${apacheCxfVersion}</version>
> >           </dependency>
> >           <dependency>
> >              <groupId>org.apache.cxf</groupId>
> >              <artifactId>cxf-rt-frontend-jaxws</artifactId>
> >              <version>${apacheCxfVersion}</version>
> >           </dependency>
> >           <dependency>
> >              <groupId>org.apache.cxf</groupId>
> >              <artifactId>cxf-rt-transports-http-jetty</artifactId>
> >              <version>${apacheCxfVersion}</version>
> >           </dependency>
> >
> >           <dependency>
> >              <groupId>org.apache.cxf</groupId>
> >              <artifactId>cxf-core</artifactId>
> >              <version>${apacheCxfVersion}</version>
> >              <exclusions>
> >                 <exclusion>
> >                    <groupId>commons-logging</groupId>
> >                    <artifactId>commons-logging</artifactId>
> >                 </exclusion>
> >              </exclusions>
> >           </dependency>
> >
> >          <dependency>
> >              <groupId>org.apache.cxf</groupId>
> >              <artifactId>cxf-rt-rs-client</artifactId>
> >              <version>${apacheCxfVersion}</version>
> >              <exclusions>
> >                 <exclusion>
> >                    <groupId>commons-logging</groupId>
> >                    <artifactId>commons-logging</artifactId>
> >                 </exclusion>
> >              </exclusions>
> >           </dependency>
> >
> > applicationContext.xml:
> >
> >        <jaxrs:server id="ecpWebServices"
> > basePackages="com.twc.ctg.ecp.service.rest.custom"
> > address="http://0.0.0.0:8877"; depends-on="activeMQConnectionFactory">
> >           <jaxrs:inInterceptors>
> >              <ref bean="validationInInterceptor"/>
> >           </jaxrs:inInterceptors>
> >           <jaxrs:outInterceptors>
> >              <ref bean="validationOutInterceptor"/>
> >           </jaxrs:outInterceptors>
> >           <jaxrs:serviceBeans>
> >              <ref bean="ecpAdminRestServiceV1"/>
> >              <ref bean="ecpApplicationRestServiceV1"/>
> >              <ref bean="ecpEntitlementRestServiceV1"/>
> >              <ref bean="ecpEntitlementRestServiceV2"/>
> >              <ref bean="ecpMetricsRestServiceV1"/>
> >              <ref bean="ecpAlertsRestServiceV1"/>
> >              <ref bean="ecpCDRestServiceV1"/>
> >           </jaxrs:serviceBeans>
> >           <jaxrs:providers>
> >              <bean
> > class="com.fasterxml.jackson.jaxrs.json.JacksonJaxbJsonProvider"/>
> >              <ref bean="genericRestExceptionMapper"/>
> >           </jaxrs:providers>
> >
> > REST service:
> >   @POST
> >     @Path("/entitlement")
> >     @Consumes({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
> >     @HeaderValidation
> >     @Valid
> >     public Response postEntitlement(@Context final HttpServletRequest
> > request, @NotNull @Valid final Entitlement Entitlement) throws
> > GenericRestException
> >     {
> > . . .
> > }
> >
> >
> >
> >
> > --
> > View this message in context:
> http://cxf.547215.n5.nabble.com/Upgraded-to-3-0-0-now-Rest-service-receiving-xml-give-400-Bad-request-tp5746953.html
> > Sent from the cxf-user mailing list archive at Nabble.com.
> >
>
>
>
> ------------------------------
>  If you reply to this email, your message will be added to the discussion
> below:
>
> http://cxf.547215.n5.nabble.com/Upgraded-to-3-0-0-now-Rest-service-receiving-xml-give-400-Bad-request-tp5746953p5746966.html
>  To unsubscribe from Upgraded to 3.0.0, now Rest service receiving xml
> give 400 Bad request, click here
> <http://cxf.547215.n5.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=5746953&code=amF2YXdvcmtpbmdnaXJsQGdtYWlsLmNvbXw1NzQ2OTUzfC0xMTE1Njg5NTY4>
> .
> NAML
> <http://cxf.547215.n5.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>
>




--
View this message in context: 
http://cxf.547215.n5.nabble.com/Upgraded-to-3-0-0-now-Rest-service-receiving-xml-give-400-Bad-request-tp5746953p5746967.html
Sent from the cxf-user mailing list archive at Nabble.com.

Reply via email to