4

I have written a rest web services using jersey 1.9.1 and it works perfectly from my local machine but when i deployed it on server it gives me below error

Nov 06, 2014 9:34:49 AM com.sun.jersey.spi.container.ContainerResponse mapMappab leContainerException SEVERE: The RuntimeException could not be mapped to a response, re-throwing to t he HTTP container java.lang.NullPointerException at com.xxx.webservices.CheckPassword.getCheckPassword(CheckPassword.java :58) at com.xxx.wsResource.MobResource.checkPassword(ApwMobResource.java:4 0) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl. java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces sorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:606)

My java file is

CheckPassword checkpassword=new CheckPassword();
JavatoJason javatojason=new JavatoJason();
@GET
@Produces(MediaType.APPLICATION_JSON)
public JSONObject checkPassword(@QueryParam("userName") String userName,
        @QueryParam("userPassword") String userPassword) throws JSONException {
Response rb = null; 
JSONObject json = new JSONObject();
System.out.println("here in check password1111 userName=>"+userName+"  userPassword==>"+userPassword);
String result=checkpassword.getCheckPassword(userName, userPassword);
JSONObject jResult = javatojason.convertString(result);

return jResult;

}

i am getting error at

String result=checkpassword.getCheckPassword(userName, userPassword);

value of userName and Password is coming fine i have tested with sop

my web.xml is

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"   xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0">
  <display-name>mobapplication</display-name>

<servlet>
<servlet-name>Jersey</servlet-name>
<servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class>
<init-param>
    <param-name>com.sun.jersey.config.property.packages</param-name>
    <param-value>com.wns;com.wns.jackson.jaxrs</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>

<servlet-mapping>
    <servlet-name>Jersey</servlet-name>
    <url-pattern>/rest/*</url-pattern>
</servlet-mapping>

</web-app>

i am using tomcat both at local as well as server. I would greatly appreciate if you can help me solve this problem. Thanks in advance

Anupam Sharnagat
  • 61
  • 1
  • 2
  • 5
  • 1
    Never mind guys i found the solution while searching at stack overflow itself i found a suggestion by @Pradip Bhatt (http://stackoverflow.com/questions/10090715/running-jersey-project-rest-web-service-to-tomcat?rq=1) i added this property to web.xml com.sun.jersey.api.json.POJOMappingFeature true which leads me to specific problem there was some req file missing used for db connection(specific to my project) added and solved :) thanks – Anupam Sharnagat Nov 07 '14 at 11:27

0 Answers0