1 Reply Latest reply on Jul 5, 2007 12:10 PM by strickla

    Seam and MySQL - Apparently wrong driver class specified?

    strickla

      Hi everyone,

      I'm trying to create a new Seam project and use MySQL instead of HSQL.
      When I attempt to start up the JBoss AS I get the following exception during initialization:

      10:45:03,312 INFO [DatasourceConnectionProvider] Using datasource: java:/mmogwi
      dgetsDatasource
      10:45:03,328 WARN [JBossManagedConnectionPool] Throwable while attempting to ge
      t 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://localho
      st:3306/mmogwidgets)
       at org.jboss.resource.adapter.jdbc.local.LocalManagedConnectionFactory.c
      reateManagedConnection(LocalManagedConnectionFactory.java:179)
       at org.jboss.resource.connectionmanager.InternalManagedConnectionPool.cr
      eateConnectionEventListener(InternalManagedConnectionPool.java:577)
       at org.jboss.resource.connectionmanager.InternalManagedConnectionPool.ge
      tConnection(InternalManagedConnectionPool.java:262)
       at org.jboss.resource.connectionmanager.JBossManagedConnectionPool$BaseP
      ool.getConnection(JBossManagedConnectionPool.java:500)
       at org.jboss.resource.connectionmanager.BaseConnectionManager2.getManage
      dConnection(BaseConnectionManager2.java:341)
       at org.jboss.resource.connectionmanager.TxConnectionManager.getManagedCo
      nnection(TxConnectionManager.java:315)
       at org.jboss.resource.connectionmanager.BaseConnectionManager2.allocateC
      onnection(BaseConnectionManager2.java:396)
       at org.jboss.resource.connectionmanager.BaseConnectionManager2$Connectio



      I used mysql Connector/J driver as the library to provide my driver class during seam setup script. It's name is "mysql-connector-java-5.0.6-bin.jar". I modified the build.xml to include that lib in the war when it is deployed. I also changed the dialect in the -ds.xml file so that it uses MySQLDialect.

      Here is my data source xml file:

      <local-tx-datasource>
       <jndi-name>mmogwidgetsDatasource</jndi-name>
       <connection-url>jdbc:mysql://localhost:3306/mmogwidgets</connection-url>
       <driver-class>com.mysql.jdbc.Driver</driver-class>
       <user-name>xxx</user-name>
       <password>xxx</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>


      and here is my persistence xml file:

      <persistence-unit name="mmogwidgets" transaction-type="JTA">
       <provider>org.hibernate.ejb.HibernatePersistence</provider>
       <jta-data-source>java:/mmogwidgetsDatasource</jta-data-source>
       <properties>
       <property name="hibernate.hbm2ddl.auto" value="create-drop"/>
       <property name="hibernate.show_sql" value="true"/>
       <property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect"/>
       <property name="hibernate.transaction.manager_lookup_class" value="org.hibernate.transaction.JBossTransactionManagerLookup"/>
       </properties>
       </persistence-unit>


      Anyone know what's going wrong?

        • 1. Re: Seam and MySQL - Apparently wrong driver class specified
          strickla

          I hate answering my own questions because I don't know if it's the "correct" answer or not...but anyway.

          I added the mysql-connector-java-5.0.6-bin.jar to /server/default/lib and everything appears to be working now...

          Why can the app server find the jar/class in that directory but not find the driver if the jar was in my war/WEB-INF/lib directory?