willcoder 2011-10-27
开发EJB3是,JBoss连接MySQL数据库出现
09:40:30,890 WARN [org.jboss.resource.connectionmanager.JBossManagedConnectionPool] Throwable while attempting to get a new connection: null: org.jboss.resource.JBossResourceException: Could not create connection; - nested throwable: (org.jboss.resource.JBossResourceException: Apparently wrong driver class specified for URL: class: com.mysql.jdbc.Driver, url: jdbc:mysql://localhost:3306/XXX) at org.jboss.resource.adapter.jdbc.local.LocalManagedConnectionFactory.getLocalManagedConnection(LocalManagedConnectionFactory.java:261) [:6.0.0.Final] at org.jboss.resource.adapter.jdbc.local.LocalManagedConnectionFactory.createManagedConnection(LocalManagedConnectionFactory.java:215) [:6.0.0.Final] at org.jboss.resource.connectionmanager.InternalManagedConnectionPool.createConnectionEventListener(InternalManagedConnectionPool.java:648) [:6.0.0.Final]
这是因为mysql-connector-java-bin.jar的位置不对,我将这个jar文件放在项目的/WEB-INFO/lib底下,正确的位置应该放在jboss_server_home/lib下,默认即 JBOSS安装目录/server/default/lib,这个异常就会消失,虽然我也不知道为什么。