Solved

How do I resolve Tomcat 6 experiencing a NullPointerException when attempting to invoke contextDestroyed()?

Posted on 2009-07-02
1
461 Views
Last Modified: 2013-12-02
Hi,

I have a context listener extending ServletContextListener. I use contextInitialized() to load in my application's property file and spawn a new thread for managing an external resource; contextDestroyed() is used to gracefully stop this thread from managing the resource.

When Tomcat starts up, contextInitialized() is invoked as expected and the application loads normally. Upon stopping the application / shutting down Tomcat, Catalina throws a NullPointerException when attempting to pass my context listener the "context destroyed" event.

I've included the error from my 'localhost' logfile.

I've checked the "standard" things, such as ensuring my application isn't throwing exceptions, no duplicate .jar's within the lib directories.

Any idea as to why Tomcat is experiencing the NullPointer?
02-Jul-2009 23:00:12 org.apache.catalina.core.StandardContext listenerStop

SEVERE: Exception sending context destroyed event to listener instance of class fivestarlives.ApplicationContextListener

java.lang.NullPointerException

	at fivestarlives.ApplicationContextListener.contextDestroyed(Unknown Source)

	at org.apache.catalina.core.StandardContext.listenerStop(StandardContext.java:3973)

	at org.apache.catalina.core.StandardContext.stop(StandardContext.java:4577)

	at org.apache.catalina.core.ContainerBase.removeChild(ContainerBase.java:924)

	at org.apache.catalina.startup.HostConfig.undeployApps(HostConfig.java:1248)

	at org.apache.catalina.startup.HostConfig.stop(HostConfig.java:1219)

	at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:316)

	at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)

	at org.apache.catalina.core.ContainerBase.stop(ContainerBase.java:1086)

	at org.apache.catalina.core.ContainerBase.stop(ContainerBase.java:1098)

	at org.apache.catalina.core.StandardEngine.stop(StandardEngine.java:448)

	at org.apache.catalina.core.StandardService.stop(StandardService.java:584)

	at org.apache.catalina.core.StandardServer.stop(StandardServer.java:744)

	at org.apache.catalina.startup.Catalina.stop(Catalina.java:633)

	at org.apache.catalina.startup.Catalina.start(Catalina.java:608)

	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 org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288)

	at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)

Open in new window

0
Comment
Question by:Sabooji
1 Comment
 
LVL 92

Accepted Solution

by:
objects earned 250 total points
ID: 24769002
The NPE is happening in your code, if you compile you class with -g option it will tell you what line number it is occurring on
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
What is the latest versions eclipse neon 2 139
create a gui in perl 3 71
Checkbox and ListView in Android Layout 4 56
print map entry 34 55
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.

910 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now