MysqlXADataSource问题

    
iamfigo
09-05-29 2 2546 1

环境:JDK 1.6 + jboss-5.1.0.GA + MySQL5.1.33;jdbc驱动:mysql-connector-java-5.1.7-bin.jar
启动正常,访问时抛异常:
21:03:18,237 WARN [JBossManagedConnectionPool] Throwable while attempting to get a new connection: null
org.jboss.resource.JBossResourceException: Could not create connection; - nested throwable: (org.jboss.resource.JBossResourceException: Could not find accessor on XADataSource: ; - nested throwable: (java.lang.NoSuchMethodException: com.mysql.jdbc.jdbc2.optional.MysqlXADataSource.setJdbc(java.lang.String)))
at org.jboss.resource.adapter.jdbc.xa.XAManagedConnectionFactory.getXAManagedConnection(XAManagedConnectionFactory.java:465)
at org.jboss.resource.adapter.jdbc.xa.XAManagedConnectionFactory.createManagedConnection(XAManagedConnectionFactory.java:409)
at org.jboss.resource.connectionmanager.InternalManagedConnectionPool.createConnectionEventListener(InternalManagedConnectionPool.java:633)
at org.jboss.resource.connectionmanager.InternalManagedConnectionPool.getConnection(InternalManagedConnectionPool.java:267)
at org.jboss.resource.connectionmanager.JBossManagedConnectionPool$BasePool.getConnection(JBossManagedConnectionPool.java:622)
at org.jboss.resource.connectionmanager.BaseConnectionManager2.getManagedConnection(BaseConnectionManager2.java:404)
at org.jboss.resource.connectionmanager.TxConnectionManager.getManagedConnection(TxConnectionManager.java:381)
at org.jboss.resource.connectionmanager.BaseConnectionManager2.allocateConnection(BaseConnectionManager2.java:496)
at org.jboss.resource.connectionmanager.BaseConnectionManager2$ConnectionManagerProxy.allocateConnection(BaseConnectionManager2.java:941)
at org.jboss.resource.adapter.jdbc.WrapperDataSource.getConnection(WrapperDataSource.java:89)
at com.jdon.model.query.JdbcTemp.queryMultiObject(JdbcTemp.java:123)
at com.jdon.jivejdon.dao.sql.SetupDaoSql.getSetupValue(SetupDaoSql.java:48)
at com.jdon.jivejdon.manager.block.IPBanListManager.loadBannedIps(IPBanListManager.java:168)
at com.jdon.jivejdon.manager.block.IPBanListManager.<init>(IPBanListManager.java:63)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at org.picocontainer.defaults.InstantiatingComponentAdapter.newInstance(InstantiatingComponentAdapter.java:128)
at org.picocontainer.defaults.ConstructorInjectionComponentAdapter$1.run(ConstructorInjectionComponentAdapter.java:154)
at org.picocontainer.defaults.ThreadLocalCyclicDependencyGuard.observe(ThreadLocalCyclicDependencyGuard.java:56)
at org.picocontainer.defaults.ConstructorInjectionComponentAdapter.getComponentInstance(ConstructorInjectionComponentAdapter.java:184)
at com.jdon.container.pico.JdonPicoContainer.getTrueInstance(JdonPicoContainer.java:379)
at com.jdon.container.pico.JdonPicoContainer.getInstance(JdonPicoContainer.java:362)
at com.jdon.container.pico.JdonPicoContainer.getComponentInstance(JdonPicoContainer.java:341)
at org.picocontainer.defaults.BasicComponentParameter.resolveInstance(BasicComponentParameter.java:77)
at org.picocontainer.defaults.ComponentParameter.resolveInstance(ComponentParameter.java:117)
at org.picocontainer.defaults.ConstructorInjectionComponentAdapter.getConstructorArguments(ConstructorInjectionComponentAdapter.java:193)
at org.picocontainer.defaults.ConstructorInjectionComponentAdapter$1.run(ConstructorInjectionComponentAdapter.java:148)
at org.picocontainer.defaults.ThreadLocalCyclicDependencyGuard.observe(ThreadLocalCyclicDependencyGuard.java:56)
at org.picocontainer.defaults.ConstructorInjectionComponentAdapter.getComponentInstance(ConstructorInjectionComponentAdapter.java:184)
at com.jdon.container.pico.JdonPicoContainer.getTrueInstance(JdonPicoContainer.java:379)
at com.jdon.container.pico.JdonPicoContainer.getInstance(JdonPicoContainer.java:362)



看到以前也有人遇到类似问题,我也是用的3.6版本的出错,希望得到解答。
[该贴被iamfigo于2009-05-29 21:39修改过]

1
iamfigo
2009-05-30 14:37

我看有人说是jdbc版本问题,java.lang.NoSuchMethodException: com.mysql.jdbc.jdbc2.optional.MysqlXADataSource.setJdbc(java.lang.String
在新有jdbc驱动中没有这个方法了?
有没有人在mysql5.1人运行成功的啊,我从昨天折腾到现在都还是没搞好!

iamfigo
2009-05-30 17:48

问题解决,是mysql-ds.xml原来的默认有错误,
用以下
<?xml version="1.0" encoding="UTF-8"?>
<datasources>
<xa-datasource>
<jndi-name>Security</jndi-name>
<!-- uncomment to enable interleaving <interleaving/> -->
<xa-datasource-class>com.mysql.jdbc.jdbc2.optional.MysqlXADataSource </xa-datasource-class>
<xa-datasource-property name="Url">jdbc:mysql://localhost:3306/security?useUnicode=true&characterEncoding=utf8&characterResultSets=utf8</xa-datasource-property>
<xa-datasource-property name="user">banq </xa-datasource-property>
<xa-datasource-property name="password">a </xa-datasource-property>
<user-name>banq </user-name>
<password>a </password>
<!-- <transaction-isolation>TRANSACTION_READ_COMMITTED </transaction-isolation>-->
<!-- This disables transaction interleaving (which BTW, most DB vendors don't support) -->
<!-- <track-connection-by-tx/>-->
<!-- <isSameRM-override-value>false </isSameRM-override-value>-->

<!--pooling parameters-->
<min-pool-size>5 </min-pool-size>
<max-pool-size>20 </max-pool-size>
<blocking-timeout-millis>5000 </blocking-timeout-millis>
<idle-timeout-minutes>15 </idle-timeout-minutes>

<exception-sorter-class-name>org.jboss.resource.adapter.jdbc.vendor.MySQLExceptionSorter </exception-sorter-class-name>
<!-- corresponding type-mapping in the standardjbosscmp-jdbc.xml (optional) -->
<metadata>
<type-mapping>mySQL </type-mapping>
</metadata>
</xa-datasource>

<xa-datasource>
<jndi-name>JiveJdonDS</jndi-name>
<!-- uncomment to enable interleaving <interleaving/> -->

<xa-datasource-class>com.mysql.jdbc.jdbc2.optional.MysqlXADataSource </xa-datasource-class>
<xa-datasource-property name="Url">jdbc:mysql://localhost:3306/jivejdon?useUnicode=true&characterEncoding=utf8&characterResultSets=utf8</xa-datasource-property>
<xa-datasource-property name="user">banq </xa-datasource-property>
<xa-datasource-property name="password">a </xa-datasource-property>
<user-name>banq </user-name>
<password>a</password>
<!-- <transaction-isolation>TRANSACTION_READ_COMMITTED </transaction-isolation>-->
<!-- This disables transaction interleaving (which BTW, most DB vendors don't support) -->
<!-- <track-connection-by-tx/>-->
<!-- <isSameRM-override-value>false </isSameRM-override-value>-->

<!--pooling parameters-->
<min-pool-size>5 </min-pool-size>
<max-pool-size>20 </max-pool-size>
<blocking-timeout-millis>5000 </blocking-timeout-millis>
<idle-timeout-minutes>15 </idle-timeout-minutes>

<exception-sorter-class-name>org.jboss.resource.adapter.jdbc.vendor.MySQLExceptionSorter </exception-sorter-class-name>
<!-- corresponding type-mapping in the standardjbosscmp-jdbc.xml (optional) -->
<metadata>
<type-mapping>mySQL </type-mapping>
</metadata>
</xa-datasource>
</datasources>
可成功部署