Win a copy of AWS Security this week in the Cloud/Virtualization forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • salvin francis
  • fred rosenberger

Communication response from servlet fails but it worked before

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello

I have an applet (where the user logins) & on pressing login button I send the login details to my servlet. In my applet, the function responsible for sending the login details to the servelt & receiving the servlet response object FAILS.

My problem is: I dont know why my function sendObject( Object o ) fails & I dont know how to fix it. Could you help me understand what is wrong & why?

I am using Apache 7.0. I think that receiving the response (getting the input stream) from the servlet fails but I dont know why & logging in was working fine the other day so I know my WEB-INF folder is set up fine & the web.xml is fine.

My function (I document where the function fails):



Java Console Output:

Result from applet.getCodeBase() = http://localhost:8080/Updater/
In sendObject(): java.io.IOException: Server returned HTTP response code: 500 for URL: http://localhost:8080/Updater/Updater



From the Apache log:

20/02/2011 11:15:08 AM org.apache.catalina.core.ApplicationContext log
INFO: ContextListener: contextInitialized()
20/02/2011 11:15:08 AM org.apache.catalina.core.ApplicationContext log
INFO: SessionListener: contextInitialized()
20/02/2011 11:15:23 AM org.apache.catalina.core.ApplicationContext log
INFO: Marking servlet Updater as unavailable
20/02/2011 11:15:23 AM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Allocate exception for servlet Updater
java.lang.NullPointerException
at javax.servlet.GenericServlet.getServletContext(GenericServlet.java:125)
at UpdaterServlet.<init>(UpdaterServlet.java:32) // REFER BELOW TO SEE LINE 32 OF THIS FILE
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at java.lang.Class.newInstance0(Unknown Source)
at java.lang.Class.newInstance(Unknown Source)
at org.apache.catalina.core.DefaultInstanceManager.newInstance(DefaultInstanceManager.java:119)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1048)
at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:799)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:135)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:161)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:164)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:541)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:383)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:243)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:188)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:288)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)



localhost_access_log...:

127.0.0.1 - - [20/Feb/2011:11:15:12 +1100] "GET /Updater/index.html HTTP/1.1" 304 -
127.0.0.1 - - [20/Feb/2011:11:15:15 +1100] "GET /Updater/UpdaterApplet.class HTTP/1.1" 304 -
127.0.0.1 - - [20/Feb/2011:11:15:15 +1100] "GET /Updater/ContentTree.class HTTP/1.1" 304 -
127.0.0.1 - - [20/Feb/2011:11:15:15 +1100] "GET /Updater/ContentMap.class HTTP/1.1" 304 -
127.0.0.1 - - [20/Feb/2011:11:15:15 +1100] "GET /Updater/UpdaterApplet$1.class HTTP/1.1" 304 -
127.0.0.1 - - [20/Feb/2011:11:15:15 +1100] "GET /Updater/SQLInterface.class HTTP/1.1" 304 -
127.0.0.1 - - [20/Feb/2011:11:15:23 +1100] "GET /Updater/ObjSerializationInterface.class HTTP/1.1" 304 -
127.0.0.1 - - [20/Feb/2011:11:15:23 +1100] "POST /Updater/Updater HTTP/1.1" 500 3117




This is the UpdaterServlet.java file (if you see above theres an error at line 32 of this file):

 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You better go back and study the servlet life cycle. Apparently you are relying on the constructor for UpdaterServlet to do all the work. I suspect your init method for that servlet does not correctly set the servlet context which is why you get:

java.lang.NullPointerException
at javax.servlet.GenericServlet.getServletContext(GenericServlet.java:125)

Bill
 
Today's lesson is that you can't wear a jetpack AND a cape. I should have read this tiny ad:
Devious Experiments for a Truly Passive Greenhouse!
https://www.kickstarter.com/projects/paulwheaton/greenhouse-1
    Bookmark Topic Watch Topic
  • New Topic