Hi,
I am using Spring 1.1.1 and hibernate 2.1.6 with Oracle 9i and JBOss 3.2.3. We need to use JtaTransactionManager as we need both jms and hiberanate calls in same method. I setup an xa capable datasource in JBoss and it is working fine and i am getting the connection factory from java:/JmsXA location as from Jboss docs i get to know that it is how it is setup. Now if i use only hibernate it works fine with xa datasourec and jta transaction manager without any problem (using oracle xa datasource and setting pad to true). But when i enable the jms usage (by using jmsTemplate and xa aware donnectioFactory) it gave error as it tries to commit locally and i get the exception TransactionInProgress. I dont know why it is happening all my resources are xa aware and coming from app server jndi.... It should be managed properly by JtaTransactiion manager. Why dont i ma getting distributed transaction and why not spring idetects that their is ongoing jta transaction and it should participate in it. Why?????. Why does it tries to commit it locally ......it is the duty of jta transaction manager to commit not of session. Is it some bug that JmsTemplate102 not detect ongoing xa transaction or is there any error in my configuration. Please help me asap
My code is as follows
This class is used from foloowing class which first use Hibernate to save the domain objectCode:// JmsTopicSender.java package com.sequelsys.server.scheduling.jms; import javax.jms.*; import org.springframework.jms.core.*; public class JmsTopicSender { private JmsTemplate102 jt; private ConnectionFactory connectionFactory; private Topic topic; public void simpleSend() { jt = new JmsTemplate102(connectionFactory, true); jt.send(topic, new MessageCreator() { public Message createMessage(Session session) throws JMSException { return session.createTextMessage("Record inserted succefully"); } }); } public void setConnectionFactory(ConnectionFactory cf) { connectionFactory = cf; } public void setTopic(Topic q) { topic = q; } }
The application context file is as followsCode:package com.sequelsys.server.scheduling.service; import org.springframework.dao.*; import com.sequelsys.common.businessservice.scheduling.*; import com.sequelsys.common.model.scheduling.*; import com.sequelsys.server.scheduling.dao.*; import com.sequelsys.server.scheduling.jms.JmsTopicSender; public class HolidayScheduleService implements IHolidayScheduleService { private IHolidayScheduleDAO holidayScheduleDAO; private JmsTopicSender jmsTopicSender; public void setHolidayScheduleDAO(IHolidayScheduleDAO holidayScheduleDAO) { this.holidayScheduleDAO = holidayScheduleDAO; } public void setJmsTopicSender(JmsTopicSender jmsTopicSender) { this.jmsTopicSender = jmsTopicSender; } public IHolidayScheduleDAO getHolidayScheduleDAO() { return holidayScheduleDAO; } public JmsTopicSender getJmsTopicSender() { return jmsTopicSender; } public HolidayScheduleService() { } public HolidaysScheduleModel createHolidaySchedule(HolidayScheduleBusinessService holidayScheduleBusinessService) throws DataAccessException { HolidaysScheduleModel holidaysScheduleModel = this.holidayScheduleDAO.create(holidayScheduleBusinessService.getHolidaysScheduleModel()); //HolidaysScheduleModel holidaysScheduleModel = new HolidaysScheduleModel(); this.jmsTopicSender.simpleSend(); return holidaysScheduleModel; } }
and web.xml isCode:<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd"> <!-- - Application context definition for Petclinic on Hibernate. --> <beans> <!-- ========================= RESOURCE DEFINITIONS ========================= --> <bean id="messageSource" class="org.springframework.context.support.ResourceBundleMessageSource"> <property name="basename"> <value>messages</value> </property> </bean> <!-- JNDI DataSource for J2EE environments --> <bean id="dataSource" class="org.springframework.jndi.JndiObjectFactoryBean"> <property name="jndiName"><value>java:/XAOracleDS</value></property> </bean> <!-- Hibernate SessionFactory --> <bean id="sessionFactory" class="org.springframework.orm.hibernate.LocalSessionFactoryBean"> <property name="dataSource"><ref local="dataSource"/></property> <property name="mappingResources"> <value>com/sequelsys/common/model/scheduling/HolidaysSchedule.hbm.xml</value> </property> <property name="hibernateProperties"> <props> <prop key="hibernate.dialect">net.sf.hibernate.dialect.Oracle9Dialect</prop> <prop key="hibernate.show_sql">true</prop> <!-- These lines are only required if we r using Jta transaction manager. They ensure jvm level caching and appropriate callbacks for jvm--> <!-- <prop key="hibernate.transaction.manager_lookup_class">net.sf.hibernate.transaction.JBossTransactionManagerLookup</prop> <prop key="hibernate.jta.UserTransaction">java:comp/UserTransaction</prop> --> </props> </property> </bean> <!-- Transaction manager for a single Hibernate SessionFactory (alternative to JTA) --> <!-- <bean id="transactionManager" class="org.springframework.orm.hibernate.HibernateTransactionManager"> <property name="sessionFactory"><ref local="sessionFactory"/></property> </bean> --> <bean id="transactionManager" class="org.springframework.transaction.jta.JtaTransactionManager"> <property name="transactionManagerName"><value>java:/TransactionManager</value></property> </bean> <bean id="holidayScheduleDAO" class="com.sequelsys.server.scheduling.dao.HolidayScheduleDAO"> <property name="sessionFactory"><ref local="sessionFactory"/></property> </bean> <bean id="connectionFactory" class="org.springframework.jndi.JndiObjectFactoryBean"> <property name="jndiName"><value>jms/connectionFactory</value></property> <property name="resourceRef"><value>true</value></property> </bean> <bean id="destination" class="org.springframework.jndi.JndiObjectFactoryBean"> <property name="jndiName"><value>jms/topic</value></property> <property name="resourceRef"><value>true</value></property> </bean> <bean id="jmsTopicSender" class="com.sequelsys.server.scheduling.jms.JmsTopicSender"> <property name="connectionFactory"><ref local="connectionFactory"/></property> <property name="topic"><ref local="destination"/></property> </bean> <!-- ========================= BUSINESS OBJECT DEFINITIONS ========================= --> <!-- - A parent bean definition which is a base definition for transaction proxies. - It is markes as abstract, since it is never supposed to be instantiated itself. - We set shared transaction attributes here, following our naming patterns. - The attributes can still be overridden in child bean definitions. --> <bean id="baseTransactionProxy" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean" abstract="true"> <property name="transactionManager"><ref bean="transactionManager"/></property> <property name="transactionAttributes"> <props> <prop key="get*">PROPAGATION_REQUIRED,readOnly</prop> <prop key="find*">PROPAGATION_REQUIRED,readOnly</prop> <prop key="load*">PROPAGATION_REQUIRED,readOnly</prop> <prop key="create*">PROPAGATION_REQUIRED</prop> </props> </property> </bean> <bean id="holidayScheduleService" parent="baseTransactionProxy"> <property name="target"> <bean class="com.sequelsys.server.scheduling.service.HolidayScheduleService"> <property name="holidayScheduleDAO"><ref local="holidayScheduleDAO"/></property> <property name="jmsTopicSender"><ref local="jmsTopicSender"/></property> </bean> </property> </bean> <bean id="schedulingFacade" class="com.sequelsys.server.common.service.SchedulingFacade"> <property name="messageSource"><ref local="messageSource"/></property> <property name="holidayScheduleService"><ref local="holidayScheduleService"/></property> </bean> </beans>
jboss.xml is asCode:<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE web-app PUBLIC '-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN' 'http://java.sun.com/dtd/web-app_2_3.dtd'> <!-- - $Id: web.xml,v 1.1 2004/08/01 23:03:20 benalex Exp $ --> <web-app> <display-name>SampleProject</display-name> <description> Provides an example for using Spring framework </description> <!-- - Location of the XML file that defines the root application context - Applied by ContextLoaderListener. --> <context-param> <param-name>contextConfigLocation</param-name> <param-value>/WEB-INF/applicationContext-hibernate.xml</param-value> </context-param> <!-- - Loads the root application context of this web app at startup, - by default from "/WEB-INF/applicationContext.xml". - Use WebApplicationContextUtils.getWebApplicationContext(servletContext) - to access it anywhere in the web application, outside of the framework. --> <listener> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> </listener> <servlet> <servlet-name>ws</servlet-name> <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> <load-on-startup>2</load-on-startup> </servlet> <!-- - Dispatcher servlet mapping for HTTP web services. - (see ws-servlet.xml for the controllers). --> <servlet-mapping> <servlet-name>ws</servlet-name> <url-pattern>/ws/*</url-pattern> </servlet-mapping> <resource-env-ref> <resource-env-ref-name>jms/topic</resource-env-ref-name> <resource-env-ref-type>javax.jms.Topic</resource-env-ref-type> </resource-env-ref> <resource-ref> <description>JMS Connection Factory</description> <res-ref-name>jms/connectionFactory</res-ref-name> <res-type>javax.jms.TopicConnectionFactory</res-type> <res-auth>Container</res-auth> <res-sharing-scope>Shareable</res-sharing-scope> </resource-ref> </web-app>
thouh not as relevant the DAO is asCode:<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE jboss-web PUBLIC "-//JBoss//DTD Web Application 2.3V2//EN" "http://www.jboss.org/j2ee/dtd/jboss-web_3_2.dtd"> <jboss-web> <context-root>SampleProjectModule</context-root> <resource-env-ref> <resource-env-ref-name>jms/topic</resource-env-ref-name> <jndi-name>topic/EMRTopic</jndi-name> </resource-env-ref> <resource-ref> <res-ref-name>jms/connectionFactory</res-ref-name> <res-type>javax.jms.TopicConnectionFactory</res-type> <jndi-name>java:/JmsXA</jndi-name> <res-auth>Container</res-auth> </resource-ref> </jboss-web>
I am getting the following exceptionCode:package com.sequelsys.server.scheduling.dao; import org.springframework.dao.*; import org.springframework.orm.hibernate.support.*; import com.sequelsys.common.model.scheduling.*; public class HolidayScheduleDAO extends HibernateDaoSupport implements IHolidayScheduleDAO { public HolidayScheduleDAO() { } public HolidaysScheduleModel create(HolidaysScheduleModel holidaysScheduleModel) throws DataAccessException { Long seqNo = (Long) this.getHibernateTemplate().save(holidaysScheduleModel); holidaysScheduleModel.setSeqNum(seqNo); return holidaysScheduleModel; } }
I am quite sure that db part is working fine but jms somehow dont know the transaction. Please do it asapCode:19:07:16,021 ERROR [STDERR] org.springframework.jms.TransactionInProgressException: Should not be call from a XASession; nested exception is javax.jms.TransactionInProgressException: Should not be call from a XASession; nested exception is javax.jms.TransactionInProgressException: Should not be call from a XASession 19:07:16,021 ERROR [STDERR] javax.jms.TransactionInProgressException: Should not be call from a XASession 19:07:16,021 ERROR [STDERR] at org.jboss.mq.SpySession.commit(SpySession.java:410) 19:07:16,021 ERROR [STDERR] at org.jboss.resource.adapter.jms.JmsSession.commit(JmsSession.java:166) 19:07:16,068 ERROR [STDERR] at org.springframework.jms.core.JmsTemplate.doSend(JmsTemplate.java:609) 19:07:16,068 ERROR [STDERR] at org.springframework.jms.core.JmsTemplate$2.doInJms(JmsTemplate.java:583) 19:07:16,068 ERROR [STDERR] at org.springframework.jms.core.JmsTemplate.execute(JmsTemplate.java:548) 19:07:16,068 ERROR [STDERR] at org.springframework.jms.core.JmsTemplate.execute(JmsTemplate.java:560) 19:07:16,068 ERROR [STDERR] at org.springframework.jms.core.JmsTemplate.send(JmsTemplate.java:581) 19:07:16,084 ERROR [STDERR] at com.sequelsys.server.scheduling.jms.JmsTopicSender.simpleSend(JmsTopicSender.java:13) 19:07:16,084 ERROR [STDERR] at com.sequelsys.server.scheduling.service.HolidayScheduleService.createHolidaySchedule(HolidayScheduleService.java:37) 19:07:16,084 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 19:07:16,084 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) 19:07:16,084 ERROR [STDERR] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) 19:07:16,084 ERROR [STDERR] at java.lang.reflect.Method.invoke(Method.java:324) 19:07:16,084 ERROR [STDERR] at org.springframework.aop.framework.AopProxyUtils.invokeJoinpointUsingReflection(AopProxyUtils.java:61) 19:07:16,084 ERROR [STDERR] at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:149) 19:07:16,084 ERROR [STDERR] at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:116) 19:07:16,084 ERROR [STDERR] at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:56) 19:07:16,099 ERROR [STDERR] at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:138) 19:07:16,099 ERROR [STDERR] at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:152) 19:07:16,099 ERROR [STDERR] at $Proxy30.createHolidaySchedule(Unknown Source) 19:07:16,099 ERROR [STDERR] at com.sequelsys.server.common.service.SchedulingFacade.createHolidaySchedule(SchedulingFacade.java:37) 19:07:16,099 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 19:07:16,099 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) 19:07:16,099 ERROR [STDERR] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) 19:07:16,099 ERROR [STDERR] at java.lang.reflect.Method.invoke(Method.java:324) 19:07:16,099 ERROR [STDERR] at org.springframework.aop.framework.AopProxyUtils.invokeJoinpointUsingReflection(AopProxyUtils.java:61) 19:07:16,099 ERROR [STDERR] at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:142) 19:07:16,099 ERROR [STDERR] at $Proxy30.createHolidaySchedule(Unknown Source) 19:07:16,099 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 19:07:16,099 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) 19:07:16,099 ERROR [STDERR] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) 19:07:16,099 ERROR [STDERR] at java.lang.reflect.Method.invoke(Method.java:324) 19:07:16,099 ERROR [STDERR] at org.springframework.remoting.support.RemoteInvocation.invoke(RemoteInvocation.java:179) 19:07:16,115 ERROR [STDERR] at org.springframework.remoting.support.DefaultRemoteInvocationExecutor.invoke(DefaultRemoteInvocationExecutor.java:32) 19:07:16,115 ERROR [STDERR] at org.springframework.remoting.support.RemoteInvocationBasedExporter.invoke(RemoteInvocationBasedExporter.java:70) 19:07:16,115 ERROR [STDERR] at org.springframework.remoting.support.RemoteInvocationBasedExporter.invokeAndCreateResult(RemoteInvocationBasedExporter.java:106) 19:07:16,115 ERROR [STDERR] at org.springframework.remoting.httpinvoker.HttpInvokerServiceExporter.handleRequest(HttpInvokerServiceExporter.java:63) 19:07:16,115 ERROR [STDERR] at org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter.handle(SimpleControllerHandlerAdapter.java:44) 19:07:16,115 ERROR [STDERR] at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:522) 19:07:16,115 ERROR [STDERR] at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:321) 19:07:16,115 ERROR [STDERR] at javax.servlet.http.HttpServlet.service(HttpServlet.java:853) 19:07:16,115 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247) 19:07:16,115 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193) 19:07:16,115 ERROR [STDERR] at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:256) 19:07:16,115 ERROR [STDERR] at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643) 19:07:16,115 ERROR [STDERR] at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480) 19:07:16,115 ERROR [STDERR] at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995) 19:07:16,130 ERROR [STDERR] at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191) 19:07:16,130 ERROR [STDERR] at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643) 19:07:16,130 ERROR [STDERR] at org.jboss.web.tomcat.security.JBossSecurityMgrRealm.invoke(JBossSecurityMgrRealm.java:220) 19:07:16,130 ERROR [STDERR] at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641) 19:07:16,130 ERROR [STDERR] at org.apache.catalina.valves.CertificatesValve.invoke(CertificatesValve.java:246) 19:07:16,130 ERROR [STDERR] at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641) 19:07:16,130 ERROR [STDERR] at org.jboss.web.tomcat.tc4.statistics.ContainerStatsValve.invoke(ContainerStatsValve.java:76) 19:07:16,130 ERROR [STDERR] at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641) 19:07:16,146 ERROR [STDERR] at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480) 19:07:16,146 ERROR [STDERR] at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995) 19:07:16,146 ERROR [STDERR] at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2417) 19:07:16,146 ERROR [STDERR] at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180) 19:07:16,146 ERROR [STDERR] at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643) 19:07:16,146 ERROR [STDERR] at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:171) 19:07:16,146 ERROR [STDERR] at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641) 19:07:16,146 ERROR [STDERR] at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:172) 19:07:16,146 ERROR [STDERR] at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641) 19:07:16,146 ERROR [STDERR] at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:65) 19:07:16,146 ERROR [STDERR] at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641) 19:07:16,146 ERROR [STDERR] at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:577) 19:07:16,146 ERROR [STDERR] at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641) 19:07:16,162 ERROR [STDERR] at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480) 19:07:16,162 ERROR [STDERR] at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995) 19:07:16,162 ERROR [STDERR] at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174) 19:07:16,162 ERROR [STDERR] at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643) 19:07:16,162 ERROR [STDERR] at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480) 19:07:16,162 ERROR [STDERR] at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995) 19:07:16,162 ERROR [STDERR] at org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:197) 19:07:16,162 ERROR [STDERR] at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:781) 19:07:16,162 ERROR [STDERR] at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:549) 19:07:16,162 ERROR [STDERR] at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:605) 19:07:16,162 ERROR [STDERR] at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:677) 19:07:16,162 ERROR [STDERR] at java.lang.Thread.run(Thread.java:534)


Reply With Quote
. I don't have an answer off the top of my head, are you sure that the JMS connection you are using is an XAConnection? I'll quickly ping Jurgen to see if he can notice anything obvious. You can of course avoid the issue if you don't use the distributed transactions, that QOS may be a bit too heavy for a simple notification service, but I'd like to see your example working....
. Mark as i said in my post that according to JBOSS docs and forrum getting jms connection factory from java:/JmsXA means that it is XA aware. The db connection is doing well but no luck with jms, i posted some questions regarding this at jboss forrum but they seems to be very aggressive about spring and start terming it very bad framework and they damn care about it. I was shocked to see such a bad behavior from JBoss group it was pathetic of them so it seems the nice spring community can help me only. Urgently waiting for u r response.
