Null Pointer exception received sometimes while receiving messages

88 views
Skip to first unread message

Ahsan

unread,
Mar 18, 2009, 4:28:57 AM3/18/09
to jsmpp
My application is working fine and constantly listening for incoming
messages but sometimes this exception is thrown although process keeps
on
working
The session state is :true
Exception in thread "pool-2-thread-42" java.lang.NullPointerException
at java.lang.String.<init>(String.java:479)
at
com.app.smsreceiver.smsutil.messagelistener.onAcceptDeliverSm(me
ssagelistener.java:34)
at org.jsmpp.session.SMPPSession.fireAcceptDeliverSm
(SMPPSession.java:44
3)
at org.jsmpp.session.SMPPSession.access$400(SMPPSession.java:
92)
at
org.jsmpp.session.SMPPSession$ResponseHandlerImpl.processDeliverSm(SM
PPSession.java:460)
at
org.jsmpp.session.state.SMPPSessionBoundRX.processDeliverSm0
(SMPPSess
ionBoundRX.java:109)
at org.jsmpp.session.state.SMPPSessionBoundRX.processDeliverSm
(SMPPSessi
onBoundRX.java:51)
at org.jsmpp.session.PDUProcessTask.run(PDUProcessTask.java:
81)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask
(ThreadPoolExec
utor.java:650)
at java.util.concurrent.ThreadPoolExecutor$Worker.run
(ThreadPoolExecutor
.java:675)
at java.lang.Thread.run(Thread.java:595)
The session is :BOUND_RX

please let me know what is wrong with it.

regards,

Ahsan

unread,
Mar 20, 2009, 7:59:40 AM3/20/09
to jsmpp
I have found that when i send empty message i get this exception
Please let me know what can be done urgently.

regards,

uud ashr

unread,
Mar 28, 2009, 1:08:42 AM3/28/09
to js...@googlegroups.com
I think it happen when the dataSm.getShortMessage() return null value.
You should carefull when implementing MessageReceiverListener#onAcceptDeliverSm(DeliverSm)
by checking the null value

String shortMessage = null;
if (dataSm.getShortMessage() != null) {
    shortMessage = new String(shortMessage);
} else {
    // keep the shortMessage null
}

Regards, 
uudashr

Ahsan

unread,
Apr 1, 2009, 8:01:56 AM4/1/09
to jsmpp
Thank you the problem has been resolved.

regards,
-Ahsan-
> > > regards,- Hide quoted text -
>
> - Show quoted text -

Eric Itzhak

unread,
Dec 17, 2013, 11:26:21 AM12/17/13
to js...@googlegroups.com
If the shortMessage is null then how do i get a DeliveryReceipt?
I don't get it sometimes but all the time.
Could this be related to the fact that I'm send the SMS content via message_payload?

בתאריך יום שבת, 28 במרץ 2009 08:08:42 UTC+3, מאת uudashr:

Eric Itzhak

unread,
Dec 19, 2013, 5:23:05 AM12/19/13
to js...@googlegroups.com
To whom it may concern, I saw that with my SMSC I get null message and optional parameters contained message_state and receipt_messate_id, so I solved it with the following code :


            try {
          
                
                OptionalParameter[]  prms = deliverSm.getOptionalParametes();
                for(OptionalParameter param : prms){
                    
                    byte[] bytes  = param.serialize();
                   
                    if (param.tag == Tag.MESSAGE_STATE.code()){ 
                        
                         int message_state = bytes[4];
                         System.out.println("Message state : "+message_state);
                         
                    }
                     
                    else if(param.tag == Tag.RECEIPTED_MESSAGE_ID.code()){
                        
                        byte[] messageIdArray = new byte[bytes.length -4];
                        System.arraycopy(bytes,4,messageIdArray,0,messageIdArray.length);
                        String message_id = new String(messageIdArray);
                        System.out.println("deliver_sm message_id : "+message_id);
                        
                    }
                     

                
                      
                       
               }
                
      
      
            } catch (Exception e) {
                System.err.println("Failed getting delivery receipt");
                e.printStackTrace();
            }






בתאריך יום שלישי, 17 בדצמבר 2013 18:26:21 UTC+2, מאת Eric Itzhak:
Reply all
Reply to author
Forward
0 new messages