Results 1 to 2 of 2

Thread: Hibernate + DefaultMessageListenerContainer102

  1. #1
    Join Date
    Nov 2007
    Posts
    13

    Default Hibernate + DefaultMessageListenerContainer102

    Hello,
    I have been strugging with this for several days now. I have written a listener that listens on a JMS MQ using the spring DefaultMessageListenerContainer102. I retrieve the message properly, however when I try to update the database in my messageListener, I am getting this exception:

    Code:
    8/5/08 17:17:12:250 EDT] 00000026 javaURLContex E   NMSV0310E: A JNDI operation on a "java:" name cannot be completed because the server runtime is not able to associate the operation's thread with any J2EE application component. This condition can occur when the JNDI client using the "java:" name is not executed on the thread of a server application request. Make sure that a J2EE application does not execute JNDI operations on "java:" names within static code blocks or in threads created by that J2EE application. Such code does not necessarily run on the thread of a server application request and therefore is not supported by JNDI operations on "java:" names. Exception stack trace: 
    javax.naming.ConfigurationException [Root exception is javax.naming.NameNotFoundException: Name comp/websphere not found in context "java:".]
    	at com.ibm.ws.naming.java.javaURLContextImpl.	... 37 more
    I have wrapped my service in a tranaction as follows:

    Code:
    public void saveOrUpdate(Interview interview) {
    		transactionTemplate.execute(new TransactionCallbackWithoutResult() {
    			protected void doInTransactionWithoutResult(TransactionStatus status) {
    				Interview interview = new Interview();
    				interview.setId(111);
    				interview.setCallerId("11111111");
    				idao.saveOrUpdate(interview);
    			}
    		});
    	}
    I am trying to use the websphere transaction manager in my configuration file as follows:
    Code:
    	<bean id="jmsTemplate"
    		class="org.springframework.jms.core.JmsTemplate102"
    		lazy-init="true">
    		<property name="connectionFactory" ref="connectionFactory" />
    		<property name="defaultDestination" ref="destination" />
    		<property name="transactionManager" ref="transactionManager" />
    		<property name="sessionTransacted" value="true" />
    	</bean>
    	<bean id="jmsTemplateACK"
    		class="org.springframework.jms.core.JmsTemplate102"
    		lazy-init="true">
    		<property name="connectionFactory" ref="connectionFactory" />
    		<property name="defaultDestination" ref="ackDestination" />
    	</bean>
    
    	<bean id="connectionFactory"
    		class="org.springframework.jndi.JndiObjectFactoryBean">
    		<property name="jndiName" value="jms/LOCALTQAQCF" />
    	</bean>
    
    	<bean id="destination"
    		class="org.springframework.jndi.JndiObjectFactoryBean">
    		<property name="jndiName" value="jms/LOCALMQQueue" />
    	</bean>
    
    	<bean id="ackDestination"
    		class="org.springframework.jndi.JndiObjectFactoryBean">
    		<property name="jndiName" value="jms/LOCALMQAckQueue" />
    	</bean>
    	<bean id="errorDestination"
    		class="org.springframework.jndi.JndiObjectFactoryBean">
    		<property name="jndiName" value="jms/LOCALMQErrorQueue" />
    	</bean>
    
    	<bean id="transactionManager"
    		class="org.springframework.transaction.jta.WebSphereUowTransactionManager">
    		<property name="autodetectTransactionManager" value="false" />
    	</bean>
    
    	<bean id="listener"
    		class="org.springframework.jms.listener.adapter.MessageListenerAdapter102">
    		<property name="delegate" ref="ackprocessor" />
    		<property name="defaultListenerMethod" value="ProcessAck" />
    	</bean>
    
    	<bean id="container"
    		class="org.springframework.jms.listener.DefaultMessageListenerContainer102">
    		<property name="connectionFactory" ref="connectionFactory" />
    		<property name="messageListener" ref="listener" />
    		<property name="destination" ref="ackDestination" />
    		<property name="sessionTransacted" value="true" />
    		<property name="transactionManager" ref="transactionManager" />
    	</bean>
    	<bean id="ackprocessor"
    		class="org.messaging.AcknowledgmentListener">
    		<property name="iservice" ref="interviewService" />
    	</bean>
    	
    	
    
    
    
    	<!--  
    		
    
    
    	<bean id="dataSource"
    		class="org.springframework.jndi.JndiObjectFactoryBean">
    		<property name="jndiName" value="jdbc/tqa" />
    		<property name="lookupOnStartup" value="true" />
    		<property name="cache" value="false" />
    		<property name="proxyInterface" value="javax.sql.DataSource" />
    	</bean>
    
    	<!-- Hibernate SessionFactory -->
    	<bean id="sessionFactory"
    		class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
    		<property name="dataSource" ref="dataSource" />
    		<property name="mappingResources">
    			<list>
    				<value>Interview.hbm.xml</value>
    			</list>
    		</property>
    		<property name="hibernateProperties">
    			<props>
    				<prop key="hibernate.dialect">
    					org.hibernate.dialect.Oracle10gDialect
    				</prop>
    				<prop key="hibernate.show_sql">true</prop>
    				<!--    IBM WAS SPECIFIC    -->
    				<prop key="hibernate.connection.datasource">
    					jdbc/tqa
    				</prop>
    				<prop key="hibernate.transaction.factory_class">
    					org.hibernate.transaction.CMTTransactionFactory
    				</prop>
    				<prop
    					key="hibernate.transaction.manager_lookup_class">
    					org.hibernate.transaction.WebSphereExtendedJTATransactionLookup
    				</prop>
    				<!--    /END IBM WAS SPECIFIC         -->
    			</props>
    		</property>
    	</bean>
    	<bean id="interviewDAO"
    		class="org.dao.InterviewDAOImpl">
    		<property name="sessionFactory" ref="sessionFactory" />
    		
    	</bean>
    
    	<bean id="interviewService"
    		class="org.services.database.interviewService">
    		<constructor-arg><ref bean="transactionManager"/></constructor-arg> 
    		<property name="idao" ref="interviewDAO" /> 
    
    	</bean>
    
    
    
    </beans>
    I would really appreciate some insite as I have scoured the documentation and don't know where to proceed with this.
    Last edited by pshah; Aug 5th, 2008 at 04:36 PM. Reason: formatting

  2. #2
    Join Date
    Nov 2007
    Posts
    13

    Default modification

    I've spent another day working on this with no avail. It seems that I cannot update the database when I'm inside the DefaultMessageListenerContainer. I get this wierd JNDI exception when I try to make a call to my DAO. Has anyone every tried to write a database inside the MDP container. Does this error mean that my web app references are wrong, or is there a problem with my transaction framework. I'am utilizing the websphere specific transaction manager. My environment: Spring 2.5 Hibernate Websphere 6.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •