Reputation: 398
While deploying my app I'm getting the following errors (I've also included subjectively significant warnings):
03:36:42,113 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: Failed to register driver for: com.mysql.jdbc.Driver; - nested throwable: (java.lang.ClassNotFoundException: com.mysql.jdbc.Driver from BaseClassLoader@66a8c396{vfs:///D:/MobilnyPodroznik/workspace/.metadata/.plugins/org.jboss.ide.eclipse.as.core/JBoss_6.x_Runtime_Server1345902635716/deploy/MP01.jar}))
(...)
Caused by: org.jboss.resource.JBossResourceException: Failed to register driver for: com.mysql.jdbc.Driver; - nested throwable: (java.lang.ClassNotFoundException: com.mysql.jdbc.Driver from BaseClassLoader@66a8c396{vfs:///D:/MobilnyPodroznik/workspace/.metadata/.plugins/org.jboss.ide.eclipse.as.core/JBoss_6.x_Runtime_Server1345902635716/deploy/MP01.jar})
(..)
Caused by: java.lang.ClassNotFoundException: com.mysql.jdbc.Driver from BaseClassLoader@66a8c396{vfs:///D:/MobilnyPodroznik/workspace/.metadata/.plugins/org.jboss.ide.eclipse.as.core/JBoss_6.x_Runtime_Server1345902635716/deploy/MP01.jar}
03:36:42,122 WARN [org.hibernate.cfg.SettingsFactory] Could not obtain connection to query metadata: org.jboss.util.NestedSQLException: Unable to get managed connection for MP01Local; - nested throwable: (javax.resource.ResourceException: Unable to get managed connection for MP01Local)
(...)
Caused by: javax.resource.ResourceException: Unable to get managed connection for MP01Local
(...)
Caused by: org.jboss.resource.JBossResourceException: Could not create connection; - nested throwable: (org.jboss.resource.JBossResourceException: Failed to register driver for: com.mysql.jdbc.Driver; - nested throwable: (java.lang.ClassNotFoundException: com.mysql.jdbc.Driver from BaseClassLoader@66a8c396{vfs:///D:/MobilnyPodroznik/workspace/.metadata/.plugins/org.jboss.ide.eclipse.as.core/JBoss_6.x_Runtime_Server1345902635716/deploy/MP01.jar}))
(...)
Caused by: org.jboss.resource.JBossResourceException: Failed to register driver for: com.mysql.jdbc.Driver; - nested throwable: (java.lang.ClassNotFoundException: com.mysql.jdbc.Driver from BaseClassLoader@66a8c396{vfs:///D:/MobilnyPodroznik/workspace/.metadata/.plugins/org.jboss.ide.eclipse.as.core/JBoss_6.x_Runtime_Server1345902635716/deploy/MP01.jar})
(...)
Caused by: java.lang.ClassNotFoundException: com.mysql.jdbc.Driver from BaseClassLoader@66a8c396{vfs:///D:/MobilnyPodroznik/workspace/.metadata/.plugins/org.jboss.ide.eclipse.as.core/JBoss_6.x_Runtime_Server1345902635716/deploy/MP01.jar}
03:36:42,143 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: Failed to register driver for: com.mysql.jdbc.Driver; - nested throwable: (java.lang.ClassNotFoundException: com.mysql.jdbc.Driver from BaseClassLoader@66a8c396{vfs:///D:/MobilnyPodroznik/workspace/.metadata/.plugins/org.jboss.ide.eclipse.as.core/JBoss_6.x_Runtime_Server1345902635716/deploy/MP01.jar}))
(...)
Caused by: org.jboss.resource.JBossResourceException: Failed to register driver for: com.mysql.jdbc.Driver; - nested throwable: (java.lang.ClassNotFoundException: com.mysql.jdbc.Driver from BaseClassLoader@66a8c396{vfs:///D:/MobilnyPodroznik/workspace/.metadata/.plugins/org.jboss.ide.eclipse.as.core/JBoss_6.x_Runtime_Server1345902635716/deploy/MP01.jar})
(...)
Caused by: java.lang.ClassNotFoundException: com.mysql.jdbc.Driver from BaseClassLoader@66a8c396{vfs:///D:/MobilnyPodroznik/workspace/.metadata/.plugins/org.jboss.ide.eclipse.as.core/JBoss_6.x_Runtime_Server1345902635716/deploy/MP01.jar}
03:36:42,147 ERROR [org.hibernate.tool.hbm2ddl.SchemaExport] schema export unsuccessful: org.jboss.util.NestedSQLException: Unable to get managed connection for MP01Local; - nested throwable: (javax.resource.ResourceException: Unable to get managed connection for MP01Local)
(...)
Caused by: javax.resource.ResourceException: Unable to get managed connection for MP01Local
(...)
Caused by: org.jboss.resource.JBossResourceException: Could not create connection; - nested throwable: (org.jboss.resource.JBossResourceException: Failed to register driver for: com.mysql.jdbc.Driver; - nested throwable: (java.lang.ClassNotFoundException: com.mysql.jdbc.Driver from BaseClassLoader@66a8c396{vfs:///D:/MobilnyPodroznik/workspace/.metadata/.plugins/org.jboss.ide.eclipse.as.core/JBoss_6.x_Runtime_Server1345902635716/deploy/MP01.jar}))
(...)
Caused by: org.jboss.resource.JBossResourceException: Failed to register driver for: com.mysql.jdbc.Driver; - nested throwable: (java.lang.ClassNotFoundException: com.mysql.jdbc.Driver from BaseClassLoader@66a8c396{vfs:///D:/MobilnyPodroznik/workspace/.metadata/.plugins/org.jboss.ide.eclipse.as.core/JBoss_6.x_Runtime_Server1345902635716/deploy/MP01.jar})
(...)
Caused by: java.lang.ClassNotFoundException: com.mysql.jdbc.Driver from BaseClassLoader@66a8c396{vfs:///D:/MobilnyPodroznik/workspace/.metadata/.plugins/org.jboss.ide.eclipse.as.core/JBoss_6.x_Runtime_Server1345902635716/deploy/MP01.jar}
As for the whole console output: http://pastebin.com/de2Br9xL
Basically, it seems as if my JDBC driver is not visible, but I have placed the .jar both in the server's default/lib folder and in project's build path, thus I'm clueless now.
persistence.xml
<?xml version="1.0" encoding="UTF-8"?>
<persistence xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"
version="2.0">
<persistence-unit name="mp" transaction-type="JTA">
<jta-data-source>java:/MP01Local</jta-data-source>
<properties>
<!--s
<property name="hibernate.dialect" value="org.hibernate.dialect.HSQLDialect"/>
-->
<property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect"/>
<property name="hibernate.hbm2ddl.auto" value="create-drop"/>
</properties>
</persistence-unit>
</persistence>
mysqllocal-ds.xml
<?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>MP01Local</jndi-name>
<connection-url>jdbc:mysql://localhost:3306/mp</connection-url>
<driver-class>com.mysql.jdbc.Driver</driver-class>
<user-name>login</user-name>
<password>pass</password>
</local-tx-datasource>
</datasources>
I have placed the DS XML file in default/deploy path of the JBoss server and mysql-connector-java-5.0.8-bin in default/lib, as indicated in the JBoss manual.
I'm using
My project build path
Upvotes: 0
Views: 5319
Reputation:
JDBC driver have to be placed in the CLASSPATH
of your application server.
Upvotes: 1
Reputation: 398
All right, I've repeated all the steps from the beginning as a fresh morning man and it worked. Still don't know why, but here're a few things that might've solved the problem. Hope this helps to anyone who's struggling to deploy his first Java EE + JPA application.
Here're the steps I've followed:
I have also deleted some old .jar deployments from my other test projects that got stuck in the workspace.metadata.plugins\org.jboss.ide.eclipse.as.core\JBoss_6.x_Runtime_Server1345902635716\deploy folder (supposedly due to incorrect shutdown), but I sincerely doubt that was what helped.
I suppose the main cause might've been that as I was swapping the drivers and Driver Definitions (I've been moving from 5.1.sth to 5.0.8) I forgot to swap them in the pj's build path as well and involuntarily left the old one.
My current persistence.xml
<?xml version="1.0" encoding="UTF-8"?>
<persistence xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"
version="2.0">
<persistence-unit name="mp" transaction-type="JTA">
<jta-data-source>java:/MP01Datasource2</jta-data-source>
<properties>
<!--s
<property name="hibernate.dialect" value="org.hibernate.dialect.HSQLDialect"/>
-->
<property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect"/>
<property name="hibernate.hbm2ddl.auto" value="create-drop"/>
</properties>
</persistence-unit>
</persistence>
Mysql_local-ds.xml
<?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>MP01Datasource2</jndi-name>
<use-java-context>true</use-java-context>
<connection-url>jdbc:mysql://localhost:3306/mp</connection-url>
<driver-class>com.mysql.jdbc.Driver</driver-class>
<user-name>x</user-name>
<password>y</password>
</local-tx-datasource>
</datasources>
Upvotes: 1