aspose file tools*
The moose likes Spring and the fly likes Spring JTA transaction manager JBOSS Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Spring
Bookmark "Spring JTA transaction manager JBOSS" Watch "Spring JTA transaction manager JBOSS" New topic
Author

Spring JTA transaction manager JBOSS

Sagar Kale
Ranch Hand

Joined: May 02, 2008
Posts: 188
I have spring beans which call SessionBean methods(EJB3) on JBOSS 4.2. I want to control transactions from Spring instead of session bean methods. So I tried to use JtaTransactionManager. But somehow it is not working.

I configured transaction manager in following way.





I get following exception.

org.springframework.beans.factory.BeanCreationException: Error creating bean wit
h name 'transactionManager' defined in ServletContext resource [/WEB-INF/classes
/beans.xml]: Invocation of init method failed; nested exception is java.lang.Ill
egalStateException: No JTA UserTransaction available - specify either 'userTrans
action' or 'userTransactionName' or 'transactionManager' or 'transactionManagerN
ame'
at org.springframework.beans.factory.support.AbstractAutowireCapableBean
Factory.initializeBean(AbstractAutowireCapableBeanFactory.java:1338)
at org.springframework.beans.factory.support.AbstractAutowireCapableBean
Factory.doCreateBean(AbstractAutowireCapableBeanFactory.java:473)
at org.springframework.beans.factory.support.AbstractAutowireCapableBean
Factory$1.run(AbstractAutowireCapableBeanFactory.java:409)
at java.security.AccessController.doPrivileged(Native Method)
at org.springframework.beans.factory.support.AbstractAutowireCapableBean
Factory.createBean(AbstractAutowireCapableBeanFactory.java:380)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getOb
ject(AbstractBeanFactory.java:264)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistr
y.getSingleton(DefaultSingletonBeanRegistry.java:222)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBe
an(AbstractBeanFactory.java:261)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean
(AbstractBeanFactory.java:185)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean
(AbstractBeanFactory.java:164)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.
preInstantiateSingletons(DefaultListableBeanFactory.java:429)
at org.springframework.context.support.AbstractApplicationContext.finish
BeanFactoryInitialization(AbstractApplicationContext.java:728)
at org.springframework.context.support.AbstractApplicationContext.refres
h(AbstractApplicationContext.java:380)
at org.springframework.web.struts.ContextLoaderPlugIn.createWebApplicati
onContext(ContextLoaderPlugIn.java:354)
at org.springframework.web.struts.ContextLoaderPlugIn.initWebApplication
Context(ContextLoaderPlugIn.java:295)
at org.springframework.web.struts.ContextLoaderPlugIn.init(ContextLoader
PlugIn.java:225)
at org.apache.struts.action.ActionServlet.initModulePlugIns(ActionServle
t.java:869)
at org.apache.struts.action.ActionServlet.init(ActionServlet.java:336)
at javax.servlet.GenericServlet.init(GenericServlet.java:212)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.
java:1161)
at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:98
1)
at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContex
t.java:4071)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4
375)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase
.java:790)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:77
0)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:553)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.j
ava:296)
at org.jboss.mx.server.RawDynamicInvoker.invoke(RawDynamicInvoker.java:1
64)
at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
at org.apache.catalina.core.StandardContext.init(StandardContext.java:53
12)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.j
ava:296)
at org.jboss.mx.server.RawDynamicInvoker.invoke(RawDynamicInvoker.java:1
64)
at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
at org.jboss.web.tomcat.service.TomcatDeployer.performDeployInternal(Tom
catDeployer.java:301)
at org.jboss.web.tomcat.service.TomcatDeployer.performDeploy(TomcatDeplo
yer.java:104)
at org.jboss.web.AbstractWebDeployer.start(AbstractWebDeployer.java:375)

at org.jboss.web.WebModule.startModule(WebModule.java:83)
at org.jboss.web.WebModule.startService(WebModule.java:61)
at org.jboss.system.ServiceMBeanSupport.jbossInternalStart(ServiceMBeanS
upport.java:289)
at org.jboss.system.ServiceMBeanSupport.jbossInternalLifecycle(ServiceMB
eanSupport.java:245)
at sun.reflect.GeneratedMethodAccessor3.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatch
er.java:155)
at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
at org.jboss.mx.server.Invocation.invoke(Invocation.java:86)
at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.
java:264)
at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
at org.jboss.system.ServiceController$ServiceProxy.invoke(ServiceControl
Sagar Kale
Ranch Hand

Joined: May 02, 2008
Posts: 188
Does anyone knows how to configure Spring JTA transaction for JBOSS 4.2.3 ?
Abel Ferreira
Greenhorn

Joined: Jul 24, 2009
Posts: 2
I got the same error. Does anyone knows how to cofigure correctly?
Eduardo Bueno
Ranch Hand

Joined: Jun 04, 2009
Posts: 155
I never managed to use JtaTransactionManager and JBoss, but this might be helpful to you.
Abel Ferreira
Greenhorn

Joined: Jul 24, 2009
Posts: 2
I got the solution. You have to remove any jta.jar from you application's classpath.
Configure his transactionManager bean as follow:



Although, I think if you do not set userTransactionName property, the "java:comp/UserTransaction" value will be used by default.
So you dont need to set this property.
As we can see at springFramework documentation:


For typical JTA transactions (REQUIRED, SUPPORTS, MANDATORY, NEVER), a plain JtaTransactionManager definition is all you need, completely portable across all J2EE servers. This corresponds to the functionality of the JTA UserTransaction, for which J2EE specifies a standard JNDI name ("java:comp/UserTransaction"). There is no need to configure a server-specific TransactionManager lookup for this kind of JTA usage.


Hope it helps you.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Spring JTA transaction manager JBOSS