0

I am dveloping a jersey based RESTful application :
so whenever i add something to my arraylist tomcat throws this error:

The RuntimeException could not be mapped to a response, re-throwing to the HTTP container
what does this mean ?

when diagonosing this problem i found it happens at :

mylist.add(item1);

why i am not able to add to arraylist ?

My Stacktrace:

<DateHere> : com.sun.jersey.spi.container.ContainerResponse mapMappableContainerException
SEVERE: The RuntimeException could not be mapped to a response, re-throwing to the HTTP container
java.lang.NullPointerException
    at com.proj.datastorage.myclass1.<init>(myclass1.java:19)
    at com.proj.datastorage.myclass2.<init>(myclass2.java:30)
    at com.proj.front.CreateResource.newShop(CreateResource.java:109)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at com.sun.jersey.spi.container.JavaMethodInvokerFactory$1.invoke(JavaMethodInvokerFactory.java:60)
    at com.sun.jersey.server.impl.model.method.dispatch.AbstractResourceMethodDispatchProvider$VoidOutInvoker._dispatch(AbstractResourceMethodDispatchProvider.java:167)
    at com.sun.jersey.server.impl.model.method.dispatch.ResourceJavaMethodDispatcher.dispatch(ResourceJavaMethodDispatcher.java:75)
    at com.sun.jersey.server.impl.uri.rules.HttpMethodRule.accept(HttpMethodRule.java:302)
    at com.sun.jersey.server.impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:147)
    at com.sun.jersey.server.impl.uri.rules.ResourceClassRule.accept(ResourceClassRule.java:108)
    at com.sun.jersey.server.impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:147)
    at com.sun.jersey.server.impl.uri.rules.RootResourceClassesRule.accept(RootResourceClassesRule.java:84)
    at com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:1511)
    at com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:1442)
    at com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1391)
    at com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1381)
    at com.sun.jersey.spi.container.servlet.WebComponent.service(WebComponent.java:416)
    at com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:538)
    at com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:716)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:849)
    at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
    at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:454)
    at java.lang.Thread.run(Unknown Source)
user2416728
  • 400
  • 4
  • 8
  • 25
  • please post the full stacktrace – fmodos Jun 18 '13 at 06:28
  • whats that mate..i mean i have given the cause of the problem ..the error i am getting..now what ?? – user2416728 Jun 18 '13 at 06:29
  • the error you are getting should have more information... here is what stack trace is: http://stackoverflow.com/questions/3988788/what-is-a-stack-trace-and-how-can-i-use-it-to-debug-my-application-errors – fmodos Jun 18 '13 at 06:31
  • you need to add com.proj.datastorage.myclass1 code also – dom farr Jun 18 '13 at 06:42
  • the error happens at class `myclass1` in the line 19, if you can post this code... also post the constructor code for the classes `myclass1` and `myclass2` – fmodos Jun 18 '13 at 06:42
  • 1
    I suspect you are trying to add either null object to a collection that does not allow nulls. or your list object is null. – dom farr Jun 18 '13 at 06:43
  • code's a bit confidential..nevertheless..i can walk you through what i am doing.. myclass2 is a shop and myclass1 are the items in it... i am calling the constrctor of myclass2 and at line 30 i am instantiating object of myclass1 inside myclass2's constructor.. coming to myclass1 ..when on line 19 this code is present.. `mylist.add(Item1);` ..insisde the constructor of myclass1 !! – user2416728 Jun 18 '13 at 06:48
  • the mylist item might be null... check where it is declared if it is `mylist = null` or `mylist = new ArrayList()` @user2416728 – fmodos Jun 18 '13 at 06:54
  • yup..its declared just before constructor.. `ArrayList mylist;` so do i need to put dummy elements in my list ? – user2416728 Jun 18 '13 at 06:59
  • 1
    no... you just need to create a default empty list for that: `ArrayList mylist = new ArrayList()` let me know if it works and I will post an answer for that @user2416728 – fmodos Jun 18 '13 at 07:01

1 Answers1

1

The mylist might be null, create a default instance for that: ArrayList<String> mylist = new ArrayList<String>().

fmodos
  • 4,472
  • 1
  • 16
  • 17
  • http://stackoverflow.com/questions/17165315/how-to-authenticate-and-redirect-a-user-to-his-own-page-in-jersey-rest-service another one for you !! ;) @fmodos – user2416728 Jun 18 '13 at 10:40