Results 1 to 2 of 2
  1. #1
    Member
    Join Date
    Jun 2010
    Location
    Madurai
    Posts
    10

    Null Pointer Exception in Thread

    Hai,

    In LS sometimes it display the NullPointerException.

    Code:
    Exception in thread "Thread-168" java.lang.NullPointerException
            at com.chellasoft.activetrader.utils.OrderUtilities.run(OrderUtilities.j
    ava:72)
    The run function of Order Utilities as follows,

    Code:
    public void run() {
    	//send order request/modify/cancel message 
    	if (user != null) {
    	try {
    		OrderRequestMessage orderRequestMessage = new OrderRequestMessage();
    		orderRequestMessage.setOrderValue(message);
    		String jsonString = orderRequestMessage.toJSON();
    		  	
                    JsonSingleUserMessage jsonSingleUserMessage = new  JsonSingleUserMessage(user.getUserId(), jsonString.length(), jsonString, CustomConstants.JSONMessageTypes_OrderRequestMessage);  	  ProcessBrowserMessages.getInstance().sendJSONSingleUserMessage(jsonSingleUserMessage);
    	}catch(JSONException e) {
    	logger.severe("Error getting when parse order request message : " + e.getMessage() + "......");
    			}
    	
    		} else {
    			logger.info("Invalid user: " + user.getUserName() + " to place Order");
    		}
    		
    		/*PrepareOrderArgs prepareOrderArgs = new PrepareOrderArgs(user, message);
    		orderArgs = prepareOrderArgs.getOrderArgs();
    		placeOrder();*/
    	}
    Please give suggestion for this issue.

    Thanks in advance.

  2. #2
    Power Member
    Join Date
    Jul 2006
    Location
    Cesano Maderno, Italy
    Posts
    784
    NullPointerException means that you tried to call a method or access a property on a variable that is actually null.

    e.g.
    if orderRequestMessage.toJSON(); returns null then the jsonString.length() on the following line will throw the NullPointerException.

    moreover the exception tells you on which line it happened (in your case 72)

    if the issue is reproducible at will you may debug your code step by step keeping an eye on the values of the variables

    HTH

 

 

Similar Threads

  1. Replies: 1
    Last Post: July 7th, 2010, 03:13 PM
  2. < WARN> Unexpected null event ???
    By mohamida in forum Adapter SDKs
    Replies: 2
    Last Post: December 10th, 2009, 07:57 AM
  3. opera -mouse pointer
    By rd2008 in forum Client SDKs
    Replies: 1
    Last Post: November 14th, 2008, 11:18 AM
  4. DISTINCT updates are NULL with recent LS server
    By rsouissi in forum Client SDKs
    Replies: 4
    Last Post: March 6th, 2008, 02:59 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT +1. The time now is 02:26 PM.