nitingautam / jsmpp

Automatically exported from code.google.com/p/jsmpp
Apache License 2.0
0 stars 0 forks source link

NullPointerException in Tomcat environment #38

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Use JSMPP 2.0.1 in Tomcat 6.0.18 environment
2. Restart the context
3. NullPointerExceptions will start to appear regularely

Stacktrace:
Exception in thread "pool-2-thread-933" java.lang.NullPointerException
    at org.jsmpp.util.PDUByteBuffer.append(PDUByteBuffer.java:97)
    at org.jsmpp.util.PDUByteBuffer.append(PDUByteBuffer.java:115)
    at org.jsmpp.util.PDUByteBuffer.append(PDUByteBuffer.java:135)
    at org.jsmpp.util.PDUByteBuffer.(PDUByteBuffer.java:57)
    at org.jsmpp.util.PDUByteBuffer.(PDUByteBuffer.java:43)
    at 
org.jsmpp.util.DefaultComposer.composeHeader(DefaultComposer.java:50)
    at 
org.jsmpp.util.DefaultComposer.enquireLinkResp(DefaultComposer.java:173)
    at 
org.jsmpp.DefaultPDUSender.sendEnquireLinkResp(DefaultPDUSender.java:169)
    at 
org.jsmpp.SynchronizedPDUSender.sendEnquireLinkResp(SynchronizedPDUSender.j
ava:165)
    at 
org.jsmpp.session.SMPPSession$ResponseHandlerImpl.sendEnquireLinkResp(SMPPS
ession.java:502)
    at 
org.jsmpp.session.state.AbstractGenericSMPPSessionBound.processEnquireLink(
AbstractGenericSMPPSessionBound.java:47)
    at org.jsmpp.session.PDUProcessTask.run(PDUProcessTask.java:61)
    at 
java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.j
ava:886)
    at 
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:
908)
    at java.lang.Thread.run(Thread.java:619)

These NullPointerExceptions keep appearing, each time from another thread.

CAUSE:
Tomcat sets all static variables to NULL on reloading a context. Because 
the background threads of JSMPP are still alive, they access the variable 
PDUByteBuffer.DEFAULT_CAPACITY_POLICY  which is then NULL.

SOLUTION:
If some method would exist that shuts down all background threadpools, the 
problem would be avoided.

Original issue reported on code.google.com by nathan.b...@gmail.com on 5 Jun 2009 at 2:14