Skip to main content

Uri Parsing Error with Restful Web Service in Sun Developer Pack

1 reply [Last post]
kschan
Offline
Joined: 2007-08-25

hello,

I am making a restful web service with Sun Developer Pack.

here is a code snippnet.

@UriTemplate( "/say/{hello}" )
@HttpMethod( "GET" )
public Representation sayHello( @UriParam("hello") String hello ) {
return new StringRepresentation( hello );
}

when invoking the function with - "http://localhost:8080/say/hello"
output "hello" which is fine ...

but when invoking the function with "http://localhost:8080/say/hello world" OR "http://localhost:8080/say/hello%20world"

my glassfish log is dumped with -

StandardWrapperValve[RESTBeans Application]: Servlet.service() for servlet RESTBeans Application threw exception
java.lang.IllegalArgumentException
at java.net.URI.create(URI.java:842)
at com.sun.ws.rest.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:150)
at com.sun.ws.rest.impl.container.servlet.ServletAdaptor.service(ServletAdaptor.java:106)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
at org.apache.catalina.core.ApplicationFilterChain.servletService(ApplicationFilterChain.java:397)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:278)
at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:566)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:536)
at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:240)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:179)
at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:566)
at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:73)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:182)
at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:566)
at com.sun.enterprise.web.VirtualServerPipeline.invoke(VirtualServerPipeline.java:120)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:939)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:137)
at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:566)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:536)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:939)
at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:239)
at com.sun.enterprise.web.connector.grizzly.ProcessorTask.invokeAdapter(ProcessorTask.java:667)
at com.sun.enterprise.web.connector.grizzly.ProcessorTask.processNonBlocked(ProcessorTask.java:574)
at com.sun.enterprise.web.connector.grizzly.ProcessorTask.process(ProcessorTask.java:844)
at com.sun.enterprise.web.connector.grizzly.ReadTask.executeProcessorTask(ReadTask.java:287)
at com.sun.enterprise.web.connector.grizzly.ReadTask.doTask(ReadTask.java:212)
at com.sun.enterprise.web.connector.grizzly.TaskBase.run(TaskBase.java:252)
at com.sun.enterprise.web.connector.grizzly.WorkerThread.run(WorkerThread.java:75)
Caused by: java.net.URISyntaxException: Illegal character in path at index 16: people/say/hello world
at java.net.URI$Parser.fail(URI.java:2809)
at java.net.URI$Parser.checkChars(URI.java:2982)
at java.net.URI$Parser.parseHierarchical(URI.java:3066)
at java.net.URI$Parser.parse(URI.java:3024)
at java.net.URI.(URI.java:578)
at java.net.URI.create(URI.java:840)
... 27 more

can anyone help?? my application need to handle something with a space in the uri parameter.

environment:
jdk1.6, glasshfish v1 , sun developer pack R2, compiled with netbean6 m10

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
sandoz
Offline
Joined: 2003-06-20

I recommend if you can to switch to the latest stable release Jersey [1]. The use-case you present should work.

Jersey is the open source reference implementation for JAX-RS. The JAX-RS API was influenced by the experience of designing and implementing RESTful Web services for the Sun Web Developer Pack and contains many improvements as well as being more open and actively worked on. The RESTful API in SWDP is no longer in active development and no further releases are planed.

If you join the project and subscribe to the users email list i can help respond to any questions you have and help you transition any code you have to the latest API.

Paul.

[1] http://jersey.dev.java.net