PDA

View Full Version : Error while setting up JOTM 2.0.9 with Spring 1.2.6 and Tomcat 5.5.12



dkalcevich
Jan 10th, 2006, 12:37 PM
Everyone,

I am trying to setup JOTM within Spring and am running into some errors. My applicationContext.xml looks like this:

<bean id="jotm" class="org.springframework.transaction.jta.JotmFactoryBea n"/>

<bean id="transactionManager"
class="org.springframework.transaction.jta.JtaTransaction Manager">
<property name="userTransaction">
<ref local="jotm"/>
</property>
</bean>

<bean id="innerDataSource"
class="org.enhydra.jdbc.standard.StandardXADataSource"
destroy-method="shutdown">
<!--<property name="transactionManager" ref="jotm"/>-->
<property name="transactionManager">
<ref local="jotm"/>
</property>
<property name="driverName" value="com.inet.tds.TdsDriver"/>
<property name="url"
value="jdbc:inetdae7:sql_server:1433?database=db_DEV"/>
</bean>

<bean id="dataSource" class="org.enhydra.jdbc.pool.StandardXAPoolDataSource"
destroy-method="shutdown">
<property name="dataSource">
<ref local="innerDataSource"/>
</property>
<property name="user" value="user"/>
<property name="password" value="pass"/>
</bean>

<bean id="sqlMapClient"
class="org.springframework.orm.ibatis.SqlMapClientFactory Bean">
<property name="configLocation" value="WEB-INF/sqlmap-config.xml"/>
<property name="dataSource" ref="dataSource"/>
</bean>

<bean id="testDAO" class="test.TestDAOImpl">
<property name="sqlMapClient" ref="sqlMapClient"/>
</bean>

The exception i get when I startup Spring is:
2006-01-10 08:44:28,652 INFO [org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/MLSDataChecker]] - <2006-01-10 08:44:28,199 INFO [org.springframework.web.struts.ContextLoaderPlugIn] - <ContextLoaderPlugIn for Struts ActionServlet 'action, module '': initialization started>
2006-01-10 08:44:28,199 INFO [org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/MLSDataChecker]] - <Initializing WebApplicationContext for Struts ActionServlet 'action', module ''>
2006-01-10 08:44:28,293 INFO [org.springframework.beans.factory.xml.XmlBeanDefin itionReader] - <Loading XML bean definitions from ServletContext resource [/WEB-INF/action-servlet.xml]>
2006-01-10 08:44:28,387 INFO [org.springframework.web.context.support.XmlWebAppl icationContext] - <Bean factory for application context [WebApplicationContext for namespace 'action-servlet']: org.springframework.beans.factory.support.DefaultL istableBeanFactory defining beans [testBean,jotm,transactionManager,innerDataSource,d ataSource,sqlMapClient,testDAO]; root of BeanFactory hierarchy>
2006-01-10 08:44:28,402 INFO [org.springframework.web.context.support.XmlWebAppl icationContext] - <7 beans defined in application context [WebApplicationContext for namespace 'action-servlet']>
2006-01-10 08:44:28,402 INFO [org.springframework.core.CollectionFactory] - <JDK 1.4+ collections available>
2006-01-10 08:44:28,418 INFO [org.springframework.core.CollectionFactory] - <Commons Collections 3.x available>
2006-01-10 08:44:28,418 INFO [org.springframework.web.context.support.XmlWebAppl icationContext] - <Unable to locate MessageSource with name 'messageSource': using default [org.springframework.context.support.DelegatingMess ageSource@3e96cf]>
2006-01-10 08:44:28,434 INFO [org.springframework.web.context.support.XmlWebAppl icationContext] - <Unable to locate ApplicationEventMulticaster with name 'applicationEventMulticaster': using default [org.springframework.context.event.SimpleApplicatio nEventMulticaster@94af2f]>
2006-01-10 08:44:28,434 INFO [org.springframework.ui.context.support.UiApplicati onContextUtils] - <Unable to locate ThemeSource with name 'themeSource': using default [org.springframework.ui.context.support.ResourceBun dleThemeSource@28305d]>
2006-01-10 08:44:28,434 INFO [org.springframework.beans.factory.support.DefaultL istableBeanFactory] - <Pre-instantiating singletons in factory [org.springframework.beans.factory.support.DefaultL istableBeanFactory defining beans [testBean,jotm,transactionManager,innerDataSource,d ataSource,sqlMapClient,testDAO]; root of BeanFactory hierarchy]>
2006-01-10 08:44:28,496 INFO [org.objectweb.jotm] - <JOTM started with a local transaction factory which is not bound.>
2006-01-10 08:44:28,496 INFO [org.objectweb.jotm] - <CAROL initialization>
2006-01-10 08:44:28,496 INFO [org.objectweb.carol.util.configuration.Configurati onRepository] - <No protocols were defined for property 'carol.protocols', trying with default protocol = 'jrmp'.>
2006-01-10 08:44:28,574 INFO [org.objectweb.jotm.jta] - <JOTM 2.0.10>
2006-01-10 08:44:28,605 INFO [org.springframework.transaction.jta.JtaTransaction Manager] - <Using JTA UserTransaction: org.objectweb.jotm.Current@3468f4>
2006-01-10 08:44:28,605 INFO [org.springframework.transaction.jta.JtaTransaction Manager] - <Using JTA TransactionManager: org.objectweb.jotm.Current@3468f4>
2006-01-10 08:44:28,637 INFO [org.springframework.beans.factory.support.DefaultL istableBeanFactory] - <Destroying singletons in factory {org.springframework.beans.factory.support.Default ListableBeanFactory defining beans [testBean,jotm,transactionManager,innerDataSource,d ataSource,sqlMapClient,testDAO]; root of BeanFactory hierarchy}>
2006-01-10 08:44:28,637 INFO [org.objectweb.jotm] - <stop JOTM>
2006-01-10 08:44:28,637 ERROR [org.springframework.web.struts.ContextLoaderPlugIn] - <Context initialization failed>
org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'innerDataSource' defined in ServletContext resource [/WEB-INF/action-servlet.xml]: Error setting property values; nested exception is org.springframework.beans.PropertyAccessExceptions Exception: PropertyAccessExceptionsException (1 errors); nested propertyAccessExceptions are: [org.springframework.beans.TypeMismatchException: Failed to convert property value of type [org.objectweb.jotm.Current] to required type [javax.transaction.TransactionManager] for property 'transactionManager']
PropertyAccessExceptionsException (1 errors)
org.springframework.beans.TypeMismatchException: Failed to convert property value of type [org.objectweb.jotm.Current] to required type [javax.transaction.TransactionManager] for property 'transactionManager'
at org.springframework.beans.BeanWrapperImpl.doTypeCo nversionIfNecessary(BeanWrapperImpl.java:839)
at org.springframework.beans.BeanWrapperImpl.setPrope rtyValue(BeanWrapperImpl.java:584)
at org.springframework.beans.BeanWrapperImpl.setPrope rtyValue(BeanWrapperImpl.java:469)
at org.springframework.beans.BeanWrapperImpl.setPrope rtyValue(BeanWrapperImpl.java:626)
at org.springframework.beans.BeanWrapperImpl.setPrope rtyValues(BeanWrapperImpl.java:653)
at org.springframework.beans.BeanWrapperImpl.setPrope rtyValues(BeanWrapperImpl.java:642)
at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.applyPropertyValues(Abs tractAutowireCapableBeanFactory.java:1023)
at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.populateBean(AbstractAu towireCapableBeanFactory.java:824)
at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.createBean(AbstractAuto wireCapableBeanFactory.java:345)
at org.springframework.beans.factory.support.Abstract BeanFactory.getBean(AbstractBeanFactory.java:226)
at org.springframework.beans.factory.support.Abstract BeanFactory.getBean(AbstractBeanFactory.java:147)
at org.springframework.beans.factory.support.DefaultL istableBeanFactory.preInstantiateSingletons(Defaul tListableBeanFactory.java:275)
at org.springframework.context.support.AbstractApplic ationContext.refresh(AbstractApplicationContext.ja va:320)
at org.springframework.web.context.support.AbstractRe freshableWebApplicationContext.refresh(AbstractRef reshableWebApplicationContext.java:134)
at org.springframework.web.struts.ContextLoaderPlugIn .createWebApplicationContext(ContextLoaderPlugIn.j ava:353)
at org.springframework.web.struts.ContextLoaderPlugIn .initWebApplicationContext(ContextLoaderPlugIn.jav a:296)
at org.springframework.web.struts.ContextLoaderPlugIn .init(ContextLoaderPlugIn.java:225)
at org.apache.struts.action.ActionServlet.initModuleP lugIns(ActionServlet.java:869)
at org.apache.struts.action.ActionServlet.init(Action Servlet.java:336)
at javax.servlet.GenericServlet.init(GenericServlet.j ava:211)
at org.apache.catalina.core.StandardWrapper.loadServl et(StandardWrapper.java:1091)
at org.apache.catalina.core.StandardWrapper.load(Stan dardWrapper.java:925)
at org.apache.catalina.core.StandardContext.loadOnSta rtup(StandardContext.java:3880)
at org.apache.catalina.core.StandardContext.start(Sta ndardContext.java:4141)
at org.apache.catalina.core.ContainerBase.addChildInt ernal(ContainerBase.java:759)
at org.apache.catalina.core.ContainerBase.addChild(Co ntainerBase.java:739)
at org.apache.catalina.core.StandardHost.addChild(Sta ndardHost.java:524)
at org.apache.catalina.startup.HostConfig.deployDescr iptor(HostConfig.java:603)
at org.apache.catalina.startup.HostConfig.deployDescr iptors(HostConfig.java:535)
at org.apache.catalina.startup.HostConfig.deployApps( HostConfig.java:470)
at org.apache.catalina.startup.HostConfig.start(HostC onfig.java:1118)
at org.apache.catalina.startup.HostConfig.lifecycleEv ent(HostConfig.java:310)
at org.apache.catalina.util.LifecycleSupport.fireLife cycleEvent(LifecycleSupport.java:119)
at org.apache.catalina.core.ContainerBase.start(Conta inerBase.java:1020)
at org.apache.catalina.core.StandardHost.start(Standa rdHost.java:718)
at org.apache.catalina.core.ContainerBase.start(Conta inerBase.java:1012)
at org.apache.catalina.core.StandardEngine.start(Stan dardEngine.java:442)
...

Any ideas are greatly appreciated. Thanks.

Daniel

Costin Leau
Jan 11th, 2006, 03:16 AM
Read the javadocs - from your error it appears that you should inject the transaction manager and not the jtom bean.

dkalcevich
Jan 11th, 2006, 09:30 AM
Thanks for the response. However, when I inject the transactionManager into the JtaTransactionManager, I get the following error:

2006-01-11 07:23:48,747 INFO [org.objectweb.jotm] - <JOTM started with a local transaction factory which is not bound.>
2006-01-11 07:23:48,747 INFO [org.objectweb.jotm] - <CAROL initialization>
2006-01-11 07:23:48,747 INFO [org.objectweb.jotm.jta] - <JOTM 2.0.10>
2006-01-11 07:23:48,778 INFO [org.springframework.transaction.jta.JtaTransaction Manager] - <Using JTA UserTransaction: org.objectweb.jotm.Current@14c28db>
2006-01-11 07:23:48,778 INFO [org.springframework.transaction.jta.JtaTransaction Manager] - <Using JTA TransactionManager: org.objectweb.jotm.Current@14c28db>
2006-01-11 07:23:48,809 INFO [org.springframework.beans.factory.support.DefaultL istableBeanFactory] - <Destroying singletons in factory {org.springframework.beans.factory.support.Default ListableBeanFactory defining beans [testBean,jotm,transactionManager,innerDataSource,d ataSource,sqlMapClient,testDAO]; root of BeanFactory hierarchy}>
2006-01-11 07:23:48,809 INFO [org.objectweb.jotm] - <stop JOTM>
2006-01-11 07:23:48,809 ERROR [org.springframework.web.struts.ContextLoaderPlugIn] - <Context initialization failed>
org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'innerDataSource' defined in ServletContext resource [/WEB-INF/action-servlet.xml]: Error setting property values; nested exception is org.springframework.beans.PropertyAccessExceptions Exception: PropertyAccessExceptionsException (1 errors); nested propertyAccessExceptions are: [org.springframework.beans.TypeMismatchException: Failed to convert property value of type [org.springframework.transaction.jta.JtaTransaction Manager] to required type [javax.transaction.TransactionManager] for property 'transactionManager']
PropertyAccessExceptionsException (1 errors)
org.springframework.beans.TypeMismatchException: Failed to convert property value of type [org.springframework.transaction.jta.JtaTransaction Manager] to required type [javax.transaction.TransactionManager] for property 'transactionManager'
at org.springframework.beans.BeanWrapperImpl.doTypeCo nversionIfNecessary(BeanWrapperImpl.java:839)

Any ideas? Thanks.

Daniel

Costin Leau
Jan 11th, 2006, 09:42 AM
I've checked the wiki and the javadocs and the following configuration (identical to yours I think) appears to be correct:


<bean id="jotm" class="org.springframework.transaction.jta.JotmFactoryBea n"/>

<bean id="transactionManager" class="org.springframework.transaction.jta.JtaTransaction Manager">
<property name="userTransaction" ref="jotm"/>
</bean>

<bean id="innerDataSource" class="org.enhydra.jdbc.standard.StandardXADataSource" destroy-method="shutdown">
<property name="transactionManager" ref="jotm"/>
<property name="driverName" value="..."/>
<property name="url" value="..."/>
</bean>

<bean id="dataSource" class="org.enhydra.jdbc.pool.StandardXAPoolDataSource" destroy-method="shutdown">
<property name="dataSource" ref="innerDataSource"/>
<property name="user" value="..."/>
<property name="password" value="..."/>
<property name="maxSize" value="..."/>
</bean>

Have your tried other versions?- maybe there have been some
recent changes inside Jotm that broke the functionality.
The jotm factory bean needs to be injected since that represents
the TransactionManager implementation.

Costin Leau
Jan 11th, 2006, 09:48 AM
Btw, maybe you should check your jars - there is no public release of JOTM 2.0.9 (at least not on the official site: http://jotm.objectweb.org/). Moreover in your logs I see <JOTM 2.0.10>.
Moreover the current object returned by Jotm does implement the javax.transaction.TransactionManager interface (from checking the javadocs available here: http://jotm.objectweb.org/current/jotm/jdoc/).
Try doing some tests and see what is the actual object retrieved from jotm and that is suppose to be injected. Turn on some logging and see what Spring does.

TraceyAnnison
Nov 20th, 2006, 02:32 AM
I have exactly the same problem! I downloaded the most recently recommended version of JOTM, (jotm-2.0.10) and implemented it with Tomcat5.5 and Spring 1.2.8 as described in the docs, and it fails with the same error :


INFO 08:13:08 org.objectweb.jotm.Current.<init>():145 - JOTM 2.0.10
DEBUG 08:13:08 org.objectweb.jotm.Current.<init>():148 - no args constructor
DEBUG 08:13:08 org.objectweb.jotm.Batch.<init>():80 - Batch constructor
DEBUG 08:13:08 org.objectweb.jotm.Clock.<init>():58 - Clock constructor
DEBUG 08:13:08 org.objectweb.jotm.TransactionRecoveryImpl.<init>():141 - TransactionRecoveryImpl constructor
DEBUG 08:13:08 org.objectweb.jotm.TransactionRecoveryImpl.<init>():156 - JOTM Recovery is disabled
DEBUG 08:13:08 org.objectweb.jotm.Current.setDefaultTimeout():106 9 - timeout= 60
DEBUG 08:13:08 org.objectweb.jotm.Current.setDefaultTimeout():107 7 - default timeout= 60
ERROR 08:13:08 org.springframework.web.context.ContextLoader.init WebApplicationContext():211 - Context initialization failed
org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'txManager' defined in ServletContext resource [/WEB-INF/morph-database.xml]: Error setting property values; nested exception is PropertyAccessExceptionsException (1 errors)
PropertyAccessExceptionsException (1 errors) org.springframework.beans.TypeMismatchException: Failed to convert property value of type [org.objectweb.jotm.Current] to required type [javax.transaction.UserTransaction] for property 'userTransaction'
at org.springframework.beans.BeanWrapperImpl.doTypeCo nversionIfNecessary(BeanWrapperImpl.java:951)
at org.springframework.beans.BeanWrapperImpl.setPrope rtyValue(BeanWrapperImpl.java:692)
at org.springframework.beans.BeanWrapperImpl.setPrope rtyValue(BeanWrapperImpl.java:572)
at org.springframework.beans.BeanWrapperImpl.setPrope rtyValue(BeanWrapperImpl.java:737)
at org.springframework.beans.BeanWrapperImpl.setPrope rtyValues(BeanWrapperImpl.java:764)
at org.springframework.beans.BeanWrapperImpl.setPrope rtyValues(BeanWrapperImpl.java:753)
at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.applyPropertyValues(Abs tractAutowireCapableBeanFactory.java:1057)
at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.populateBean(AbstractAu towireCapableBeanFactory.java:857)
at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.createBean(AbstractAuto wireCapableBeanFactory.java:378)
at org.springframework.beans.factory.support.Abstract BeanFactory.getBean(AbstractBeanFactory.java:233)
at org.springframework.beans.factory.support.Abstract BeanFactory.getBean(AbstractBeanFactory.java:145)

This is from a spring xml setting :

<bean id="txManager" class="org.springframework.transaction.jta.JtaTransaction Manager">
<property name="userTransaction">
<ref bean="userTransaction"/>
</property>
</bean>

And a context.xml setting :

<Transaction name="UserTransaction" auth="Container"
type="javax.transaction.UserTransaction"
factory="org.objectweb.jotm.UserTransactionFactory"
jotm.timeout="60"/>

Though using this context.xml setting doesn't help :

<Resource name="UserTransaction" auth="Container"
type="javax.transaction.UserTransaction"/>

<ResourceParams name="UserTransaction">
<parameter>
<name>factory</name>
<value>org.objectweb.jotm.UserTransactionFactory</value>
</parameter>
<parameter>
<name>jotm.timeout</name>
<value>60</value>
</parameter>
</ResourceParams>

Does anyone know how to resolve this?

Any help would be much appreciated,
Tracey Annison

Costin Leau
Nov 20th, 2006, 10:38 AM
I double check the JOTM site and javadocs (http://jotm.objectweb.org/current/jotm/jdoc/org/objectweb/jotm/Current.html)and, as I said in my previous post things seem to be in order - org.objectweb.jotm.Current class does implement the UserTransaction. The conversion might fail if the classes are somehow loaded by two different classloaders though I doubt this is the case: are you using JPA by any chance?
Try running some small tests - have a very simple webapp and just check that the TM setup works in there.