Tomcat deployment problem

classic Classic list List threaded Threaded
2 messages Options
pmg
Reply | Threaded
Open this post in threaded view
|

Tomcat deployment problem

pmg
I have problem deploying my app on tomcat 6.0 using btm 1.1 (somehow I could not get btm 1.2 working for me)

Note: I have not made any change suggested at http://docs.codehaus.org/display/BTM/Tomcat yet because I am loading the transaction manager and data source through my spring config.

From console all works well, no problem with transaction manager or data sources. All my persistence test works fine. Here is complete config

        <bean id="aDataSource" class="bitronix.tm.resource.jdbc.PoolingDataSource" init-method="init" destroy-method="close">
                <property name="className" value="oracle.jdbc.xa.client.OracleXADataSource" />
                <property name="uniqueName" value="aData" />
                <property name="minPoolSize" value="5" />
                <property name="maxPoolSize" value="50" />
                <property name="acquireIncrement" value="1" />
                <property name="allowLocalTransactions" value="true" />
                <property name="automaticEnlistingEnabled" value="true" />
                <property name="useTmJoin" value="false" />               
                <property name="driverProperties">
                        <props>
                                <prop key="URL">XXX</prop>
                                <prop key="user">XXX</prop>
                                <prop key="password">XXX</prop>                               
                        </props>
                </property>
        </bean>

        <bean id="bDataSource" class="bitronix.tm.resource.jdbc.PoolingDataSource" init-method="init" destroy-method="close">
                <property name="className" value="oracle.jdbc.xa.client.OracleXADataSource" />
                <property name="uniqueName" value="bData" />
                <property name="minPoolSize" value="5" />
                <property name="maxPoolSize" value="50" />
                <property name="allowLocalTransactions" value="true" />               
                <property name="acquireIncrement" value="1" />
                <property name="automaticEnlistingEnabled" value="true" />
                <property name="useTmJoin" value="false" />               
                <property name="driverProperties">
                        <props>
                                <prop key="URL">XXX</prop>
                                <prop key="user">XXX</prop>
                                <prop key="password">XXX</prop>                               
                        </props>
                </property>
        </bean>

        <bean id="cDataSource" class="bitronix.tm.resource.jdbc.PoolingDataSource" init-method="init" destroy-method="close">
                <property name="className" value="oracle.jdbc.xa.client.OracleXADataSource" />
                <property name="uniqueName" value="cData" />
                <property name="minPoolSize" value="5" />
                <property name="maxPoolSize" value="50" />
                <property name="allowLocalTransactions" value="true" />               
                <property name="acquireIncrement" value="1" />
                <property name="automaticEnlistingEnabled" value="true" />
                <property name="useTmJoin" value="false" />               
                <property name="driverProperties">
                        <props>
                                <prop key="URL">XXX</prop>
                                <prop key="user">XXX</prop>
                                <prop key="password">XXX</prop>                               
                        </props>
                </property>
        </bean>

Deploying the app  on tomcat 6.0 gets

java.lang.IllegalArgumentException: resource with uniqueName 'aData' has already been registered
        bitronix.tm.resource.ResourceRegistrar.register(ResourceRegistrar.java:50)
        bitronix.tm.resource.jdbc.PoolingDataSource.buildXAPool(PoolingDataSource.java:70)
        bitronix.tm.resource.jdbc.PoolingDataSource.init(PoolingDataSource.java:48)
        sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
        sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
        java.lang.reflect.Method.invoke(Unknown Source)
        org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeCustomInitMethod(AbstractAutowireCapableBeanFactory.java:1104)
        org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1066)
        org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1029)
        org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:420)
        org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:245)
        org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:141)
        org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:242)
        org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:156)
        org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:290)
        org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:348)
        org.springframework.web.context.support.AbstractRefreshableWebApplicationContext.refresh(AbstractRefreshableWebApplicationContext.java:156)
        org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:308)
        org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:252)
        org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:221)
        org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:115)
        javax.servlet.GenericServlet.init(GenericServlet.java:212)
        org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
        org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
        org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
        org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
        org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
        java.lang.Thread.run(Unknown Source)


Thanks.
- pmg
 
Reply | Threaded
Open this post in threaded view
|

Re: Tomcat deployment problem

Ludovic Orban
Administrator
Hi,

First, let me guess why you did not manage to get version 1.2 running. I suppose during startup of the TM you got an XAException and the TM refused to start, right ? That probably means you did not grant your Oracle user privileges to run recovery.

Check this link: http://docs.codehaus.org/display/BTM/JdbcXaSupportEvaluation#JdbcXaSupportEvaluation-Oracle

you have to have the DBAs grant your user these privileges:

grant select on sys.dba_pending_transactions to myUser;
grant select on sys.pending_trans$ to myUser;
grant select on sys.dba_2pc_pending to myUser;
grant execute on sys.dbms_system to myUser;


If you don't, you might end up in serious trouble as recovery after failure won't work and you could corrupt your data.

The reason why BTM 1.1 does not complain is because there is a bug in it that prevents it for reporting such failure to recover during startup.

Now, about your Tomcat problem I suspect a classloader issue. BTM internally registers all resources using their unique names in the bitronix.tm.resource.ResourceRegistrar class. If you share that class between different web applications and have them create resources with the common names you'll end up with that problem.

Where did you put the BTM JAR file ? In Tomcat's common/lib folder or in the WAR's WEB-INF/lib one ? Either all webapp should have the BTM jar in the WEB-INF/lib or connection pools should be created globally by Tomcat and shared between all applications as explained in the Tomcat page.

Ludovic