Announcement Announcement Module
Collapse
No announcement yet.
Spring-JMS with Glassfish Exception Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Spring-JMS with Glassfish Exception

    Hi,

    I have an application which is built using spring-jms and I am trying to get it to work with Glassfish.

    When I deploy my app I get the following exception:

    Code:
    Caused by: javax.jms.JMSException: MQJMSRA_DC2001: Unsupported:setExceptionListener():inACC=false:connectionId=7397227676621758721
    	at com.sun.messaging.jms.ra.DirectConnection._unsupported(DirectConnection.java:982)
    	at com.sun.messaging.jms.ra.DirectConnection.setExceptionListener(DirectConnection.java:505)
    	at org.springframework.jms.connection.SingleConnectionFactory.prepareConnection(SingleConnectionFactory.java:364)
    	at org.springframework.jms.connection.SingleConnectionFactory.initConnection(SingleConnectionFactory.java:289)
    	at org.springframework.jms.connection.SingleConnectionFactory.createConnection(SingleConnectionFactory.java:225)
    	at org.springframework.jms.support.JmsAccessor.createConnection(JmsAccessor.java:184)
    	at org.springframework.jms.listener.AbstractJmsListeningContainer.createSharedConnection(AbstractJmsListeningContainer.java:404)
    	at org.springframework.jms.listener.AbstractJmsListeningContainer.establishSharedConnection(AbstractJmsListeningContainer.java:372)
    	at org.springframework.jms.listener.AbstractJmsListeningContainer.doStart(AbstractJmsListeningContainer.java:279)
    	at org.springframework.jms.listener.SimpleMessageListenerContainer.doStart(SimpleMessageListenerContainer.java:224)
    	at org.springframework.jms.listener.AbstractJmsListeningContainer.start(AbstractJmsListeningContainer.java:264)
    I have defined my beans as follows:

    Code:
    <bean id="jndiTemplate" class="org.springframework.jndi.JndiTemplate">
            <property name="environment">
                <props>
                    <prop key="java.naming.factory.initial">com.sun.enterprise.naming.SerialInitContextFactory</prop>
                    <prop key="java.naming.factory.url.pkgs">com.sun.enterprise.naming</prop>
                    <prop key="java.naming.factory.state">com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl</prop>
                </props>
            </property>
        </bean>
    
        <bean id="queueConnectionFactory" class="org.springframework.jndi.JndiObjectFactoryBean">
            <property name="jndiTemplate" ref="jndiTemplate"/>
            <property name="jndiName" value="jms/QueueConnectionFactory"/>
            <property name="lookupOnStartup" value="false"/>
            <property name="cache" value="false"/>
            <property name="proxyInterface" value="javax.jms.QueueConnectionFactory"/>
        </bean>
    
        <bean id="cachingConnectionFactory" class="org.springframework.jms.connection.CachingConnectionFactory" destroy-method="destroy">
            <property name="targetConnectionFactory" ref="queueConnectionFactory"/>
            <property name="reconnectOnException" value="true"/>
            <property name="sessionCacheSize" value="100"/>
        </bean>
    
        <bean id="singleConnectionFactory" class="org.springframework.jms.connection.SingleConnectionFactory" destroy-method="destroy">
            <property name="targetConnectionFactory" ref="queueConnectionFactory"/>
            <property name="reconnectOnException" value="true"/>
        </bean>
    
        <bean id="receiveQueue" class="org.springframework.jndi.JndiObjectFactoryBean">
            <property name="jndiTemplate" ref="jndiTemplate"/>
            <property name="jndiName" value="jms/ReceiveQueue"/>
        </bean>
    
        <bean id="sendQueue" class="org.springframework.jndi.JndiObjectFactoryBean">
            <property name="jndiTemplate" ref="jndiTemplate"/>
            <property name="jndiName" value="jms/SendQueue"/>
        </bean>
    
        <bean id="jmsTemplate" class="org.springframework.jms.core.JmsTemplate">
            <property name="connectionFactory" ref="singleConnectionFactory"/>
            <property name="defaultDestination" ref="sendQueue"/>
        </bean>
    
        <bean id="jmsMessageListener" class="example1.JmsMessageListener"/>
    
        <bean id="container" class="org.springframework.jms.listener.SimpleMessageListenerContainer">
            <property name="connectionFactory" ref="singleConnectionFactory"/>
            <property name="messageListener" ref="jmsMessageListener"/>
            <property name="exceptionListener" ref="jmsMessageListener"/>
            <property name="destination" ref="receiveQueue"/>
        </bean>
    I seem to see some information about the "reconnectOnException" property mentioned in a few places, but the information I find is loose and vague. I have tried setting true and false on it with little effect.

    Can anyone help out?

    Many Thanks

  • #2
    It seems odd that the provider doesn't support setExceptionListener().

    In order to prevent Spring from setting it, you need to remove the "exceptionListener" property on the container, and leave "reconnectOnException" at its default (false).

    Comment


    • #3
      Originally posted by Gary Russell View Post
      It seems odd that the provider doesn't support setExceptionListener().

      In order to prevent Spring from setting it, you need to remove the "exceptionListener" property on the container, and leave "reconnectOnException" at its default (false).

      Gary,

      Thanks. I have set the reconnectOnException to false (and also tried ommited), and removed the exceptionListener and that gives me the following exception:

      Code:
      [#|2012-12-03T15:57:13.249+0000|INFO|glassfish3.1.1|org.glassfish.admingui|_ThreadID=25;_ThreadName=Thread-2
      ;|Exception Occurred :Error occurred during deployment: Exception while loading the app : java.lang.IllegalStateException: 
      ContainerBase.addChild: start: org.apache.catalina.LifecycleException: org.springframework.context.ApplicationContextException: 
      Failed to start bean 'container'; nested exception is org.springframework.jms.IllegalStateException: setExceptionListener call not 
      supported on proxy for shared Connection. Set the 'exceptionListener' property on the SingleConnectionFactory instead. 
      Alternatively, activate SingleConnectionFactory's 'reconnectOnException' feature, which will allow for registering further 
      ExceptionListeners to the recovery chain.; nested exception is javax.jms.IllegalStateException: setExceptionListener call not 
      supported on proxy for shared Connection. Set the 'exceptionListener' property on the SingleConnectionFactory instead. 
      Alternatively, activate SingleConnectionFactory's 'reconnectOnException' feature, which will allow for registering further 
      ExceptionListeners to the recovery chain.. Please see server.log for more details.|#]
      If I do as it says and set the exceptionListener property on the SingleConnectionFactory I get the same exception as the original post.

      Thanks

      Chris

      Comment


      • #4
        Yeah, I forgot the container adds itself as an ExceptionListener.

        Try switching to a DefaultMessageListenerContainer instead of SimpleMessageListenerContainer.

        If that doesn't work, you'll have to explore why glassfish doesn't support this important method.

        Comment


        • #5
          Originally posted by Gary Russell View Post
          Yeah, I forgot the container adds itself as an ExceptionListener.

          Try switching to a DefaultMessageListenerContainer instead of SimpleMessageListenerContainer.

          If that doesn't work, you'll have to explore why glassfish doesn't support this important method.
          Gary,

          That done the job. Thank you for your help.

          Chris

          Comment


          • #6
            Looks like I spoke to soon. Even though the app now deploys there are still problems:

            My beans are:

            Code:
            <bean id="jndiTemplate" class="org.springframework.jndi.JndiTemplate">
                    <property name="environment">
                        <props>
                            <prop key="java.naming.factory.initial">com.sun.enterprise.naming.SerialInitContextFactory</prop>
                            <prop key="java.naming.factory.url.pkgs">com.sun.enterprise.naming</prop>
                            <prop key="java.naming.factory.state">com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl</prop>
                        </props>
                    </property>
                </bean>
            
                <bean id="queueConnectionFactory" class="org.springframework.jndi.JndiObjectFactoryBean">
                    <property name="jndiTemplate" ref="jndiTemplate"/>
                    <property name="jndiName" value="jms/QueueConnectionFactory"/>
                    <property name="lookupOnStartup" value="false"/>
                    <property name="cache" value="false"/>
                    <property name="proxyInterface" value="javax.jms.QueueConnectionFactory"/>
                </bean>
            
                <bean id="cachingConnectionFactory" class="org.springframework.jms.connection.CachingConnectionFactory" destroy-method="destroy">
                    <property name="targetConnectionFactory" ref="queueConnectionFactory"/>
                    <property name="reconnectOnException" value="false"/>
                    <property name="sessionCacheSize" value="100"/>
                    <property name="exceptionListener" ref="jmsMessageListener"/>
                </bean>
            
                <bean id="receiveQueue" class="org.springframework.jndi.JndiObjectFactoryBean">
                    <property name="jndiTemplate" ref="jndiTemplate"/>
                    <property name="jndiName" value="jms/ReceiveQueue"/>
                </bean>
            
                <bean id="sendQueue" class="org.springframework.jndi.JndiObjectFactoryBean">
                    <property name="jndiTemplate" ref="jndiTemplate"/>
                    <property name="jndiName" value="jms/SendQueue"/>
                </bean>
            
                <bean id="jmsTemplate" class="org.springframework.jms.core.JmsTemplate">
                    <property name="connectionFactory" ref="cachingConnectionFactory"/>
                    <property name="defaultDestination" ref="sendQueue"/>
                </bean>
            
                <bean id="jmsMessageListener" class="example1.JmsMessageListener"/>
            
                <bean id="container" class="org.springframework.jms.listener.DefaultMessageListenerContainer">
                    <property name="connectionFactory" ref="cachingConnectionFactory"/>
                    <property name="messageListener" ref="jmsMessageListener"/>
                    <property name="destination" ref="receiveQueue"/>
                </bean>
            The log file states:

            Code:
            [#|2012-12-04T09:48:34.539+0000|WARNING|glassfish3.1.1|javax.jms.Connection.mqjmsra|_ThreadID=17;_ThreadName=Thread-2;|MQJMSRA_DC2001: Unsupported:setExceptionListener():inACC=false:connectionId=64241601027680768|#]
            
            [#|2012-12-04T09:48:34.539+0000|WARNING|glassfish3.1.1|org.springframework.jms.listener.DefaultMessageListenerContainer|_ThreadID=17;_ThreadName=Thread-2;|Could not refresh JMS Connection for destination 'Oracle GlassFish(tm) Server MQ Destination
            getName():		ReceiveQueue
            Class:			com.sun.messaging.Queue
            getVERSION():		3.0
            isReadonly():		false
            getProperties():	{imqDestinationName=ReceiveQueue, imqDestinationDescription=A Description for the Destination Object}' - retrying in 5000 ms. Cause: MQJMSRA_DC2001: Unsupported:setExceptionListener():inACC=false:connectionId=64241601027680768|#]
            Chris

            Comment


            • #7
              I am out of ideas; like I said, it is odd that the provider doesn't support this method.

              I don't have time right now to dig into GlassFish, sorry.

              Comment


              • #8
                Thanks Gary, I will look at the Glassfish side and see what I can find out.

                Comment

                Working...
                X