Hi Kl,

Thanks for this detailed analysis. For my example project I decided to get
out Jersey just to avoid side effects and for making progress with my
original task which is CXF support for odata4j.

Usually there is no deploy scenario using CXF and Jersey at the same time.
With that it is not a show stopper.

For mid or longterm it would anyhow nice to get both implementations
running at the same time. odata4j has a huge test suite (several hundred
test cases) and it would be useful to mix up Jersey and CXF client and
server in any combination.

Regards,
Stephan


-----Original Message-----
From: K Fung <[email protected]>
Reply-To: "[email protected]" <[email protected]>
Date: Tue, 31 Jan 2012 03:26:57 +0100
To: "[email protected]" <[email protected]>
Subject: Re: Jersey / CXF compatibility

>Hi Stephan,
>
>(this e-mail is based off revision 14 of your source code, da71e69dfdcd)
>
>I have some good news and bad news. The good news is that I have a
>workaround that can make all of your parameterized tests pass. The bad
>news
>is that CXF and Jersey binaries are indeed getting mixed up when you run
>these tests.
>
>For the workaround, In JerseyTestClient, change your getResource method so
>that it looks like the following:
>
>  public String getResource(URI uri) {
>    JerseyTestClient.LOGGER.debug("getResource(), uri = " + uri);
>    WebResource webResource = new Client().resource(uri);
>    return webResource.accept(MediaType.WILDCARD_TYPE).get(String.class);
>  }
>
>By sending an explicit Accept header, this will block HttpUrlConnection
>from sending an invalid header to CXF. CXF was (correctly!) spitting out a
>406 when the HttpUrlConnection was sending:
>
>text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2
>
>(I'm not sure why HttpUrlConnection was sending this invalid accept. I
>didn't drill down into this too deeply. Perhaps the JDK team can tell us
>why).
>
>This would obviously imply that your test clients should always be sending
>an Accept header but this shouldn't be too much of a burden for you (and
>it
>seems you've already done it in the latest version of CxfTestClient).
>
>Nevertheless, as I feared, CXF and Jersey code are getting mixed up on the
>server-side. You can see this in the stack:
>
>012-01-30 17:40:18,785 DEBUG [qtp525030058-29]
>org.apache.cxf.phase.PhaseInterceptorChain: Invoking handleMessage on
>interceptor org.apache.cxf.jaxrs.interceptor.JAXRSInInterceptor@1ff61bcf
>java.lang.IllegalArgumentException: Error parsing media type '*; q=.2'
>at
>com.sun.jersey.core.impl.provider.header.MediaTypeProvider.fromString(Medi
>aTypeProvider.java:77)
> at
>com.sun.jersey.core.impl.provider.header.MediaTypeProvider.fromString(Medi
>aTypeProvider.java:50)
>at javax.ws.rs.core.MediaType.valueOf(MediaType.java:119)
> at
>org.apache.cxf.jaxrs.utils.JAXRSUtils.parseMediaTypes(JAXRSUtils.java:1097
>)
>at
>org.apache.cxf.jaxrs.utils.JAXRSUtils.sortMediaTypes(JAXRSUtils.java:1189)
> at
>org.apache.cxf.jaxrs.interceptor.JAXRSInInterceptor.processRequest(JAXRSIn
>Interceptor.java:136)
>at
>org.apache.cxf.jaxrs.interceptor.JAXRSInInterceptor.handleMessage(JAXRSInI
>nterceptor.java:88)
> at
>org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorCha
>in.java:263)
>at
>org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiation
>Observer.java:123)
> at
>org.apache.cxf.transport.http.AbstractHTTPDestination.invoke(AbstractHTTPD
>estination.java:206)
>at
>org.apache.cxf.transport.servlet.ServletController.invokeDestination(Servl
>etController.java:213)
> at
>org.apache.cxf.transport.servlet.ServletController.invoke(ServletControlle
>r.java:154)
>at
>org.apache.cxf.transport.servlet.CXFNonSpringServlet.invoke(CXFNonSpringSe
>rvlet.java:126)
> at
>org.apache.cxf.transport.servlet.AbstractHTTPServlet.handleRequest(Abstrac
>tHTTPServlet.java:184)
>at
>org.apache.cxf.transport.servlet.AbstractHTTPServlet.doGet(AbstractHTTPSer
>vlet.java:112)
> at javax.servlet.http.HttpServlet.service(HttpServlet.java:693)
>at
>org.apache.cxf.transport.servlet.AbstractHTTPServlet.service(AbstractHTTPS
>ervlet.java:163)
> at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:538)
>at
>org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:478)
> at
>org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.ja
>va:225)
>at
>org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.ja
>va:940)
> at
>org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:406)
>at
>org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.jav
>a:186)
> at
>org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.jav
>a:874)
>at
>org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:1
>17)
> at
>org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollectio
>n.java:149)
>at
>org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java
>:110)
> at org.eclipse.jetty.server.Server.handle(Server.java:349)
>at
>org.eclipse.jetty.server.HttpConnection.handleRequest(HttpConnection.java:
>441)
> at
>org.eclipse.jetty.server.HttpConnection$RequestHandler.headerComplete(Http
>Connection.java:919)
>at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:582)
> at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:218)
>at
>org.eclipse.jetty.server.AsyncHttpConnection.handle(AsyncHttpConnection.ja
>va:52)
> at
>org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(SelectChannelEndPoin
>t.java:586)
>at
>org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run(SelectChannelEndPoint
>.java:44)
> at
>org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.jav
>a:598)
>at
>org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java
>:533)
> at java.lang.Thread.run(Thread.java:662)
>Caused by: java.text.ParseException: Expected separator '/' instead of ';'
>at
>com.sun.jersey.core.header.reader.HttpHeaderReader.nextSeparator(HttpHeade
>rReader.java:112)
> at
>com.sun.jersey.core.impl.provider.header.MediaTypeProvider.valueOf(MediaTy
>peProvider.java:88)
>at
>com.sun.jersey.core.impl.provider.header.MediaTypeProvider.fromString(Medi
>aTypeProvider.java:75)
> ... 37 more
>
>Regards,
>kl
>
>P.S. I assume you deliberately wanted a Jersey client to connect to a CXF
>server.

Reply via email to