java.lang.NullPointerException

There are no available Samebug tips for this exception. Do you have an idea how to solve this issue? A short tip would help users who saw this issue last week.

  • I had set the host, port, password, systemId, systemType and bindType on the SmppSessionFactoryBean initially and could connect to my smsc and send/receive texts. {code} <bean id="session" class="org.springframework.integration.smpp.session.SmppSessionFactoryBean" > <property name="host" value="${smpp.host}" /> <property name="port" value="${smpp.port}" /> <property name="password" value="${smpp.password}" /> <property name="systemId" value="${smpp.systemId}" /> <property name="systemType" value="${smpp.systemId}" /> <property name="bindType" value="BIND_TRX" /> </bean> {code} I was having some problems in my application and was debugging. These breakpoints caused the SessionStateListener in org.springframework.integration.smpp.session.SmppSessionFactoryBean.AutoReconnectLifecycle#registerSessionCloseListener to be triggered and perform the close and reschedule. However instead of reconnecting it threw NPE because the reconnectingExecutor had been set to null. Something is calling the stop method that in turn calls shutdown on the reconnectingExecutor and sets it to null. NPE: {code} 2014-11-14 01:01:20.900 INFO 58299 --- [ Thread-2] essionFactoryBean$AutoReconnectLifecycle : Session to 212.242.37.209:2775 has been closed. Try to reconnect later 2014-11-14 01:01:20.901 DEBUG 58299 --- [pool-1-thread-3] org.jsmpp.session.SMPPSession : Sending enquire_link_resp 2014-11-14 01:01:20.901 DEBUG 58299 --- [pool-1-thread-1] org.jsmpp.session.SMPPSession : Sending enquire_link_resp 2014-11-14 01:01:20.901 DEBUG 58299 --- [pool-1-thread-3] o.jsmpp.session.AbstractSessionContext : Activity notified 2014-11-14 01:01:20.901 DEBUG 58299 --- [pool-1-thread-3] o.s.i.smpp.inbound.SmppInboundGateway$1 : Receiving message : Fhddh����ghggg 2014-11-14 01:01:20.901 DEBUG 58299 --- [pool-1-thread-3] o.s.i.smpp.inbound.SmppInboundGateway : received an SMS in class org.springframework.integration.smpp.inbound.SmppInboundGateway$1. Processing it. Exception in thread "Thread-2" java.lang.NullPointerException at org.springframework.integration.smpp.session.SmppSessionFactoryBean$AutoReconnectLifecycle.scheduleReconnect(SmppSessionFactoryBean.java:548) at org.springframework.integration.smpp.session.SmppSessionFactoryBean$AutoReconnectLifecycle.access$2200(SmppSessionFactoryBean.java:447) at org.springframework.integration.smpp.session.SmppSessionFactoryBean$AutoReconnectLifecycle$1.onStateChange(SmppSessionFactoryBean.java:515) at org.jsmpp.session.AbstractSessionContext.fireStateChanged(AbstractSessionContext.java:83) at org.jsmpp.session.SMPPSessionContext.changeState(SMPPSessionContext.java:61) at org.jsmpp.session.AbstractSessionContext.close(AbstractSessionContext.java:62) at org.jsmpp.session.AbstractSession.close(AbstractSession.java:198) at org.jsmpp.session.SMPPSession$PDUReaderWorker.readPDU(SMPPSession.java:587) at org.jsmpp.session.SMPPSession$PDUReaderWorker.run(SMPPSession.java:551) {code} If I explicitly set the reconnectingExecutor property on the SmppSessionFactoryBean in my configuration - then the reconnect continues to work even when debugging/loosing network connection for a while or similar. The reason is that the setReconnectingExecutor method in SmppSessionFactoryBean also sets a boolean 'reconnectingExecutorSet' to true - and when that boolean is set, the stop() method will not shutdown or null the reconnectingExecutor : {code} <bean id="session" class="org.springframework.integration.smpp.session.SmppSessionFactoryBean" > <property name="host" value="${smpp.host}" /> <property name="port" value="${smpp.port}" /> <property name="password" value="${smpp.password}" /> <property name="systemId" value="${smpp.systemId}" /> <property name="systemType" value="${smpp.systemId}" /> <property name="bindType" value="BIND_TRX" /> <property name="reconnectingExecutor"> <bean class="java.util.concurrent.Executors" factory-method="newFixedThreadPool"> <constructor-arg value="1" type="int" /> </bean> </property> </bean> {code}
    via by Flemming Jønsson,
  • I had set the host, port, password, systemId, systemType and bindType on the SmppSessionFactoryBean initially and could connect to my smsc and send/receive texts. {code} <bean id="session" class="org.springframework.integration.smpp.session.SmppSessionFactoryBean" > <property name="host" value="${smpp.host}" /> <property name="port" value="${smpp.port}" /> <property name="password" value="${smpp.password}" /> <property name="systemId" value="${smpp.systemId}" /> <property name="systemType" value="${smpp.systemId}" /> <property name="bindType" value="BIND_TRX" /> </bean> {code} I was having some problems in my application and was debugging. These breakpoints caused the SessionStateListener in org.springframework.integration.smpp.session.SmppSessionFactoryBean.AutoReconnectLifecycle#registerSessionCloseListener to be triggered and perform the close and reschedule. However instead of reconnecting it threw NPE because the reconnectingExecutor had been set to null. Something is calling the stop method that in turn calls shutdown on the reconnectingExecutor and sets it to null. NPE: {code} 2014-11-14 01:01:20.900 INFO 58299 --- [ Thread-2] essionFactoryBean$AutoReconnectLifecycle : Session to 212.242.37.209:2775 has been closed. Try to reconnect later 2014-11-14 01:01:20.901 DEBUG 58299 --- [pool-1-thread-3] org.jsmpp.session.SMPPSession : Sending enquire_link_resp 2014-11-14 01:01:20.901 DEBUG 58299 --- [pool-1-thread-1] org.jsmpp.session.SMPPSession : Sending enquire_link_resp 2014-11-14 01:01:20.901 DEBUG 58299 --- [pool-1-thread-3] o.jsmpp.session.AbstractSessionContext : Activity notified 2014-11-14 01:01:20.901 DEBUG 58299 --- [pool-1-thread-3] o.s.i.smpp.inbound.SmppInboundGateway$1 : Receiving message : Fhddh����ghggg 2014-11-14 01:01:20.901 DEBUG 58299 --- [pool-1-thread-3] o.s.i.smpp.inbound.SmppInboundGateway : received an SMS in class org.springframework.integration.smpp.inbound.SmppInboundGateway$1. Processing it. Exception in thread "Thread-2" java.lang.NullPointerException at org.springframework.integration.smpp.session.SmppSessionFactoryBean$AutoReconnectLifecycle.scheduleReconnect(SmppSessionFactoryBean.java:548) at org.springframework.integration.smpp.session.SmppSessionFactoryBean$AutoReconnectLifecycle.access$2200(SmppSessionFactoryBean.java:447) at org.springframework.integration.smpp.session.SmppSessionFactoryBean$AutoReconnectLifecycle$1.onStateChange(SmppSessionFactoryBean.java:515) at org.jsmpp.session.AbstractSessionContext.fireStateChanged(AbstractSessionContext.java:83) at org.jsmpp.session.SMPPSessionContext.changeState(SMPPSessionContext.java:61) at org.jsmpp.session.AbstractSessionContext.close(AbstractSessionContext.java:62) at org.jsmpp.session.AbstractSession.close(AbstractSession.java:198) at org.jsmpp.session.SMPPSession$PDUReaderWorker.readPDU(SMPPSession.java:587) at org.jsmpp.session.SMPPSession$PDUReaderWorker.run(SMPPSession.java:551) {code} If I explicitly set the reconnectingExecutor property on the SmppSessionFactoryBean in my configuration - then the reconnect continues to work even when debugging/loosing network connection for a while or similar. The reason is that the setReconnectingExecutor method in SmppSessionFactoryBean also sets a boolean 'reconnectingExecutorSet' to true - and when that boolean is set, the stop() method will not shutdown or null the reconnectingExecutor : {code} <bean id="session" class="org.springframework.integration.smpp.session.SmppSessionFactoryBean" > <property name="host" value="${smpp.host}" /> <property name="port" value="${smpp.port}" /> <property name="password" value="${smpp.password}" /> <property name="systemId" value="${smpp.systemId}" /> <property name="systemType" value="${smpp.systemId}" /> <property name="bindType" value="BIND_TRX" /> <property name="reconnectingExecutor"> <bean class="java.util.concurrent.Executors" factory-method="newFixedThreadPool"> <constructor-arg value="1" type="int" /> </bean> </property> </bean> {code}
    via by Flemming Jønsson,
    • java.lang.NullPointerException at org.springframework.integration.smpp.session.SmppSessionFactoryBean$AutoReconnectLifecycle.scheduleReconnect(SmppSessionFactoryBean.java:548) at org.springframework.integration.smpp.session.SmppSessionFactoryBean$AutoReconnectLifecycle.access$2200(SmppSessionFactoryBean.java:447) at org.springframework.integration.smpp.session.SmppSessionFactoryBean$AutoReconnectLifecycle$1.onStateChange(SmppSessionFactoryBean.java:515) at org.jsmpp.session.AbstractSessionContext.fireStateChanged(AbstractSessionContext.java:83) at org.jsmpp.session.SMPPSessionContext.changeState(SMPPSessionContext.java:61) at org.jsmpp.session.AbstractSessionContext.close(AbstractSessionContext.java:62) at org.jsmpp.session.AbstractSession.close(AbstractSession.java:198) at org.jsmpp.session.SMPPSession$PDUReaderWorker.readPDU(SMPPSession.java:587) at org.jsmpp.session.SMPPSession$PDUReaderWorker.run(SMPPSession.java:551)
    No Bugmate found.