Hi Sergey, I continue to see the problem with status 406. Is there a way to intercept this request before JAXRSInInterceptor, and change the ACCEPT header ?
Thanks for your help. On Thu, Jul 19, 2012 at 6:35 PM, java kurious <[email protected]> wrote: > Ok, I have the source code downloaded, and I have the glassfish running > from NetBeans. As you mentioned, I have left both cxf-bundle and > cxf-rt-frontend-jaxrs as dependencies. When both libraries are present, * > JAXRSInInterceptor.java* from cxf-rt-frontend-jaxrs gets called. I also > put breakpoints in MediaTypeHeaderProvider.java, but it does not seem to > get called. Here are the steps I followed to start debugging. > > > 1. > > Started the Glassfish in Debug mode. > 2. > > Issued a request to the REST service. > 3. > > The code stops at *JAXRSInInterceptor.java's **processRequest**(Message > msg) *method at following line:* * > > *try {* > > *acceptContentTypes = JAXRSUtils.sortMediaTypes(acceptTypes);* > > *} catch (IllegalArgumentException ex) {* > > *throw new WebApplicationException(406);* > > *}* > > The Accept header was [text/html, image/gif, image/jpeg, *; q=.2, */*; > q=.2]. > > > Let me know what specifically you want me to test. > > Thanks > Vineet. > > > On Thu, Jul 19, 2012 at 2:08 PM, Sergey Beryozkin <[email protected]>wrote: > >> I can see the test (based on the embedded jetty) working just fine: >> >> ID: 1 >> Address: >> http://localhost:9002/**bookstore/books/123<http://localhost:9002/bookstore/books/123> >> Http-Method: GET >> Content-Type: */* >> Headers: {Accept=[text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2], >> Cache-Control=[no-cache], connection=[keep-alive], content-type=[*/*], >> Host=[localhost:9002], Pragma=[no-cache], User-Agent=[Apache CXF >> ${project.version}]} >> >> and the response is getting is back... >> I wonder if Tomcat/Glassfish actually transforms the Accept values >> somehow afterwards, something subtle is causing the issue. >> >> Can you please help a bit with debugging it ? >> For a start you can probably drop either bundle or jaxrs frontend >> dependency, actually, do it after we sort out this issue :-) >> >> Can you download CXF 2.6.1 source: >> >> http://search.maven.org/**remotecontent?filepath=org/** >> apache/cxf/cxf-bundle/2.6.1/**cxf-bundle-2.6.1-sources.jar<http://search.maven.org/remotecontent?filepath=org/apache/cxf/cxf-bundle/2.6.1/cxf-bundle-2.6.1-sources.jar> >> >> and set a breakpoint in org.apache.cxf.jaxrs.impl.**MediaTypeHeaderProvider, >> after the endpoint starts and then invoke on it ? >> I wonder what woukd actually happen... >> >> Thanks, Sergey >> >> >> >> >> On 19/07/12 18:38, Sergey Beryozkin wrote: >> >>> Hi, >>> >>> Yes, I see now... >>> I have a few tests which seem to confirm it's been fixed, but I guess >>> the code dealing with this case is a bit brittle. >>> >>> I'll experiment a bit more and will get back to you >>> >>> Thanks, Sergey >>> >>> On 19/07/12 18:22, java kurious wrote: >>> >>>> Hi Sergey, >>>> >>>> I am implementing a REST web service using Camel and CXF. Following is >>>> the signature of the method. >>>> >>>> @GET >>>> @Path("/getCustomer") >>>> @Produces({"text/xml","text/**html","application/xml"}) >>>> public Customer getCustomer( >>>> @PathParam("name") String name) { >>>> } >>>> >>>> Now, I could test the interface with Firefotx with success. But when a >>>> >>>> different WebClient connected to the same interface, It got a Status 406 >>>> error. After looking at the log files, I noticed following in the >>>> server.log of glassfish. >>>> >>>> Accept=[text/html, image/gif, image/jpeg,*; q=.2, */*; q=.2], >>>> >>>> The single '*' is causing the problem. It is not an acceptable type to >>>> be specified as per the CXF user forum, >>>> http://cxf.547215.n5.nabble.**com/Jersey-CXF-compatibility-** >>>> td5437938.html<http://cxf.547215.n5.nabble.com/Jersey-CXF-compatibility-td5437938.html> >>>> . To recreate this problem with Firefox browser, I changed the header >>>> that Firefox was sending to match the above header, and Firefox also >>>> failed with the same error. Once I changed* to */* in Firefox, >>>> everything started working again. Unfortunately, I can't do that with >>>> the WebClient connecting to my interface, as the code is not available. >>>> >>>> In the same forum, >>>> http://cxf.547215.n5.nabble.**com/Jersey-CXF-compatibility-** >>>> td5437938.html<http://cxf.547215.n5.nabble.com/Jersey-CXF-compatibility-td5437938.html> >>>> , >>>> you had mentioned that this '*' issue should be fixed. So, my question >>>> was if this was indeed fixed. >>>> >>>> >>>> _Following is the trace I have from Glassfish Server log. _ >>>> >>>> INFO: DEBUG [http-thread-pool-8080(1)] (ServletController.java:209) - >>>> Service http request on thread: >>>> Thread[http-thread-pool-8080(**1),5,grizzly-kernel] >>>> >>>> INFO: DEBUG [http-thread-pool-8080(1)] >>>> (AbstractHTTPDestination.java:**192) - Create a new message for >>>> processing >>>> >>>> INFO: DEBUG [http-thread-pool-8080(1)] (Headers.java:347) - Request >>>> Headers: {Accept=[text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2], >>>> accept-charset=[ISO-8859-1,**utf-8;q=0.7,*;q=0.7], >>>> accept-encoding=[gzip,deflate]**, >>>> accept-language=[en,en-gb;q=0.**7,en-us;q=0.3], >>>> cache-control=[max-age=0], >>>> connection=[keep-alive], Content-Type=[null], host=[localhost:8080], >>>> keep-alive=[115], user-agent=[Mozilla/5.0 (X11; U; Linux i686; en-US; >>>> rv:1.9.2.16) Gecko/20110323 Ubuntu/10.04 (lucid) Firefox/3.6.16]} >>>> >>>> INFO: DEBUG [http-thread-pool-8080(1)] (PhaseInterceptorChain.java:** >>>> 205) >>>> - Adding interceptor >>>> org.apache.cxf.transport.**https.**CertConstraintsInterceptor@**f6c321 >>>> to >>>> phase pre-stream >>>> >>>> INFO: DEBUG [http-thread-pool-8080(1)] (PhaseInterceptorChain.java:** >>>> 674) >>>> - Chain org.apache.cxf.phase.**PhaseInterceptorChain@10a516f was >>>> created. >>>> Current flow: >>>> receive [PolicyInInterceptor] >>>> pre-stream [CertConstraintsInterceptor] >>>> unmarshal [JAXRSInInterceptor] >>>> pre-logical [OneWayProcessorInterceptor] >>>> invoke [ServiceInvokerInterceptor] >>>> post-invoke [OutgoingChainInterceptor] >>>> >>>> INFO: DEBUG [http-thread-pool-8080(1)] (PhaseInterceptorChain.java:** >>>> 259) >>>> - Invoking handleMessage on interceptor >>>> org.apache.cxf.ws.policy.**PolicyInInterceptor@1b7aa8e >>>> >>>> INFO: DEBUG [http-thread-pool-8080(1)] (PhaseInterceptorChain.java:** >>>> 259) >>>> - Invoking handleMessage on interceptor >>>> org.apache.cxf.transport.**https.**CertConstraintsInterceptor@**f6c321 >>>> >>>> INFO: DEBUG [http-thread-pool-8080(1)] (PhaseInterceptorChain.java:** >>>> 259) >>>> - Invoking handleMessage on interceptor >>>> org.apache.cxf.jaxrs.**interceptor.**JAXRSInInterceptor@2bc9ae >>>> >>>> INFO: DEBUG [http-thread-pool-8080(1)] >>>> (**WebApplicationExceptionMapper.**java:62) - WebApplicationException >>>> has >>>> been caught, status: 406 >>>> javax.ws.rs.**WebApplicationException >>>> at >>>> org.apache.cxf.jaxrs.**interceptor.**JAXRSInInterceptor.** >>>> processRequest(**JAXRSInInterceptor.java:139) >>>> >>>> at >>>> org.apache.cxf.jaxrs.**interceptor.**JAXRSInInterceptor.** >>>> handleMessage(**JAXRSInInterceptor.java:89) >>>> >>>> at >>>> org.apache.cxf.phase.**PhaseInterceptorChain.**doIntercept(** >>>> PhaseInterceptorChain.java:**262) >>>> >>>> at >>>> org.apache.cxf.transport.**ChainInitiationObserver.**onMessage(** >>>> ChainInitiationObserver.java:**123) >>>> >>>> at >>>> org.apache.cxf.transport.http.**AbstractHTTPDestination.**invoke(** >>>> AbstractHTTPDestination.java:**211) >>>> >>>> at >>>> org.apache.cxf.transport.**servlet.ServletController.** >>>> invokeDestination(**ServletController.java:213) >>>> >>>> at >>>> org.apache.cxf.transport.**servlet.ServletController.** >>>> invoke(ServletController.java:**154) >>>> >>>> at >>>> org.apache.cxf.transport.**servlet.CXFNonSpringServlet.** >>>> invoke(CXFNonSpringServlet.**java:129) >>>> >>>> at >>>> org.apache.cxf.transport.**servlet.AbstractHTTPServlet.**handleRequest( >>>> **AbstractHTTPServlet.java:187) >>>> >>>> at >>>> org.apache.cxf.transport.**servlet.AbstractHTTPServlet.** >>>> doGet(AbstractHTTPServlet.**java:115) >>>> >>>> at javax.servlet.http.**HttpServlet.service(**HttpServlet.java:668) >>>> at >>>> org.apache.cxf.transport.**servlet.AbstractHTTPServlet.** >>>> service(AbstractHTTPServlet.**java:166) >>>> >>>> at >>>> org.apache.catalina.core.**StandardWrapper.service(** >>>> StandardWrapper.java:1542) >>>> >>>> at >>>> org.apache.catalina.core.**StandardWrapperValve.invoke(** >>>> StandardWrapperValve.java:281) >>>> >>>> at >>>> org.apache.catalina.core.**StandardContextValve.invoke(** >>>> StandardContextValve.java:175) >>>> >>>> at >>>> org.apache.catalina.core.**StandardPipeline.doInvoke(** >>>> StandardPipeline.java:655) >>>> >>>> at >>>> org.apache.catalina.core.**StandardPipeline.invoke(** >>>> StandardPipeline.java:595) >>>> >>>> at >>>> org.apache.catalina.core.**StandardHostValve.invoke(** >>>> StandardHostValve.java:161) >>>> >>>> at >>>> org.apache.catalina.connector.**CoyoteAdapter.doService(** >>>> CoyoteAdapter.java:331) >>>> >>>> at >>>> org.apache.catalina.connector.**CoyoteAdapter.service(** >>>> CoyoteAdapter.java:231) >>>> >>>> at >>>> com.sun.enterprise.v3.**services.impl.ContainerMapper$** >>>> AdapterCallable.call(**ContainerMapper.java:317) >>>> >>>> at >>>> com.sun.enterprise.v3.**services.impl.ContainerMapper.** >>>> service(ContainerMapper.java:**195) >>>> >>>> at >>>> com.sun.grizzly.http.**ProcessorTask.invokeAdapter(** >>>> ProcessorTask.java:849) >>>> at com.sun.grizzly.http.**ProcessorTask.doProcess(** >>>> ProcessorTask.java:746) >>>> at com.sun.grizzly.http.**ProcessorTask.process(** >>>> ProcessorTask.java:1045) >>>> at >>>> com.sun.grizzly.http.**DefaultProtocolFilter.execute(** >>>> DefaultProtocolFilter.java:**228) >>>> >>>> at >>>> com.sun.grizzly.**DefaultProtocolChain.**executeProtocolFilter(** >>>> DefaultProtocolChain.java:137) >>>> >>>> at >>>> com.sun.grizzly.**DefaultProtocolChain.execute(** >>>> DefaultProtocolChain.java:104) >>>> >>>> at >>>> com.sun.grizzly.**DefaultProtocolChain.execute(** >>>> DefaultProtocolChain.java:90) >>>> >>>> at >>>> com.sun.grizzly.http.**HttpProtocolChain.execute(** >>>> HttpProtocolChain.java:79) >>>> at >>>> com.sun.grizzly.**ProtocolChainContextTask.**doCall(** >>>> ProtocolChainContextTask.java:**54) >>>> >>>> at >>>> com.sun.grizzly.**SelectionKeyContextTask.call(** >>>> SelectionKeyContextTask.java:**59) >>>> >>>> at com.sun.grizzly.ContextTask.**run(ContextTask.java:71) >>>> at >>>> com.sun.grizzly.util.**AbstractThreadPool$Worker.** >>>> doWork(AbstractThreadPool.**java:532) >>>> >>>> at >>>> com.sun.grizzly.util.**AbstractThreadPool$Worker.run(** >>>> AbstractThreadPool.java:513) >>>> >>>> at java.lang.Thread.run(Thread.**java:722) >>>> >>>> INFO: DEBUG [http-thread-pool-8080(1)] (PhaseInterceptorChain.java:** >>>> 259) >>>> - Invoking handleMessage on interceptor >>>> org.apache.cxf.interceptor.**OneWayProcessorInterceptor@**1823fd1 >>>> >>>> INFO: DEBUG [http-thread-pool-8080(1)] (PhaseInterceptorChain.java:** >>>> 259) >>>> - Invoking handleMessage on interceptor >>>> org.apache.cxf.interceptor.**ServiceInvokerInterceptor@**11e787e >>>> >>>> INFO: DEBUG [http-thread-pool-8080(1)] (PhaseInterceptorChain.java:** >>>> 259) >>>> - Invoking handleMessage on interceptor >>>> org.apache.cxf.interceptor.**OutgoingChainInterceptor@**178c3da >>>> >>>> INFO: DEBUG [http-thread-pool-8080(1)] >>>> (OutgoingChainInterceptor.**java:176) - Interceptors contributed by >>>> bus: >>>> [org.apache.cxf.ws.policy.**PolicyOutInterceptor@1351523] >>>> >>>> INFO: DEBUG [http-thread-pool-8080(1)] >>>> (OutgoingChainInterceptor.**java:180) - Interceptors contributed by >>>> service: [] >>>> >>>> INFO: DEBUG [http-thread-pool-8080(1)] >>>> (OutgoingChainInterceptor.**java:184) - Interceptors contributed by >>>> endpoint: [org.apache.cxf.interceptor.**MessageSenderInterceptor@** >>>> 1fec925] >>>> >>>> INFO: DEBUG [http-thread-pool-8080(1)] >>>> (OutgoingChainInterceptor.**java:190) - Interceptors contributed by >>>> binding: [org.apache.cxf.jaxrs.**interceptor.** >>>> JAXRSOutInterceptor@47dcc2] >>>> >>>> INFO: DEBUG [http-thread-pool-8080(1)] (PhaseInterceptorChain.java:** >>>> 674) >>>> - Chain org.apache.cxf.phase.**PhaseInterceptorChain@90d38 was created. >>>> Current flow: >>>> setup [PolicyOutInterceptor] >>>> prepare-send [MessageSenderInterceptor] >>>> marshal [JAXRSOutInterceptor] >>>> >>>> INFO: DEBUG [http-thread-pool-8080(1)] (PhaseInterceptorChain.java:** >>>> 259) >>>> - Invoking handleMessage on interceptor >>>> org.apache.cxf.ws.policy.**PolicyOutInterceptor@1351523 >>>> >>>> INFO: DEBUG [http-thread-pool-8080(1)] (PolicyOutInterceptor.java:63) - >>>> No binding operation info. >>>> >>>> INFO: DEBUG [http-thread-pool-8080(1)] (PhaseInterceptorChain.java:** >>>> 259) >>>> - Invoking handleMessage on interceptor >>>> org.apache.cxf.interceptor.**MessageSenderInterceptor@**1fec925 >>>> >>>> INFO: DEBUG [http-thread-pool-8080(1)] (PhaseInterceptorChain.java:** >>>> 205) >>>> - Adding interceptor >>>> org.apache.cxf.interceptor.**MessageSenderInterceptor$** >>>> MessageSenderEndingInterceptor**@9e362f >>>> >>>> to phase prepare-send-ending >>>> >>>> INFO: DEBUG [http-thread-pool-8080(1)] (PhaseInterceptorChain.java:** >>>> 672) >>>> - Chain org.apache.cxf.phase.**PhaseInterceptorChain@90d38 was >>>> modified. >>>> Current flow: >>>> setup [PolicyOutInterceptor] >>>> prepare-send [MessageSenderInterceptor] >>>> marshal [JAXRSOutInterceptor] >>>> prepare-send-ending [**MessageSenderEndingInterceptor**] >>>> >>>> INFO: DEBUG [http-thread-pool-8080(1)] (PhaseInterceptorChain.java:** >>>> 259) >>>> - Invoking handleMessage on interceptor >>>> org.apache.cxf.jaxrs.**interceptor.**JAXRSOutInterceptor@47dcc2 >>>> >>>> INFO: DEBUG [http-thread-pool-8080(1)] (PhaseInterceptorChain.java:** >>>> 259) >>>> - Invoking handleMessage on interceptor >>>> org.apache.cxf.interceptor.**MessageSenderInterceptor$** >>>> MessageSenderEndingInterceptor**@9e362f >>>> >>>> >>>> INFO: DEBUG [http-thread-pool-8080(1)] (ServletController.java:218) - >>>> Finished servicing http request on thread: >>>> Thread[http-thread-pool-8080(**1),5,grizzly-kernel] >>>> >>>> >>>> Thanks again for your help. >>>> >>>> >>>> >>>> >>>> >>>> On Thu, Jul 19, 2012 at 12:54 PM, Sergey Beryozkin < >>>> [email protected] >>>> <mailto:[email protected]>> wrote: >>>> >>>> Hi, >>>> >>>> On 19/07/12 17:37, java kurious wrote: >>>> >>>> I am getting following 406 error when sending a request to a >>>> REST service. >>>> >>>> [#|2012-07-19T11:00:50.226-__**0400|INFO|glassfish3.1.1|__** >>>> javax.enterprise.system.std.__**com.sun.enterprise.server.__** >>>> logging|_ThreadID=128;___**ThreadName=Thread-2;|DEBUG >>>> >>>> [http-thread-pool-28181(4)] >>>> (__**WebApplicationExceptionMapper.**__java:62) - >>>> *WebApplicationException >>>> has been caught, status: 406* >>>> >>>> javax.ws.rs <http://javax.ws.rs>.__**WebApplicationException >>>> at >>>> org.apache.cxf.jaxrs.__**interceptor.__**JAXRSInInterceptor.__** >>>> processRequest(__**JAXRSInInterceptor.java:139) >>>> >>>> at >>>> org.apache.cxf.jaxrs.__**interceptor.__**JAXRSInInterceptor.__** >>>> handleMessage(__**JAXRSInInterceptor.java:89) >>>> >>>> >>>> >>>> >>>> INFO: DEBUG [http-thread-pool-8080(5)] (Headers.java:347) - Request >>>> Headers: {*Accept=[text/html, image/gif, image/jpeg, *; q=.2, >>>> */*; q=.2*], >>>> >>>> accept-charset=[ISO-8859-1,__**utf-8;q=0.7,*;q=0.7], >>>> accept-encoding=[gzip,deflate]**__, >>>> accept-language=[en,en-gb;q=0.**__7,en-us;q=0.3], >>>> cache-control=[max-age=0], >>>> connection=[keep-alive], Content-Type=[null], host=[localhost:8080], >>>> keep-alive=[115], user-agent=[Mozilla/5.0 (X11; U; Linux i686; >>>> en-US; >>>> rv:1.9.2.16) Gecko/20110323 Ubuntu/10.04 (lucid) Firefox/3.6.16]} >>>> >>>> >>>> Can you provide a bit more info please ? >>>> There has to be some more debug statements showing which resource >>>> methods have been checked. >>>> >>>> How does the resource method signature look like ? I can see a >>>> wilcard (*/*) available in Accept, but what may happen for example >>>> is that some bean is returned but say it can not be handled by JAXB, etc >>>> >>>> Cheers, Sergey >>>> >>>> >>>> >>>> >>>> I saw the discussion on following link: >>>> >>>> http://cxf.547215.n5.nabble.__**com/Jersey-CXF-compatibility-_** >>>> _td5437938.html >>>> >>>> <http://cxf.547215.n5.nabble.**com/Jersey-CXF-compatibility-** >>>> td5437938.html<http://cxf.547215.n5.nabble.com/Jersey-CXF-compatibility-td5437938.html> >>>> > >>>> >>>> I am wondering if the fix has been made and if so, which jar >>>> file do I need >>>> to upgrade. Following are the direct dependencies I have >>>> declared related >>>> to cxf: >>>> >>>> <dependency> >>>> <groupId>org.apache.camel</__**groupId> >>>> <artifactId>camel-cxf</__**artifactId> >>>> <version>2.9.1</version> >>>> </dependency> >>>> <dependency> >>>> <groupId>org.apache.camel</__**groupId> >>>> <artifactId>camel-cxf-__**transport</artifactId> >>>> <version>2.9.1</version> >>>> </dependency> >>>> <dependency> >>>> <groupId>org.apache.cxf</__**groupId> >>>> <artifactId>cxf-rt-frontend-__**jaxrs</artifactId> >>>> <version>2.6.1</version> >>>> </dependency> >>>> <dependency> >>>> <groupId>org.apache.cxf</__**groupId> >>>> <artifactId>cxf-bundle</__**artifactId> >>>> <version>2.6.1</version> >>>> </dependency> >>>> >>>> >>>> Thanks for any help. >>>> >>>> >>>> >>> >>> >
