Here is the whole stack trace. So this is with 2 pojo java beans that have the same @XmlRootElement
2014-07-28 14:38:53,564 DEBUG [RemoveTimeBasedEntitlementsExpiredService RUNNING] com.twc.ctg.ecp.service.app.metric.MetricsTimers - registered new timer in metrics registry 2014-07-28 14:38:53,566 DEBUG [RemoveTimeBasedEntitlementsExpiredService RUNNING] com.twc.ctg.ecp.persistence.mappers.TimeBasedEntitlementBatchMapper.deleteTimeBasedEntitlementExpired - ooo Using Connection [ProxyConnection[PooledConnection[oracle.jdbc.driver.T4CConnection@2ebc1316 ]]] 2014-07-28 14:38:53,566 DEBUG [RemoveTimeBasedEntitlementsExpiredService RUNNING] com.twc.ctg.ecp.persistence.mappers.TimeBasedEntitlementBatchMapper.deleteTimeBasedEntitlementExpired - ==> Preparing: delete from time_based_entitlement tbe where tbe.viewing_period_end < ? 2014-07-28 14:38:53,568 DEBUG [RemoveTimeBasedEntitlementsExpiredService RUNNING] com.twc.ctg.ecp.persistence.mappers.TimeBasedEntitlementBatchMapper.deleteTimeBasedEntitlementExpired - ==> Parameters: 1406579903564(Long) 2014-07-28 14:38:53,570 DEBUG [RemoveTimeBasedEntitlementsExpiredService RUNNING] com.twc.ctg.ecp.service.services.RemoveTimeBasedEntitlementsExpiredService - RemoveTimeBasedEntitlementsExpiredService runOneIteration end 2014-07-28 14:38:55,387 INFO [qtp1312169486-231] org.apache.cxf.interceptor.LoggingInInterceptor - Inbound Message ---------------------------- ID: 2 Address: http://localhost:8877/ecp/contentdirect/v1/entitlement Encoding: ISO-8859-1 Http-Method: POST Content-Type: application/xml Headers: {accept-encoding=[gzip,deflate], ClientMessageId=[clientmessageid], connection=[keep-alive], Content-Length=[393], content-type=[application/xml], CorrelationId=[correlationid], CustomerIp=[10.254.222.222], Host=[localhost:8877], User-Agent=[Apache-HttpClient/4.1.1 (java 1.5)]} Payload: <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <Order> <ViewingPeriodStart>1689848400000</ViewingPeriodStart> <ViewingPeriodEnd>1691489999000</ViewingPeriodEnd> <DivisionId>NYC.8150</DivisionId> <MasId>NYC</MasId> <AccountNumber>8150100040000039</AccountNumber> <ResourceId>IND_LIBRARY::INMV0114000007009062</ResourceId> <OrderId>fjeo48kgjuuroh</OrderId> </Order> -------------------------------------- 2014-07-28 14:38:55,439 WARN [qtp1312169486-231] org.apache.cxf.jaxrs.provider.AbstractJAXBProvider - java.lang.ClassCastException: Cannot cast com.twc.ctg.ecp.model.csg.CsgEntitlementBase to com.twc.ctg.ecp.model.csg.CsgEntitlement at java.lang.Class.cast(Class.java:3094) at org.apache.cxf.jaxrs.provider.JAXBElementProvider.readFrom(JAXBElementProvider.java:203) at org.apache.cxf.jaxrs.utils.JAXRSUtils.readFromMessageBodyReader(JAXRSUtils.java:1325) at org.apache.cxf.jaxrs.utils.JAXRSUtils.readFromMessageBody(JAXRSUtils.java:1276) at org.apache.cxf.jaxrs.utils.JAXRSUtils.processParameter(JAXRSUtils.java:815) at org.apache.cxf.jaxrs.utils.JAXRSUtils.processParameters(JAXRSUtils.java:778) at org.apache.cxf.jaxrs.interceptor.JAXRSInInterceptor.processRequest(JAXRSInInterceptor.java:212) at org.apache.cxf.jaxrs.interceptor.JAXRSInInterceptor.handleMessage(JAXRSInInterceptor.java:76) at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:307) at org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:121) at org.apache.cxf.transport.http.AbstractHTTPDestination.invoke(AbstractHTTPDestination.java:243) at org.apache.cxf.transport.http_jetty.JettyHTTPDestination.doService(JettyHTTPDestination.java:259) at org.apache.cxf.transport.http_jetty.JettyHTTPHandler.handle(JettyHTTPHandler.java:65) at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1088) at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1024) at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:135) at org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:255) at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:116) at org.eclipse.jetty.server.Server.handle(Server.java:370) at org.eclipse.jetty.server.AbstractHttpConnection.handleRequest(AbstractHttpConnection.java:494) at org.eclipse.jetty.server.AbstractHttpConnection.content(AbstractHttpConnection.java:982) at org.eclipse.jetty.server.AbstractHttpConnection$RequestHandler.content(AbstractHttpConnection.java:1043) at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:865) at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:240) at org.eclipse.jetty.server.AsyncHttpConnection.handle(AsyncHttpConnection.java:82) at org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(SelectChannelEndPoint.java:696) at org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run(SelectChannelEndPoint.java:53) at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:608) at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:543) at java.lang.Thread.run(Thread.java:744) 2014-07-28 14:38:55,445 WARN [qtp1312169486-231] org.apache.cxf.jaxrs.impl.WebApplicationExceptionMapper - javax.ws.rs.BadRequestException: HTTP 400 Bad Request at org.apache.cxf.jaxrs.utils.SpecExceptions.toBadRequestException(SpecExceptions.java:84) at org.apache.cxf.jaxrs.utils.ExceptionUtils.toBadRequestException(ExceptionUtils.java:109) at org.apache.cxf.jaxrs.provider.JAXBElementProvider.readFrom(JAXBElementProvider.java:213) at org.apache.cxf.jaxrs.utils.JAXRSUtils.readFromMessageBodyReader(JAXRSUtils.java:1325) at org.apache.cxf.jaxrs.utils.JAXRSUtils.readFromMessageBody(JAXRSUtils.java:1276) at org.apache.cxf.jaxrs.utils.JAXRSUtils.processParameter(JAXRSUtils.java:815) at org.apache.cxf.jaxrs.utils.JAXRSUtils.processParameters(JAXRSUtils.java:778) at org.apache.cxf.jaxrs.interceptor.JAXRSInInterceptor.processRequest(JAXRSInInterceptor.java:212) at org.apache.cxf.jaxrs.interceptor.JAXRSInInterceptor.handleMessage(JAXRSInInterceptor.java:76) at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:307) at org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:121) at org.apache.cxf.transport.http.AbstractHTTPDestination.invoke(AbstractHTTPDestination.java:243) at org.apache.cxf.transport.http_jetty.JettyHTTPDestination.doService(JettyHTTPDestination.java:259) at org.apache.cxf.transport.http_jetty.JettyHTTPHandler.handle(JettyHTTPHandler.java:65) at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1088) at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1024) at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:135) at org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:255) at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:116) at org.eclipse.jetty.server.Server.handle(Server.java:370) at org.eclipse.jetty.server.AbstractHttpConnection.handleRequest(AbstractHttpConnection.java:494) at org.eclipse.jetty.server.AbstractHttpConnection.content(AbstractHttpConnection.java:982) at org.eclipse.jetty.server.AbstractHttpConnection$RequestHandler.content(AbstractHttpConnection.java:1043) at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:865) at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:240) at org.eclipse.jetty.server.AsyncHttpConnection.handle(AsyncHttpConnection.java:82) at org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(SelectChannelEndPoint.java:696) at org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run(SelectChannelEndPoint.java:53) at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:608) at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:543) at java.lang.Thread.run(Thread.java:744) Caused by: java.lang.ClassCastException: Cannot cast com.twc.ctg.ecp.model.csg.CsgEntitlementBase to com.twc.ctg.ecp.model.csg.CsgEntitlement at java.lang.Class.cast(Class.java:3094) at org.apache.cxf.jaxrs.provider.JAXBElementProvider.readFrom(JAXBElementProvider.java:203) ... 28 more 2014-07-28 14:38:55,446 INFO [qtp1312169486-231] org.apache.cxf.interceptor.LoggingOutInterceptor - Outbound Message --------------------------- ID: 2 Response-Code: 400 Content-Type: Headers: {Date=[Mon, 28 Jul 2014 20:38:55 GMT], Content-Length=[0]} On Mon, Jul 28, 2014 at 1:43 PM, Sergey Beryozkin [via CXF] < [email protected]> wrote: > Hi > On 27/07/14 22:44, javaworkinggirl wrote: > > 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 > > > > Where is this exception coming from ? Can you provide more info if it is > coming from CXF ? > > Cheers, Sergey > > > 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] < > > [hidden email] <http://user/SendEmail.jtp?type=node&node=5747001&i=0>> > 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 > >> < > > >> . > >> 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. > > > > > -- > Sergey Beryozkin > > Talend Community Coders > http://coders.talend.com/ > > Blog: http://sberyozkin.blogspot.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-tp5746953p5747001.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-tp5746953p5747003.html Sent from the cxf-user mailing list archive at Nabble.com.
