I can't find this error reason. Using Tomcat and context reload

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

I can't find this error reason. Using Tomcat and context reload

Jcode99
I using Tomcat 6.0 and Bitronix 1.3 Beta

Following error...

Caused by: javax.management.InstanceAlreadyExistsException: bitronix.tm:type=JdbcPooledConnection,UniqueName=BBS,Id=0
        at com.sun.jmx.mbeanserver.RepositorySupport.addMBean(Unknown Source)
        at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.internal_addObject(Unknown Source)
        at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.registerObject(Unknown Source)
        at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.registerMBean(Unknown Source)
        at com.sun.jmx.mbeanserver.JmxMBeanServer.registerMBean(Unknown Source)


and my source...

             private static DataSourceManager instance = null;
       
        private static ResourceLoader btmResourceLoader  = null;
       
        private DataSourceManager(){
                init();
        }
       
        public static Connection getConnection(String poolName){
                if(instance == null){
                        instance = new DataSourceManager();
                }

                PoolingDataSource poolingDataSource = (PoolingDataSource)btmResourceLoader.getResources().get(poolName);
               
                try{
                        return poolingDataSource.getConnection();
                }catch(SQLException SQLE){
                        System.out.println(SQLE.getCause());
                        return null;
                }
        }
       
        private void init(){

                try{
                        Configuration btmConfigurationf = TransactionManagerServices.getConfiguration();
                       
                        File resourceProperties = new File(Thread.currentThread().getContextClassLoader().getResource("").getPath());
                       
                        btmConfigurationf.setResourceConfigurationFilename(resourceProperties.getPath() + "/" + btmConfigurationf.getResourceConfigurationFilename());
                       
                        resourceProperties = null;
                       
                        btmResourceLoader = TransactionManagerServices.getResourceLoader();
                       
                        btmResourceLoader.init();
                }catch(Exception E){
                        System.out.println("[ERROR] DataSourceManager is not loaded. Please check configuration files");
                        System.out.println(E);
                }
        }

and configuration fils into 'myContext/WEB-INF/classes' folder

--- bitronix-default-config.properties ---

bitronix.tm.serverId=Test
bitronix.tm.resource.bind=false
bitronix.tm.2pc.async=false
bitronix.tm.2pc.warnAboutZeroResourceTransactions=true
bitronix.tm.journal.disk.logPart1Filename=C:/btm1.tlog
bitronix.tm.journal.disk.logPart2Filename=C:/btm2.tlog
bitronix.tm.journal.disk.forcedWriteEnabled=false
bitronix.tm.journal.disk.forceBatchingEnabled=false
bitronix.tm.journal.disk.maxLogSize=2
bitronix.tm.journal.disk.filterLogStatus=true
bitronix.tm.journal.disk.skipCorruptedLogs=true
bitronix.tm.timer.defaultTransactionTimeout=60
bitronix.tm.timer.transactionRetryInterval=10
bitronix.tm.timer.gracefulShutdownInterval=60
bitronix.tm.timer.backgroundRecoveryInterval=0
bitronix.tm.resource.configuration=resources.properties


--- resource.properties ---

bitronix.tm.resource.bind=false
resource.ds2.className=org.enhydra.jdbc.standard.StandardXADataSource
resource.ds2.uniqueName=BBS
resource.ds2.maxPoolSize=2
resource.ds2.minPoolSize=1
resource.ds2.allowLocalTransactions=true
resource.ds2.testQuery=SELECT 1
resource.ds2.driverProperties.driverName=net.sourceforge.jtds.jdbc.Driver
resource.ds2.driverProperties.user=myId
resource.ds2.driverProperties.password=myPassword
resource.ds2.driverProperties.url=jdbc:jtds:sqlserver://localhost:1433/BBS


How can I solve this error?

thank you for bitronix developers
Reply | Threaded
Open this post in threaded view
|

Re: I can't find this error reason. Using Tomcat and context reload

Ludovic Orban
Administrator
Hi,

This exception seems to indicate there is a problem with the JMX registration of connections. It looks like you've embedded BTM directly in your WAR file so I wonder how you are initializing / de-initializing it. Did you register a ServletContextListener to do so ? If not, you are probably running into a connection leak problem when redeploying the context.

Could you please explain in details exactly how you are running into this problem ? Also post the complete stack trace you're getting and if possible a debug log which will also help tracing the error.


As a side note, may I suggest you to revise your configuration ? Disabling forced writes and enabling skipCorruptedLogs is definitely not a good idea unless you really know what the consequences are.

Also, you should avoid using the StandardXADataSource class for your JDBC pool. If you really want to fake XA, use the LrcXADataSource instead (http://docs.codehaus.org/display/BTM/LastResourceCommit) which is much more reliable.

Ludovic