glassfish
  1. glassfish
  2. GLASSFISH-11314

[Embedded] ClassNotFoundException: com.mysql.jdbc.jdbc2.optional.MysqlDataSource

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Won't Fix
    • Affects Version/s: V3
    • Fix Version/s: V3
    • Component/s: other
    • Labels:
      None
    • Environment:

      Operating System: All
      Platform: Sun

    • Issuezilla Id:
      11,314

      Description

      I've pointed pom.xml to the preinstalled V3 b74b. I've configured appserver
      with mysql and created correspondent resources in appserver. In pom.xml was
      useed dbVendorName=mssql and createTables=true. I've tried to deploy cmpcustomer
      sample. But I saw SQL exceptions during the deployment:
      java.lang.ClassNotFoundException: com.mysql.jdbc.jdbc2.optional.MysqlDataSource

      See all messages bellow.

      To reproduce the issue.

      1) Install appserver, create S1AS_HOME
      2) cvs co appserver-sqe/bootstrap.xml, create SPS_HOME
      3) ant -f bootstrap.xml co-ejb
      4) cd to appserver-sqe/pe/ejb/ejb30/persistence/datatypes
      5) ant mysql-setup (it will setup appserver with mysql)
      6) In buildJava2DB.xml replace resources names with your names. For
      cmpcusomer.ear: cmpcustomer-pool/jdbc/cmpcustomer. I've attached
      buildJava2DB.xml with these names.
      7) ant -f buildJava2DB.xml setup (it will create jdbc resources in appserver)
      8) execute through maven cmpcustomer.ear deployment with dbVendorName=mssql and
      createTables=true, pointing to preinstalled appserver.

      I've attached an archive

      INFO: Instantiated an instance of
      org.hibernate.validator.engine.resolver.JPATraversableResolver.
      Dec 16, 2009 1:59:13 PM com.sun.gjc.common.DataSourceObjectBuilder
      getDataSourceObject
      SEVERE: jdbc.exc_cnfe_ds
      java.lang.ClassNotFoundException: com.mysql.jdbc.jdbc2.optional.MysqlDataSource
      at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
      at java.security.AccessController.doPrivileged(Native Method)
      at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:303)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
      at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:316)
      at java.lang.Class.forName0(Native Method)
      at java.lang.Class.forName(Class.java:247)
      at
      com.sun.gjc.common.DataSourceObjectBuilder.getDataSourceObject(DataSourceObjectBuilder.java:279)
      at
      com.sun.gjc.common.DataSourceObjectBuilder.constructDataSourceObject(DataSourceObjectBuilder.java:108)
      at
      com.sun.gjc.spi.ManagedConnectionFactory.getDataSource(ManagedConnectionFactory.java:1167)
      at
      com.sun.gjc.spi.DSManagedConnectionFactory.getDataSource(DSManagedConnectionFactory.java:135)
      at
      com.sun.gjc.spi.DSManagedConnectionFactory.createManagedConnection(DSManagedConnectionFactory.java:90)
      at
      com.sun.enterprise.resource.allocator.LocalTxConnectorAllocator.createResource(LocalTxConnectorAllocator.java:72)
      at
      com.sun.enterprise.resource.pool.ConnectionPool.createSingleResource(ConnectionPool.java:834)
      at
      com.sun.enterprise.resource.pool.ConnectionPool.createResource(ConnectionPool.java:1087)
      at
      com.sun.enterprise.resource.pool.datastructure.ListDataStructure.addResource(ListDataStructure.java:121)
      at
      com.sun.enterprise.resource.pool.ConnectionPool.addResource(ConnectionPool.java:268)
      at
      com.sun.enterprise.resource.pool.ConnectionPool.createResourceAndAddToPool(ConnectionPool.java:1381)
      at
      com.sun.enterprise.resource.pool.ConnectionPool.createResources(ConnectionPool.java:862)
      at
      com.sun.enterprise.resource.pool.ConnectionPool.initPool(ConnectionPool.java:220)
      at
      com.sun.enterprise.resource.pool.ConnectionPool.internalGetResource(ConnectionPool.java:446)
      at
      com.sun.enterprise.resource.pool.ConnectionPool.getResource(ConnectionPool.java:360)
      at
      com.sun.enterprise.resource.pool.PoolManagerImpl.getResourceFromPool(PoolManagerImpl.java:227)
      at
      com.sun.enterprise.resource.pool.PoolManagerImpl.getResource(PoolManagerImpl.java:151)
      at
      com.sun.enterprise.connectors.ConnectionManagerImpl.getResource(ConnectionManagerImpl.java:321)
      at
      com.sun.enterprise.connectors.ConnectionManagerImpl.internalGetConnection(ConnectionManagerImpl.java:280)
      at
      com.sun.enterprise.connectors.ConnectionManagerImpl.allocateConnection(ConnectionManagerImpl.java:172)
      at
      com.sun.enterprise.connectors.ConnectionManagerImpl.allocateConnection(ConnectionManagerImpl.java:149)
      at
      com.sun.enterprise.connectors.ConnectionManagerImpl.allocateConnection(ConnectionManagerImpl.java:144)
      at com.sun.gjc.spi.base.DataSource.getConnection(DataSource.java:105)
      at
      org.glassfish.persistence.common.Java2DBProcessorHelper.getConnection(Java2DBProcessorHelper.java:636)
      at
      org.glassfish.persistence.common.Java2DBProcessorHelper.executeDDLStatement(Java2DBProcessorHelper.java:572)
      at
      org.glassfish.persistence.common.Java2DBProcessorHelper.createOrDropTablesInDB(Java2DBProcessorHelper.java:267)
      at
      com.sun.jdo.spi.persistence.support.ejb.ejbc.CMPProcessor.process(CMPProcessor.java:128)
      at
      com.sun.jdo.spi.persistence.support.ejb.codegen.CMPDeployerImpl.deploy(CMPDeployerImpl.java:225)
      at
      org.glassfish.ejb.startup.EjbDeployer.generateArtifacts(EjbDeployer.java:321)
      at
      org.glassfish.javaee.core.deployment.JavaEEDeployer.prepare(JavaEEDeployer.java:209)
      at
      com.sun.enterprise.v3.server.ApplicationLifecycle.prepareModule(ApplicationLifecycle.java:644)
      at
      org.glassfish.javaee.full.deployment.EarDeployer.prepareBundle(EarDeployer.java:269)
      at
      org.glassfish.javaee.full.deployment.EarDeployer.access$200(EarDeployer.java:79)
      at
      org.glassfish.javaee.full.deployment.EarDeployer$1.doBundle(EarDeployer.java:131)
      at
      org.glassfish.javaee.full.deployment.EarDeployer$1.doBundle(EarDeployer.java:129)
      at
      org.glassfish.javaee.full.deployment.EarDeployer.doOnBundles(EarDeployer.java:197)
      at
      org.glassfish.javaee.full.deployment.EarDeployer.doOnAllTypedBundles(EarDeployer.java:206)
      at
      org.glassfish.javaee.full.deployment.EarDeployer.doOnAllBundles(EarDeployer.java:232)
      at
      org.glassfish.javaee.full.deployment.EarDeployer.prepare(EarDeployer.java:129)
      at
      com.sun.enterprise.v3.server.ApplicationLifecycle.prepareModule(ApplicationLifecycle.java:644)
      at
      com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:296)
      at
      org.glassfish.kernel.embedded.EmbeddedDeployerImpl.deploy(EmbeddedDeployerImpl.java:214)
      at
      org.glassfish.kernel.embedded.EmbeddedDeployerImpl.deploy(EmbeddedDeployerImpl.java:144)
      at org.glassfish.maven.DeployMojo.execute(DeployMojo.java:75)
      at
      org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:453)
      at
      org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:559)
      at
      org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalWithLifecycle(DefaultLifecycleExecutor.java:500)
      at
      org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:479)
      at
      org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:331)
      at
      org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:292)
      at
      org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:142)
      at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:336)
      at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:129)
      at org.apache.maven.cli.MavenCli.main(MavenCli.java:301)
      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:597)
      at org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315)
      at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
      at org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)
      at org.codehaus.classworlds.Launcher.main(Launcher.java:375)
      Dec 16, 2009 1:59:13 PM
      com.sun.enterprise.resource.allocator.LocalTxConnectorAllocator createResource
      WARNING: poolmgr.create_resource_error
      Dec 16, 2009 1:59:13 PM com.sun.enterprise.connectors.ConnectionManagerImpl
      internalGetConnection
      WARNING: poolmgr.get_connection_failure
      Dec 16, 2009 1:59:13 PM com.sun.gjc.spi.base.DataSource getConnection
      WARNING: jdbc.exc_get_conn
      Dec 16, 2009 1:59:13 PM org.glassfish.persistence.common.Java2DBProcessorHelper
      logI18NWarnMessage
      WARNING: Cannot connect to database via JNDI name 'jdbc/cmpcustomer':
      java.sql.SQLException: Error in allocating a connection. Cause: Class name is
      wrong or classpath is not set for : com.mysql.jdbc.jdbc2.optional.MysqlDataSource.

      1. buildJava2DB.xml
        3 kB
        easarina
      2. cmpcustomer.ear
        28 kB
        easarina

        Activity

        Hide
        easarina added a comment -

        Created an attachment (id=4105)
        buildJava2DB.xml

        Show
        easarina added a comment - Created an attachment (id=4105) buildJava2DB.xml
        Hide
        easarina added a comment -

        Created an attachment (id=4106)
        cmpcustomer.ear

        Show
        easarina added a comment - Created an attachment (id=4106) cmpcustomer.ear
        Hide
        easarina added a comment -

        1) I've added to my environment CLASSPATH that pointed to
        mysql-connector-java-5.1.7-bin.jar.
        2) I've used mysql as a dbVendorName.

        But it did not help I still saw, the same error: MysqlDataSource was not found.

        3) It is strange that when I've used mssql I saw the same MysqlDataSource was
        not found error, but not SQL-92 error.
        4)mysql is absent in embedded guide and in asadmin help, both embeded guide and
        asadmin help have the same list of db vendors:
        db2, mssql, oracle, derby, javadb, postgresql, pointbase, sybase.

        Show
        easarina added a comment - 1) I've added to my environment CLASSPATH that pointed to mysql-connector-java-5.1.7-bin.jar. 2) I've used mysql as a dbVendorName. But it did not help I still saw, the same error: MysqlDataSource was not found. 3) It is strange that when I've used mssql I saw the same MysqlDataSource was not found error, but not SQL-92 error. 4)mysql is absent in embedded guide and in asadmin help, both embeded guide and asadmin help have the same list of db vendors: db2, mssql, oracle, derby, javadb, postgresql, pointbase, sybase.
        Hide
        easarina added a comment -

        I would like to make one correction, in item 7 has to be executed:

        ant -f buildJava2DB.xml mysql setup (it will create mysql resources in appserver)

        Show
        easarina added a comment - I would like to make one correction, in item 7 has to be executed: ant -f buildJava2DB.xml mysql setup (it will create mysql resources in appserver)
        Hide
        sherryshen added a comment -

        cc

        Show
        sherryshen added a comment - cc
        Hide
        sirajg added a comment -

        transfer

        Show
        sirajg added a comment - transfer
        Hide
        sirajg added a comment -

        transfer

        Show
        sirajg added a comment - transfer
        Hide
        Bhavanishankar added a comment -

        If there is regular glassfish installed, and most of the resource creation is
        done via asadmin command, then why is the embedded-glassfish-maven-plugin used
        just for deployment instead of using 'asadmin' itself?

        Show
        Bhavanishankar added a comment - If there is regular glassfish installed, and most of the resource creation is done via asadmin command, then why is the embedded-glassfish-maven-plugin used just for deployment instead of using 'asadmin' itself?

          People

          • Assignee:
            Bhavanishankar
            Reporter:
            easarina
          • Votes:
            1 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: