users@jersey.java.net

[Jersey] Send array as query string

From: Shuja Rehman <shujamughal_at_gmail.com>
Date: Fri, 19 Aug 2011 17:34:14 +0500

Hi All,

I am trying to send array as query parameter as shown below.

@GET
@Path("data/xml")
@Produces("application/xml")
public MyListing getData(@QueryParam("ids") int[] Ids)
{
...
}

but it is not working. here is the error stack trace,

HTTP Status 500 -
------------------------------

*type* Exception report

*message*

*description* *The server encountered an internal error () that prevented it
from fulfilling this request.*

*exception*

javax.servlet.ServletException: Servlet.init() for servlet
org.netbeans.rest.application.config.ApplicationConfig threw exception
        org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:108)
        org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:379)
        org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:243)
        org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:259)
        org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:281)
        java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
        java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
        java.lang.Thread.run(Unknown Source)

*root cause*

com.sun.jersey.spi.inject.Errors$ErrorMessagesException
        com.sun.jersey.spi.inject.Errors.processErrorMessages(Errors.java:150)
        com.sun.jersey.spi.inject.Errors.postProcess(Errors.java:117)
        com.sun.jersey.spi.inject.Errors.processWithErrors(Errors.java:183)
        com.sun.jersey.server.impl.application.WebApplicationImpl.initiate(WebApplicationImpl.java:649)
        com.sun.jersey.server.impl.application.WebApplicationImpl.initiate(WebApplicationImpl.java:644)
        com.sun.jersey.spi.container.servlet.ServletContainer.initiate(ServletContainer.java:428)
        com.sun.jersey.spi.container.servlet.ServletContainer$InternalWebComponent.initiate(ServletContainer.java:277)
        com.sun.jersey.spi.container.servlet.WebComponent.load(WebComponent.java:573)
        com.sun.jersey.spi.container.servlet.WebComponent.init(WebComponent.java:211)
        com.sun.jersey.spi.container.servlet.ServletContainer.init(ServletContainer.java:332)
        com.sun.jersey.spi.container.servlet.ServletContainer.init(ServletContainer.java:496)
        javax.servlet.GenericServlet.init(GenericServlet.java:158)
        org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:108)
        org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:379)
        org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:243)
        org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:259)
        org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:281)
        java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
        java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
        java.lang.Thread.run(Unknown Source)

*note* *The full stack trace of the root cause is available in the Apache
Tomcat/7.0.5 logs.*
Can anyone let me know where is the problem or how to send array either as
query string or param path?


Thanks in advance

-- 
Regards
Shuja-ur-Rehman Baig
<http://pk.linkedin.com/in/shujamughal>