2 Replies Latest reply on Aug 6, 2009 4:30 PM by Arbi Sookazian

    MySQL xa-datasource problem

    Arbi Sookazian Master

      JBoss 4.2.3.GA
      mysql-connector-java-5.1.7-bin.jar
      MySQL 5.1
      Seam 2.1.2.GA

      /********************************************************/

      I am trying to create a new Seam distro example showcasing XA/2PC with MySQL 5.1. Eventually I want to use Seam 2.2.x with JBoss 5.1.x but currently JBoss Tools 2.0.0.GA in JBDS 2.0.0.GA does not support JBoss AS 5.1 server config in JBoss Server view. Perhaps I need to download Eclipse IDE 3.5 and install/config JBoss Tools 3.0 or 3.1.

      Anyways, I basically copied and renamed the Seam booking project as XA-MySQL. In this project, I changed jboss-seam-booking-ds.xml to the following:

      <?xml version="1.0" encoding="UTF-8"?>
      
      <!DOCTYPE datasources
       PUBLIC "-//JBoss//DTD JBOSS JCA Config 1.5//EN"
       "http://www.jboss.org/j2ee/dtd/jboss-ds_1_5.dtd">
      <datasources>
       <xa-datasource>
       <jndi-name>bookingDatasource</jndi-name>
       <xa-datasource-property name="URL">jdbc:mysql://localhost:3306/jboss</xa-datasource-property>
       <xa-datasource-class>com.mysql.jdbc.jdbc2.optional.MysqlXADataSource</xa-datasource-class>
       <user-name>jboss</user-name>
       <password>password</password>
       <!-- <track-connection-by-tx>true</track-connection-by-tx> -->
       <exception-sorter-class-name>org.jboss.resource.adapter.jdbc.vendor.MySQLExceptionSorter</exception-sorter-class-name>
       <valid-connection-checker-class-name>org.jboss.resource.adapter.jdbc.vendor.MySQLValidConnectionChecker</valid-connection-checker-class-name>
       <min-pool-size>1</min-pool-size>
       <max-pool-size>10</max-pool-size>
       <idle-timeout-minutes>10</idle-timeout-minutes>
       <metadata>
       <type-mapping>mySQL</type-mapping>
       </metadata>
       </xa-datasource>
       </datasources>


      I see the following stack trace when I startup JBoss and deploy my new app:

      11:39:17,840 ERROR [[/seam-booking]] Exception sending context initialized event to listener instance of class org.jboss.seam.servlet.SeamListener
      org.jboss.seam.InstantiationException: Could not instantiate Seam component: startupInterceptor
       at org.jboss.seam.Component.newInstance(Component.java:2144)
       at org.jboss.seam.contexts.Contexts.startup(Contexts.java:304)
       at org.jboss.seam.contexts.Contexts.startup(Contexts.java:278)
       at org.jboss.seam.contexts.ServletLifecycle.endInitialization(ServletLifecycle.java:113)
       at org.jboss.seam.init.Initialization.init(Initialization.java:740)
       at org.jboss.seam.servlet.SeamListener.contextInitialized(SeamListener.java:36)
       at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3856)
       at org.apache.catalina.core.StandardContext.start(StandardContext.java:4361)
       at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:790)
       at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:770)
       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(DelegatingMethodAccessorImpl.java:25)
       at java.lang.reflect.Method.invoke(Method.java:585)
       at org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:296)
       at org.jboss.mx.server.RawDynamicInvoker.invoke(RawDynamicInvoker.java:164)
       at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
       at org.apache.catalina.core.StandardContext.init(StandardContext.java:5312)
       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
       at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
       at java.lang.reflect.Method.invoke(Method.java:585)
       at org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:296)
       at org.jboss.mx.server.RawDynamicInvoker.invoke(RawDynamicInvoker.java:164)
       at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
       at org.jboss.web.tomcat.service.TomcatDeployer.performDeployInternal(TomcatDeployer.java:301)
       at org.jboss.web.tomcat.service.TomcatDeployer.performDeploy(TomcatDeployer.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(ServiceMBeanSupport.java:289)
       at org.jboss.system.ServiceMBeanSupport.jbossInternalLifecycle(ServiceMBeanSupport.java:245)
       at sun.reflect.GeneratedMethodAccessor3.invoke(Unknown Source)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
       at java.lang.reflect.Method.invoke(Method.java:585)
       at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.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(ServiceController.java:978)
       at $Proxy0.start(Unknown Source)
       at org.jboss.system.ServiceController.start(ServiceController.java:417)
       at sun.reflect.GeneratedMethodAccessor9.invoke(Unknown Source)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
       at java.lang.reflect.Method.invoke(Method.java:585)
       at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.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.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:210)
       at $Proxy44.start(Unknown Source)
       at org.jboss.web.AbstractWebContainer.start(AbstractWebContainer.java:466)
       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
       at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
       at java.lang.reflect.Method.invoke(Method.java:585)
       at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
       at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
       at org.jboss.mx.interceptor.AbstractInterceptor.invoke(AbstractInterceptor.java:133)
       at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
       at org.jboss.mx.interceptor.ModelMBeanOperationInterceptor.invoke(ModelMBeanOperationInterceptor.java:142)
       at org.jboss.mx.interceptor.DynamicInterceptor.invoke(DynamicInterceptor.java:97)
       at org.jboss.system.InterceptorServiceMBeanSupport.invokeNext(InterceptorServiceMBeanSupport.java:238)
       at org.jboss.wsf.container.jboss42.DeployerInterceptor.start(DeployerInterceptor.java:87)
       at org.jboss.deployment.SubDeployerInterceptorSupport$XMBeanInterceptor.start(SubDeployerInterceptorSupport.java:188)
       at org.jboss.deployment.SubDeployerInterceptor.invoke(SubDeployerInterceptor.java:95)
       at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
       at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
       at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
       at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:210)
       at $Proxy45.start(Unknown Source)
       at org.jboss.deployment.MainDeployer.start(MainDeployer.java:1025)
       at org.jboss.deployment.MainDeployer.start(MainDeployer.java:1015)
       at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:819)
       at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:782)
       at sun.reflect.GeneratedMethodAccessor24.invoke(Unknown Source)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
       at java.lang.reflect.Method.invoke(Method.java:585)
       at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
       at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
       at org.jboss.mx.interceptor.AbstractInterceptor.invoke(AbstractInterceptor.java:133)
       at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
       at org.jboss.mx.interceptor.ModelMBeanOperationInterceptor.invoke(ModelMBeanOperationInterceptor.java:142)
       at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
       at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
       at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
       at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:210)
       at $Proxy9.deploy(Unknown Source)
       at org.jboss.deployment.scanner.URLDeploymentScanner.deploy(URLDeploymentScanner.java:421)
       at org.jboss.deployment.scanner.URLDeploymentScanner.scan(URLDeploymentScanner.java:610)
       at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.doScan(AbstractDeploymentScanner.java:263)
       at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.loop(AbstractDeploymentScanner.java:274)
       at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.run(AbstractDeploymentScanner.java:225)
      Caused by: org.jboss.seam.InstantiationException: Could not instantiate Seam component: startConversation
       at org.jboss.seam.Component.newInstance(Component.java:2144)
       at org.jboss.seam.Component.getInstance(Component.java:2021)
       at org.jboss.seam.Component.getInstance(Component.java:1983)
       at org.jboss.seam.Component.getInstance(Component.java:1977)
       at org.jboss.seam.Component.getInstanceInAllNamespaces(Component.java:2349)
       at org.jboss.seam.Component.getValueToInject(Component.java:2301)
       at org.jboss.seam.Component.injectAttributes(Component.java:1736)
       at org.jboss.seam.Component.inject(Component.java:1554)
       at org.jboss.seam.core.BijectionInterceptor.aroundInvoke(BijectionInterceptor.java:61)
       at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
       at org.jboss.seam.core.MethodContextInterceptor.aroundInvoke(MethodContextInterceptor.java:44)
       at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
       at org.jboss.seam.intercept.RootInterceptor.invoke(RootInterceptor.java:107)
       at org.jboss.seam.intercept.JavaBeanInterceptor.interceptInvocation(JavaBeanInterceptor.java:185)
       at org.jboss.seam.intercept.JavaBeanInterceptor.invoke(JavaBeanInterceptor.java:103)
       at org.jboss.seam.example.booking.TestStartupInterceptor_$$_javassist_seam_1.init(TestStartupInterceptor_$$_javassist_seam_1.java)
       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
       at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
       at java.lang.reflect.Method.invoke(Method.java:585)
       at org.jboss.seam.util.Reflections.invoke(Reflections.java:22)
       at org.jboss.seam.util.Reflections.invokeAndWrap(Reflections.java:144)
       at org.jboss.seam.Component.callComponentMethod(Component.java:2249)
       at org.jboss.seam.Component.callCreateMethod(Component.java:2172)
       at org.jboss.seam.Component.newInstance(Component.java:2132)
       ... 95 more
      Caused by: javax.naming.NameNotFoundException: local not bound
       at org.jnp.server.NamingServer.getBinding(NamingServer.java:529)
       at org.jnp.server.NamingServer.getBinding(NamingServer.java:537)
       at org.jnp.server.NamingServer.getObject(NamingServer.java:543)
       at org.jnp.server.NamingServer.lookup(NamingServer.java:296)
       at org.jnp.server.NamingServer.lookup(NamingServer.java:270)
       at org.jnp.server.NamingServer.lookup(NamingServer.java:270)
       at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:667)
       at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:627)
       at javax.naming.InitialContext.lookup(InitialContext.java:351)
       at org.jboss.seam.Component.instantiateSessionBean(Component.java:1400)
       at org.jboss.seam.Component.instantiate(Component.java:1364)
       at org.jboss.seam.Component.newInstance(Component.java:2122)
       ... 119 more


      Please note that when I used the following contents in the same *-ds.xml, there are no exceptions during deployment of the project:

      <?xml version="1.0" encoding="UTF-8"?>
      
      <!DOCTYPE datasources
       PUBLIC "-//JBoss//DTD JBOSS JCA Config 1.5//EN"
       "http://www.jboss.org/j2ee/dtd/jboss-ds_1_5.dtd">
      <datasources>
       <local-tx-datasource>
       <jndi-name>bookingDatasource</jndi-name>
       <connection-url>jdbc:mysql://localhost:3306/jboss</connection-url>
       <driver-class>com.mysql.jdbc.Driver</driver-class>
       <user-name>jboss</user-name>
       <password>password</password>
       <exception-sorter-class-name>org.jboss.resource.adapter.jdbc.vendor.MySQLExceptionSorter</exception-sorter-class-name>
      
       <metadata>
       <type-mapping>mySQL</type-mapping>
       </metadata>
       </local-tx-datasource>
      </datasources>


      The ultimate goal is to define two <xa-datasource> blocks in the *-ds.xml so I can essentially have two transactions on two different db's (i.e. distributed tx) managed by the tx mgr (EJB3/JTA) for 2PC.

      Any advice is appreciated, it's difficult to find good examples on *-ds.xml configs for xa-datasources with MySQL and JBoss. thx.