Post a Job  |   Ask a Question?   |   Already registered? login or register
AUROVINDO SAHU
10/07/2015 07:26 AM

problem in dynamic dispatcher (REST)


it raise NullPointerException -------------------------------- web.xml .............. <servlet> <servlet-name>SubResourceLocator</servlet-name> <servlet-class>org.glassfish.jersey.servlet.ServletContainer</servlet-class> <init-param> <param-name>jersey.config.server.provider.packages</param-name> <param-value>com.dd.MainResource</param-value> </init-param> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>SubResourceLocator</servlet-name> <url-pattern>/rest/*</url-pattern> </servlet-mapping> -------------------------------------------------------------------- sub-resource locator class ......................................... @Path("/bank") public class DynamicResource { @Path("{type}") public Object dispatch(@PathParam("{type}") String type){ if(type.equals("deposite")){ return new BankResource(); } else return null; } } --------------------------------------------------------------------- sub-resource class ............................. public class BankResource { @GET @Produces(MediaType.TEXT_PLAIN) public String withdrawl(@PathParam("id") String id){ return "success"; } }
Spam    3 Comments

kishore,sirikonda
10/07/2015 08:31:00
In your sub-resource class you are not placed placeholder for id. @Path("/{id}") @GET @Produces.... etc

AUROVINDO,SAHU
10/07/2015 12:25:34
i tried that one also .. after that also it shows same exception..i dont know what is the problem ????

AUROVINDO,SAHU
10/07/2015 12:42:28
I got the solution for it . in the above in the sub-resource locator class i input @PathParam("{type}"). it should not be in the curly bracket. If it den it become regular expression . thats why it raise NullPointerException.

Languages :
xml