Announcement Announcement Module
Collapse
No announcement yet.
Spring 2.5 JMS NullPointerException on receive, works on 2.0.7 OK Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Spring 2.5 JMS NullPointerException on receive, works on 2.0.7 OK

    Hi,

    I just tried to upgrade to the latest Spring 2.5 version from Spring 2.0.7.
    The application has been stable on 2.0.7, but now generateds an

    Exception in thread "main" java.lang.NullPointerException
    at com.sun.evtl.mq.client.VtvAnalyzerClient.receive(V tvAnalyzerClient.java:159)

    on a JMS receive using a Selector() on JMS CorrelationId call:

    Code snippet:
    message = (TextMessage) jmsTemplate.receiveSelected(responseQueue, resSelectorId);
    resp = message.getText();

    Did I miss anything related to changes I needed to make to be compatible with Spring 2.5??? This application has been stable for many months and I was trying to upgrade to the latest Spring release to stay current and to address a JDBC issue that recently surfaced...


    Any thoughts, suggestions are most appreciated...

    Thanks.

  • #2
    So I suppose what's actually null there is the received message? The NPE caused by the "message.getText()" call?

    I wonder what Spring 2.5 would do differently than Spring 2.0.7 there... What does your JMS setup look like?

    Juergen

    Comment


    • #3
      Hi Juergen,

      Thanks for responding to the issue I was seeing...

      Here is a snippet of the Spring XML file for this area:

      <?xml version="1.0" encoding="UTF-8"?>
      <beans xmlns="http://www.springframework.org/schema/beans"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://www.springframework.org/schema/beans
      http://www.springframework.org/schema/beans/spring-beans.xsd">


      <!-- VTV Analyzer Request Queue -->
      <bean id="vtvAnalyzerRequestQueue"
      class="com.sun.messaging.Queue">
      <constructor-arg value="vtvAnalyzerRequestQueue" />
      </bean>

      <!-- VTV Analyzer Response Queue -->
      <bean id="vtvAnalyzerResponseQueue"
      class="com.sun.messaging.Queue">
      <constructor-arg value="vtvAnalyzerResponseQueue" />
      </bean>

      <!-- Internal JMS Queue Connection Factory -->

      <!-- A Pooled Based JMS Provider -->
      <bean id="jmsFactory" class="com.sun.messaging.ConnectionFactory">
      </bean>

      <bean id="topicFactory"
      class="com.sun.messaging.ConnectionFactory">
      </bean>

      </beans>

      Let me know if you have any questions or suggestions.

      Thanks again for looking into the exception I observed...

      Comment


      • #4
        I had a similar problem, setting lazy-init to false appears to have solved my issue, still trying to figure out why.

        Here's how you set lazy-init to false:

        Code:
        <beans default-lazy-init="false">

        Comment


        • #5
          Hi,

          I tested your solution without success... I am still receiving the null pointer from the JMS receive(). Not sure what is causing the issue since it works in an older 2.0.7 version. I do like the option to turn off lazy-init and fail fast...

          Thanks for the suggestion... I am still looking trying to upgrade to the latest Spring release...

          Comment


          • #6
            Mystery Solved between Spring 2.0.7 and 2.5.4 JMS receive() issues

            There was a subtle change in the Spring JmsTemplate between 2.0.7 and 2.5.x that caused the issues observed with a Null Message being returned on a receive() [waiting forever for a Message]. The change made seems to be related to making the Spring JmsTemplate more compliant with the JMS standard. The change made was related to the value used to indicate a blocking[WAIT] receive() timeout value call, in 2.0.7 that value was a '-1', in 2.5.4 it is now a '0'.... This subtle change caused me to become a client of the hair-club, since I had ripped out large sections while debugging this nasty side-effect..

            All is well now...

            Spring JmsTemplate 2.0.7 code:
            Code:
            public class JmsTemplate extends JmsDestinationAccessor implements JmsOperations {
            
            	/**
            	 * Default timeout for receive operations:
            	 * -1 indicates a blocking receive without timeout.
            	 */
            	public static final long DEFAULT_RECEIVE_TIMEOUT = -1;


            Spring JmsTemplate 2.5.4 code:
            Code:
            public class JmsTemplate extends JmsDestinationAccessor implements JmsOperations {
            
            	/**
            	 * Timeout value indicating that a receive operation should
            	 * check if a message is immediately available without blocking.
            	 */
            	public static final long RECEIVE_TIMEOUT_NO_WAIT = -1;
            
            	/**
            	 * Timeout value indicating a blocking receive without timeout.
            	 */
            	public static final long RECEIVE_TIMEOUT_INDEFINITE_WAIT = 0;

            Comment

            Working...
            X