You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by bhaskerhari <bh...@yahoo.com> on 2013/09/06 18:57:01 UTC

Is there a way to suppress the usage of org.apache.cxf.javascript.JavascriptQueryHandler for my JAX RS calls?

I am having an issue with the REST request urls that my clients send. We
allow xml tags and "|" characters in our request urls. But this is throwing
an error:-

java.lang.IllegalArgumentException
	java.net.URI.create(URI.java:841)

org.apache.cxf.javascript.JavascriptQueryHandler.isRecognizedQuery(JavascriptQueryHandler.java:86)

org.apache.cxf.javascript.JavascriptQueryHandler.isRecognizedQuery(JavascriptQueryHandler.java:168)

org.apache.cxf.transport.servlet.ServletController.findQueryHandler(ServletController.java:242)

org.apache.cxf.transport.servlet.ServletController.invoke(ServletController.java:194)

org.apache.cxf.transport.servlet.ServletController.invoke(ServletController.java:137)

org.apache.cxf.transport.servlet.CXFNonSpringServlet.invoke(CXFNonSpringServlet.java:158)

This was working fine with older versions of CXF, may be because
JavascriptQueryHandler was not available in the very old versions of CXF.

Tried setting the URIEncoding at tomcat end, but it does not work.

So is there a way to tell CXF not to use
org.apache.cxf.javascript.JavascriptQueryHandler for the request? Or a way
to come up with a custom JavascriptQueryHandler so that I do URIEncoding
before I call isRecognizedQuery? 

Or a way to do tell CXF to do URIEncoding of my requests?



--
View this message in context: http://cxf.547215.n5.nabble.com/Is-there-a-way-to-suppress-the-usage-of-org-apache-cxf-javascript-JavascriptQueryHandler-for-my-JAX--tp5733646.html
Sent from the cxf-user mailing list archive at Nabble.com.

Re: Is there a way to suppress the usage of org.apache.cxf.javascript.JavascriptQueryHandler for my JAX RS calls?

Posted by bhaskerhari <bh...@yahoo.com>.
Great, Will implement the temporary fix for now and will migrate it to 2.7.7
later.

Could you please shed some light on the
java.lang.ArrayIndexOutOfBoundsException? We are kind of blocked with our
migration due to this error? 



--
View this message in context: http://cxf.547215.n5.nabble.com/Is-there-a-way-to-suppress-the-usage-of-org-apache-cxf-javascript-JavascriptQueryHandler-for-my-JAX--tp5733646p5733733.html
Sent from the cxf-user mailing list archive at Nabble.com.

Re: Is there a way to suppress the usage of org.apache.cxf.javascript.JavascriptQueryHandler for my JAX RS calls?

Posted by Daniel Kulp <dk...@apache.org>.
I just put a guard around this URI.create call for 2.7.7-SNAPSHOT.   Thus, 2.7.7 should "fix" this particular issue.

Dan



On Sep 6, 2013, at 12:57 PM, bhaskerhari <bh...@yahoo.com> wrote:

> I am having an issue with the REST request urls that my clients send. We
> allow xml tags and "|" characters in our request urls. But this is throwing
> an error:-
> 
> java.lang.IllegalArgumentException
> 	java.net.URI.create(URI.java:841)
> 
> org.apache.cxf.javascript.JavascriptQueryHandler.isRecognizedQuery(JavascriptQueryHandler.java:86)
> 
> org.apache.cxf.javascript.JavascriptQueryHandler.isRecognizedQuery(JavascriptQueryHandler.java:168)
> 
> org.apache.cxf.transport.servlet.ServletController.findQueryHandler(ServletController.java:242)
> 
> org.apache.cxf.transport.servlet.ServletController.invoke(ServletController.java:194)
> 
> org.apache.cxf.transport.servlet.ServletController.invoke(ServletController.java:137)
> 
> org.apache.cxf.transport.servlet.CXFNonSpringServlet.invoke(CXFNonSpringServlet.java:158)
> 
> This was working fine with older versions of CXF, may be because
> JavascriptQueryHandler was not available in the very old versions of CXF.
> 
> Tried setting the URIEncoding at tomcat end, but it does not work.
> 
> So is there a way to tell CXF not to use
> org.apache.cxf.javascript.JavascriptQueryHandler for the request? Or a way
> to come up with a custom JavascriptQueryHandler so that I do URIEncoding
> before I call isRecognizedQuery? 
> 
> Or a way to do tell CXF to do URIEncoding of my requests?
> 
> 
> 
> --
> View this message in context: http://cxf.547215.n5.nabble.com/Is-there-a-way-to-suppress-the-usage-of-org-apache-cxf-javascript-JavascriptQueryHandler-for-my-JAX--tp5733646.html
> Sent from the cxf-user mailing list archive at Nabble.com.

-- 
Daniel Kulp
dkulp@apache.org - http://dankulp.com/blog
Talend Community Coder - http://coders.talend.com


Re: Is there a way to suppress the usage of org.apache.cxf.javascript.JavascriptQueryHandler for my JAX RS calls?

Posted by bhaskerhari <bh...@yahoo.com>.
Think we finally managed to get the functionality same as with the earlier
version of CXF. But we noticed an unusual thing. It is about the memory the
application is consuming with the new CXF libraries. Application with the
new CXF libraries is consuming a lot more memory and the GC time is also
higher. The JVM has gone from using 8 GB to more than 10GB.

Do you see anything that we will need to take care of with the latest ones?

Below are list of customisations that I had to do in our application to
retain the functionality after using the new CXF libraries.

1. Constructing JAXBContext for one of the WS clients. (This is a static
variable done in a static block. So does not construct for every request)
2. Added an AbstractSoapInterceptor for our WS to remove the SOAPAction from
the requests.
3. Added StaxTransformFeature to convert some of the root elements coming
without namespace to append namespaces.



--
View this message in context: http://cxf.547215.n5.nabble.com/Is-there-a-way-to-suppress-the-usage-of-org-apache-cxf-javascript-JavascriptQueryHandler-for-my-JAX--tp5733646p5733949.html
Sent from the cxf-user mailing list archive at Nabble.com.

Re: Is there a way to suppress the usage of org.apache.cxf.javascript.JavascriptQueryHandler for my JAX RS calls?

Posted by bhaskerhari <bh...@yahoo.com>.
Looks like this error was coming with older version of CXF as well. So this
might not be a CXF issue. Found that the exception message is not correct
here. Think changing the maxHttpHeaderSize at the tomcat end might resolve
this error.



--
View this message in context: http://cxf.547215.n5.nabble.com/Is-there-a-way-to-suppress-the-usage-of-org-apache-cxf-javascript-JavascriptQueryHandler-for-my-JAX--tp5733646p5733759.html
Sent from the cxf-user mailing list archive at Nabble.com.

Re: Is there a way to suppress the usage of org.apache.cxf.javascript.JavascriptQueryHandler for my JAX RS calls?

Posted by bhaskerhari <bh...@yahoo.com>.
This issue is happening only intermittently, so the same request would be
given a successful response without any error. Will try to do some more
debugging on this.

I am using Tomcat 6. Could it be a case that this requires Tomcat 7?



--
View this message in context: http://cxf.547215.n5.nabble.com/Is-there-a-way-to-suppress-the-usage-of-org-apache-cxf-javascript-JavascriptQueryHandler-for-my-JAX--tp5733646p5733736.html
Sent from the cxf-user mailing list archive at Nabble.com.

Re: Is there a way to suppress the usage of org.apache.cxf.javascript.JavascriptQueryHandler for my JAX RS calls?

Posted by Sergey Beryozkin <sb...@gmail.com>.
On 09/09/13 17:19, bhaskerhari wrote:
> I am using CXF 2.7.5 now.
> Actually we are trying to update the CXF version from 2.2.11 to 2.7.5.
> 2.2.11 does not throw this error.  When we updated the CXF libraries to
> 2.7.5, this error is being thrown.

Hmm... The exception is actually coming from Tomcat, when the (JSON) 
provider starts writing the data the headers are actually written first 
and somehow it fails in your case,

I've no idea why it it can happen. Can you please investigate a bit more 
and may be narrow down the problem a bit ?

Cheers, Sergey
>
>
>
> --
> View this message in context: http://cxf.547215.n5.nabble.com/Is-there-a-way-to-suppress-the-usage-of-org-apache-cxf-javascript-JavascriptQueryHandler-for-my-JAX--tp5733646p5733725.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

Re: Is there a way to suppress the usage of org.apache.cxf.javascript.JavascriptQueryHandler for my JAX RS calls?

Posted by bhaskerhari <bh...@yahoo.com>.
I am using CXF 2.7.5 now. 
Actually we are trying to update the CXF version from 2.2.11 to 2.7.5.
2.2.11 does not throw this error.  When we updated the CXF libraries to
2.7.5, this error is being thrown.



--
View this message in context: http://cxf.547215.n5.nabble.com/Is-there-a-way-to-suppress-the-usage-of-org-apache-cxf-javascript-JavascriptQueryHandler-for-my-JAX--tp5733646p5733725.html
Sent from the cxf-user mailing list archive at Nabble.com.

Re: Is there a way to suppress the usage of org.apache.cxf.javascript.JavascriptQueryHandler for my JAX RS calls?

Posted by Sergey Beryozkin <sb...@gmail.com>.
I suspect that the custom entity being serialized is not thread-safe, 
can it be the case ?
What CXF version is it ?

Sergey
On 09/09/13 17:12, bhaskerhari wrote:
> Thanks for your replies. Currently i have all the cxf libraries in my webapp.
> Will try it out with smaller jars excluding the cxf runtime javascript lib.
>
> I just found another issue where i am facing ArrayIndexOutOfBoundsException.
>
> 2013-09-09 10:36:09,132 WARN [catalina-exec-30]
> [WebApplicationExceptionMapper] javax.ws.rs.InternalServerErrorException:
> java.lang.ArrayIndexOutOfBoundsException: 8192
> 	at
> org.apache.cxf.jaxrs.provider.json.JSONProvider.writeTo(JSONProvider.java:377)
> 	at
> org.apache.cxf.jaxrs.utils.JAXRSUtils.writeMessageBody(JAXRSUtils.java:1326)
> 	at
> org.apache.cxf.jaxrs.interceptor.JAXRSOutInterceptor.serializeMessage(JAXRSOutInterceptor.java:282)
> 	at
> org.apache.cxf.jaxrs.interceptor.JAXRSOutInterceptor.processResponse(JAXRSOutInterceptor.java:154)
> 	at
> org.apache.cxf.jaxrs.interceptor.JAXRSOutInterceptor.handleMessage(JAXRSOutInterceptor.java:85)
> 	at
> org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:271)
> 	at
> org.apache.cxf.interceptor.OutgoingChainInterceptor.handleMessage(OutgoingChainInterceptor.java:77)
> 	at
> org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:271)
> 	at
> org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:121)
> 	at
> org.apache.cxf.transport.http.AbstractHTTPDestination.invoke(AbstractHTTPDestination.java:239)
> 	at
> org.apache.cxf.transport.servlet.ServletController.invokeDestination(ServletController.java:223)
> 	at
> org.apache.cxf.transport.servlet.ServletController.invoke(ServletController.java:203)
> 	at
> org.apache.cxf.transport.servlet.ServletController.invoke(ServletController.java:137)
> 	at
> org.apache.cxf.transport.servlet.CXFNonSpringServlet.invoke(CXFNonSpringServlet.java:158)
> 	at
> org.apache.cxf.transport.servlet.AbstractHTTPServlet.handleRequest(AbstractHTTPServlet.java:243)
> 	at
> org.apache.cxf.transport.servlet.AbstractHTTPServlet.doGet(AbstractHTTPServlet.java:168)
> 	at javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
> 	at
> org.apache.cxf.transport.servlet.AbstractHTTPServlet.service(AbstractHTTPServlet.java:219)
> 	at
> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
> 	at
> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
>
> Caused by: java.lang.ArrayIndexOutOfBoundsException: 8192
> 	at
> org.apache.coyote.http11.InternalAprOutputBuffer.endHeaders(InternalAprOutputBuffer.java:521)
> 	at
> org.apache.coyote.http11.Http11AprProcessor.prepareResponse(Http11AprProcessor.java:1780)
> 	at
> org.apache.coyote.http11.Http11AprProcessor.action(Http11AprProcessor.java:1019)
> 	at org.apache.coyote.Response.action(Response.java:181)
> 	at
> org.apache.coyote.http11.InternalAprOutputBuffer.doWrite(InternalAprOutputBuffer.java:545)
> 	at org.apache.coyote.Response.doWrite(Response.java:560)
> 	at
> org.apache.catalina.connector.OutputBuffer.realWriteBytes(OutputBuffer.java:364)
> 	at org.apache.tomcat.util.buf.ByteChunk.append(ByteChunk.java:339)
> 	at
> org.apache.catalina.connector.OutputBuffer.writeBytes(OutputBuffer.java:392)
> 	at org.apache.catalina.connector.OutputBuffer.write(OutputBuffer.java:381)
> 	at
> org.apache.catalina.connector.CoyoteOutputStream.write(CoyoteOutputStream.java:89)
>
> What I have observed is that this error happens intermittently when two
> similar requests are sent to the WS at the exact same time. When the failing
> requests are processed again, they seem to be fine.
>
> Looks like we are getting into a RACE condition here. Please suggest me how
> can be get rid of this?
>
>
>
> --
> View this message in context: http://cxf.547215.n5.nabble.com/Is-there-a-way-to-suppress-the-usage-of-org-apache-cxf-javascript-JavascriptQueryHandler-for-my-JAX--tp5733646p5733721.html
> Sent from the cxf-user mailing list archive at Nabble.com.
>



Re: Is there a way to suppress the usage of org.apache.cxf.javascript.JavascriptQueryHandler for my JAX RS calls?

Posted by bhaskerhari <bh...@yahoo.com>.
Thanks for your replies. Currently i have all the cxf libraries in my webapp. 
Will try it out with smaller jars excluding the cxf runtime javascript lib. 

I just found another issue where i am facing ArrayIndexOutOfBoundsException. 

2013-09-09 10:36:09,132 WARN [catalina-exec-30]
[WebApplicationExceptionMapper] javax.ws.rs.InternalServerErrorException:
java.lang.ArrayIndexOutOfBoundsException: 8192
	at
org.apache.cxf.jaxrs.provider.json.JSONProvider.writeTo(JSONProvider.java:377)
	at
org.apache.cxf.jaxrs.utils.JAXRSUtils.writeMessageBody(JAXRSUtils.java:1326)
	at
org.apache.cxf.jaxrs.interceptor.JAXRSOutInterceptor.serializeMessage(JAXRSOutInterceptor.java:282)
	at
org.apache.cxf.jaxrs.interceptor.JAXRSOutInterceptor.processResponse(JAXRSOutInterceptor.java:154)
	at
org.apache.cxf.jaxrs.interceptor.JAXRSOutInterceptor.handleMessage(JAXRSOutInterceptor.java:85)
	at
org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:271)
	at
org.apache.cxf.interceptor.OutgoingChainInterceptor.handleMessage(OutgoingChainInterceptor.java:77)
	at
org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:271)
	at
org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:121)
	at
org.apache.cxf.transport.http.AbstractHTTPDestination.invoke(AbstractHTTPDestination.java:239)
	at
org.apache.cxf.transport.servlet.ServletController.invokeDestination(ServletController.java:223)
	at
org.apache.cxf.transport.servlet.ServletController.invoke(ServletController.java:203)
	at
org.apache.cxf.transport.servlet.ServletController.invoke(ServletController.java:137)
	at
org.apache.cxf.transport.servlet.CXFNonSpringServlet.invoke(CXFNonSpringServlet.java:158)
	at
org.apache.cxf.transport.servlet.AbstractHTTPServlet.handleRequest(AbstractHTTPServlet.java:243)
	at
org.apache.cxf.transport.servlet.AbstractHTTPServlet.doGet(AbstractHTTPServlet.java:168)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
	at
org.apache.cxf.transport.servlet.AbstractHTTPServlet.service(AbstractHTTPServlet.java:219)
	at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
	at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)

Caused by: java.lang.ArrayIndexOutOfBoundsException: 8192
	at
org.apache.coyote.http11.InternalAprOutputBuffer.endHeaders(InternalAprOutputBuffer.java:521)
	at
org.apache.coyote.http11.Http11AprProcessor.prepareResponse(Http11AprProcessor.java:1780)
	at
org.apache.coyote.http11.Http11AprProcessor.action(Http11AprProcessor.java:1019)
	at org.apache.coyote.Response.action(Response.java:181)
	at
org.apache.coyote.http11.InternalAprOutputBuffer.doWrite(InternalAprOutputBuffer.java:545)
	at org.apache.coyote.Response.doWrite(Response.java:560)
	at
org.apache.catalina.connector.OutputBuffer.realWriteBytes(OutputBuffer.java:364)
	at org.apache.tomcat.util.buf.ByteChunk.append(ByteChunk.java:339)
	at
org.apache.catalina.connector.OutputBuffer.writeBytes(OutputBuffer.java:392)
	at org.apache.catalina.connector.OutputBuffer.write(OutputBuffer.java:381)
	at
org.apache.catalina.connector.CoyoteOutputStream.write(CoyoteOutputStream.java:89)

What I have observed is that this error happens intermittently when two
similar requests are sent to the WS at the exact same time. When the failing
requests are processed again, they seem to be fine. 

Looks like we are getting into a RACE condition here. Please suggest me how
can be get rid of this?



--
View this message in context: http://cxf.547215.n5.nabble.com/Is-there-a-way-to-suppress-the-usage-of-org-apache-cxf-javascript-JavascriptQueryHandler-for-my-JAX--tp5733646p5733721.html
Sent from the cxf-user mailing list archive at Nabble.com.

Re: Is there a way to suppress the usage of org.apache.cxf.javascript.JavascriptQueryHandler for my JAX RS calls?

Posted by Daniel Kulp <dk...@apache.org>.
On Sep 9, 2013, at 6:50 AM, bhaskerhari <bh...@yahoo.com> wrote:

> One solution I found so far is to extend JavascriptQueryHandler and override
> the method isRecognizedQuery to return false always. The other solution is
> to extend org.apache.cxf.transports.http.internal.QueryHandlerRegistryImpl
> and override getHandlers() to return an empty list of QueryHandlers. Both
> the solutions seems to be working for me. 
> 
> Could you please suggest me if it is ok to implement like this? Or do you
> know a better way to handle this?

The better way would be to just use the smaller jars and NOT put the cxf-runtime-javascript  jar into you app.   Thus, the javascript handler wouldn't even be there at all.


-- 
Daniel Kulp
dkulp@apache.org - http://dankulp.com/blog
Talend Community Coder - http://coders.talend.com


Re: Is there a way to suppress the usage of org.apache.cxf.javascript.JavascriptQueryHandler for my JAX RS calls?

Posted by bhaskerhari <bh...@yahoo.com>.
Thanks for your reply.

I just found another issue where i am facing ArrayIndexOutOfBoundsException.



What I have observed is that this error happens intermittently when two
similar requests are sent to the WS at the exact same time. When the failing
requests are processed again, they seem to be fine.

Looks like we are getting into a RACE condition here. Please suggest me how
can be get rid of this?



--
View this message in context: http://cxf.547215.n5.nabble.com/Is-there-a-way-to-suppress-the-usage-of-org-apache-cxf-javascript-JavascriptQueryHandler-for-my-JAX--tp5733646p5733719.html
Sent from the cxf-user mailing list archive at Nabble.com.

Re: Is there a way to suppress the usage of org.apache.cxf.javascript.JavascriptQueryHandler for my JAX RS calls?

Posted by Sergey Beryozkin <sb...@gmail.com>.
Hi
On 09/09/13 11:50, bhaskerhari wrote:
> One solution I found so far is to extend JavascriptQueryHandler and override
> the method isRecognizedQuery to return false always. The other solution is
> to extend org.apache.cxf.transports.http.internal.QueryHandlerRegistryImpl
> and override getHandlers() to return an empty list of QueryHandlers. Both
> the solutions seems to be working for me.
>
> Could you please suggest me if it is ok to implement like this? Or do you
> know a better way to handle this?
>

I believe Dan has removed QueryHandler extension on the trunk, so in 
3.0.0 it won't interfere, I guess either of the options you've tried is 
OK on the JAX-RS path

Cheers, Sergey

>
>
>
> --
> View this message in context: http://cxf.547215.n5.nabble.com/Is-there-a-way-to-suppress-the-usage-of-org-apache-cxf-javascript-JavascriptQueryHandler-for-my-JAX--tp5733646p5733690.html
> Sent from the cxf-user mailing list archive at Nabble.com.
>



Re: Is there a way to suppress the usage of org.apache.cxf.javascript.JavascriptQueryHandler for my JAX RS calls?

Posted by bhaskerhari <bh...@yahoo.com>.
One solution I found so far is to extend JavascriptQueryHandler and override
the method isRecognizedQuery to return false always. The other solution is
to extend org.apache.cxf.transports.http.internal.QueryHandlerRegistryImpl
and override getHandlers() to return an empty list of QueryHandlers. Both
the solutions seems to be working for me. 

Could you please suggest me if it is ok to implement like this? Or do you
know a better way to handle this?




--
View this message in context: http://cxf.547215.n5.nabble.com/Is-there-a-way-to-suppress-the-usage-of-org-apache-cxf-javascript-JavascriptQueryHandler-for-my-JAX--tp5733646p5733690.html
Sent from the cxf-user mailing list archive at Nabble.com.