glassfish
  1. glassfish
  2. GLASSFISH-15835

No way to inject artifacts into maven-embedded-glassfish-plugin classpath

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 3.1_b40
    • Fix Version/s: 3.1
    • Component/s: embedded
    • Labels:
      None

      Description

      (Bhavani is already working on this; please make sure this is assigned to him.)

      The maven-embedded-glassfish-plugin has the capability of pointing to an external config file (domain.xml), but if that domain.xml refers to-for example-a JDBC connection pool that requires a JDBC database driver, then it is impossible to get the database driver's jar onto the classpath of the embedded Glassfish instance.

      Bhavani supplied me with a patch that fixes this problem, but the fix needs obviously to make it into the plugin core.

        Activity

        Hide
        Bhavanishankar added a comment -

        Fix has been checked in.

        Show
        Bhavanishankar added a comment - Fix has been checked in.
        Hide
        ljnelson added a comment -

        Hi, Bhavani; what build is this fix part of? b41, I hope?

        Show
        ljnelson added a comment - Hi, Bhavani; what build is this fix part of? b41, I hope?
        Hide
        Bhavanishankar added a comment -

        The changes were part of the plugin. So, the upcoming 3.1-b05 version of the plugin should have it (current 3.1-SNAPSHOT should already have the fix).

        Show
        Bhavanishankar added a comment - The changes were part of the plugin. So, the upcoming 3.1-b05 version of the plugin should have it (current 3.1-SNAPSHOT should already have the fix).
        Hide
        ljnelson added a comment -

        Bhavani, we may have to reopen this one; not sure.

        3.2-SNAPSHOT of the plugin prints the following:

        [INFO] — maven-embedded-glassfish-plugin:3.2-SNAPSHOT:start (default) @ junit-ejb-dbunit-mem —
        Created New Bootstrap ClassLoader. ServerId = embedded, ClassPaths =
        ClassPath Element : file:/Users/ljnelson/.m2/repository/org/glassfish/extras/glassfish-embedded-all/3.1-b39/glassfish-embedded-all-3.1-b39.jar
        ClassPath Element : file:/Users/ljnelson/.m2/repository/org/glassfish/maven-embedded-glassfish-plugin/3.2-SNAPSHOT/maven-embedded-glassfish-plugin-3.2-SNAPSHOT.jar

        You'll notice that h2 is not part of this list. When we were working on diagnosing this problem, the locally patched 3.2-SNAPSHOT file you sent me printed an additional ClassPath element that (when I had h2 in my dependencies section) also printed h2 as a classpath element.

        Now, what's odd is that in my test case (which you have, I believe), h2 is found and located, even with this output. I confirm this by looking up a datasource directly and getting a connection from it:

        final DataSource ds = (DataSource)context.lookup("java:global/jdbc/H2Test");
        ds.getConnection();

        ...where obviously I've set up H2Test in my domain.xml file properly.

        However, in my real-world example, which also includes a JPA persistence unit, EclipseLink cannot find the H2 driver. So, to recap, a straight DataSource lookup and connection retrieval works fine, but internal JPA operations (setting up the EntityManagerFactory, it looks like) fail.

        Here's a sample stack:

        Feb 7, 2011 2:50:03 PM com.sun.gjc.common.DataSourceObjectBuilder getDataSourceObject
        SEVERE: jdbc.exc_cnfe_ds
        java.lang.ClassNotFoundException: org.h2.jdbcx.JdbcDataSource
        at com.sun.enterprise.v3.server.APIClassLoaderServiceImpl$APIClassLoader.loadClass(APIClassLoaderServiceImpl.java:180)
        at com.sun.enterprise.v3.server.APIClassLoaderServiceImpl$APIClassLoader.loadClass(APIClassLoaderServiceImpl.java:172)
        at java.lang.Class.forName0(Native Method)
        at java.lang.Class.forName(Class.java:247)
        at com.sun.gjc.common.DataSourceObjectBuilder.getDataSourceObject(DataSourceObjectBuilder.java:283)
        at com.sun.gjc.common.DataSourceObjectBuilder.constructDataSourceObject(DataSourceObjectBuilder.java:112)
        at com.sun.gjc.spi.ManagedConnectionFactory.getDataSource(ManagedConnectionFactory.java:1290)
        at com.sun.gjc.spi.DSManagedConnectionFactory.getDataSource(DSManagedConnectionFactory.java:148)
        at com.sun.gjc.spi.DSManagedConnectionFactory.createManagedConnection(DSManagedConnectionFactory.java:101)
        at com.sun.enterprise.connectors.service.ConnectorConnectionPoolAdminServiceImpl.getUnpooledConnection(ConnectorConnectionPoolAdminServiceImpl.java:699)
        at com.sun.enterprise.connectors.service.ConnectorConnectionPoolAdminServiceImpl.getConnection(ConnectorConnectionPoolAdminServiceImpl.java:1602)
        at com.sun.enterprise.connectors.ConnectorRuntime.getConnection(ConnectorRuntime.java:584)
        at com.sun.enterprise.connectors.service.ConnectorResourceAdminServiceImpl$MyDataSource.getConnection(ConnectorResourceAdminServiceImpl.java:277)
        at org.eclipse.persistence.sessions.JNDIConnector.connect(JNDIConnector.java:126)
        at org.eclipse.persistence.sessions.JNDIConnector.connect(JNDIConnector.java:94)
        at org.eclipse.persistence.sessions.DatasourceLogin.connectToDatasource(DatasourceLogin.java:162)
        at org.eclipse.persistence.internal.databaseaccess.DatasourceAccessor.connectInternal(DatasourceAccessor.java:330)
        at org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.connectInternal(DatabaseAccessor.java:291)
        at org.eclipse.persistence.internal.databaseaccess.DatasourceAccessor.connect(DatasourceAccessor.java:418)
        at org.eclipse.persistence.sessions.server.ConnectionPool.buildConnection(ConnectionPool.java:167)
        at org.eclipse.persistence.sessions.server.ExternalConnectionPool.startUp(ExternalConnectionPool.java:130)
        at org.eclipse.persistence.sessions.server.ServerSession.connect(ServerSession.java:484)
        at org.eclipse.persistence.internal.sessions.DatabaseSessionImpl.login(DatabaseSessionImpl.java:640)
        at org.eclipse.persistence.internal.jpa.EntityManagerFactoryProvider.login(EntityManagerFactoryProvider.java:235)
        at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.deploy(EntityManagerSetupImpl.java:394)
        at org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.getServerSession(EntityManagerFactoryImpl.java:185)
        at org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.createEntityManagerImpl(EntityManagerFactoryImpl.java:242)
        at org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:230)
        at org.glassfish.persistence.jpa.PersistenceUnitLoader.doJava2DB(PersistenceUnitLoader.java:373)
        at org.glassfish.persistence.jpa.JPADeployer$2.visitPUD(JPADeployer.java:423)
        at org.glassfish.persistence.jpa.JPADeployer$PersistenceUnitDescriptorIterator.iteratePUDs(JPADeployer.java:475)
        at org.glassfish.persistence.jpa.JPADeployer.iterateInitializedPUsAtApplicationPrepare(JPADeployer.java:453)
        at org.glassfish.persistence.jpa.JPADeployer.event(JPADeployer.java:377)

        I will adapt my test case to this bug and attach it when I've got it suitably isolated.

        Show
        ljnelson added a comment - Bhavani, we may have to reopen this one; not sure. 3.2-SNAPSHOT of the plugin prints the following: [INFO] — maven-embedded-glassfish-plugin:3.2-SNAPSHOT:start (default) @ junit-ejb-dbunit-mem — Created New Bootstrap ClassLoader. ServerId = embedded, ClassPaths = ClassPath Element : file:/Users/ljnelson/.m2/repository/org/glassfish/extras/glassfish-embedded-all/3.1-b39/glassfish-embedded-all-3.1-b39.jar ClassPath Element : file:/Users/ljnelson/.m2/repository/org/glassfish/maven-embedded-glassfish-plugin/3.2-SNAPSHOT/maven-embedded-glassfish-plugin-3.2-SNAPSHOT.jar You'll notice that h2 is not part of this list. When we were working on diagnosing this problem, the locally patched 3.2-SNAPSHOT file you sent me printed an additional ClassPath element that (when I had h2 in my dependencies section) also printed h2 as a classpath element. Now, what's odd is that in my test case (which you have, I believe), h2 is found and located, even with this output. I confirm this by looking up a datasource directly and getting a connection from it: final DataSource ds = (DataSource)context.lookup("java:global/jdbc/H2Test"); ds.getConnection(); ...where obviously I've set up H2Test in my domain.xml file properly. However, in my real-world example, which also includes a JPA persistence unit, EclipseLink cannot find the H2 driver. So, to recap, a straight DataSource lookup and connection retrieval works fine, but internal JPA operations (setting up the EntityManagerFactory, it looks like) fail. Here's a sample stack: Feb 7, 2011 2:50:03 PM com.sun.gjc.common.DataSourceObjectBuilder getDataSourceObject SEVERE: jdbc.exc_cnfe_ds java.lang.ClassNotFoundException: org.h2.jdbcx.JdbcDataSource at com.sun.enterprise.v3.server.APIClassLoaderServiceImpl$APIClassLoader.loadClass(APIClassLoaderServiceImpl.java:180) at com.sun.enterprise.v3.server.APIClassLoaderServiceImpl$APIClassLoader.loadClass(APIClassLoaderServiceImpl.java:172) at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Class.java:247) at com.sun.gjc.common.DataSourceObjectBuilder.getDataSourceObject(DataSourceObjectBuilder.java:283) at com.sun.gjc.common.DataSourceObjectBuilder.constructDataSourceObject(DataSourceObjectBuilder.java:112) at com.sun.gjc.spi.ManagedConnectionFactory.getDataSource(ManagedConnectionFactory.java:1290) at com.sun.gjc.spi.DSManagedConnectionFactory.getDataSource(DSManagedConnectionFactory.java:148) at com.sun.gjc.spi.DSManagedConnectionFactory.createManagedConnection(DSManagedConnectionFactory.java:101) at com.sun.enterprise.connectors.service.ConnectorConnectionPoolAdminServiceImpl.getUnpooledConnection(ConnectorConnectionPoolAdminServiceImpl.java:699) at com.sun.enterprise.connectors.service.ConnectorConnectionPoolAdminServiceImpl.getConnection(ConnectorConnectionPoolAdminServiceImpl.java:1602) at com.sun.enterprise.connectors.ConnectorRuntime.getConnection(ConnectorRuntime.java:584) at com.sun.enterprise.connectors.service.ConnectorResourceAdminServiceImpl$MyDataSource.getConnection(ConnectorResourceAdminServiceImpl.java:277) at org.eclipse.persistence.sessions.JNDIConnector.connect(JNDIConnector.java:126) at org.eclipse.persistence.sessions.JNDIConnector.connect(JNDIConnector.java:94) at org.eclipse.persistence.sessions.DatasourceLogin.connectToDatasource(DatasourceLogin.java:162) at org.eclipse.persistence.internal.databaseaccess.DatasourceAccessor.connectInternal(DatasourceAccessor.java:330) at org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.connectInternal(DatabaseAccessor.java:291) at org.eclipse.persistence.internal.databaseaccess.DatasourceAccessor.connect(DatasourceAccessor.java:418) at org.eclipse.persistence.sessions.server.ConnectionPool.buildConnection(ConnectionPool.java:167) at org.eclipse.persistence.sessions.server.ExternalConnectionPool.startUp(ExternalConnectionPool.java:130) at org.eclipse.persistence.sessions.server.ServerSession.connect(ServerSession.java:484) at org.eclipse.persistence.internal.sessions.DatabaseSessionImpl.login(DatabaseSessionImpl.java:640) at org.eclipse.persistence.internal.jpa.EntityManagerFactoryProvider.login(EntityManagerFactoryProvider.java:235) at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.deploy(EntityManagerSetupImpl.java:394) at org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.getServerSession(EntityManagerFactoryImpl.java:185) at org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.createEntityManagerImpl(EntityManagerFactoryImpl.java:242) at org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:230) at org.glassfish.persistence.jpa.PersistenceUnitLoader.doJava2DB(PersistenceUnitLoader.java:373) at org.glassfish.persistence.jpa.JPADeployer$2.visitPUD(JPADeployer.java:423) at org.glassfish.persistence.jpa.JPADeployer$PersistenceUnitDescriptorIterator.iteratePUDs(JPADeployer.java:475) at org.glassfish.persistence.jpa.JPADeployer.iterateInitializedPUsAtApplicationPrepare(JPADeployer.java:453) at org.glassfish.persistence.jpa.JPADeployer.event(JPADeployer.java:377) I will adapt my test case to this bug and attach it when I've got it suitably isolated.
        Hide
        ljnelson added a comment -

        Please see the attached test case which proves that this bug needs to be reopened.

        H2 is found on the classpath when you do a direct DataSource lookup from an InitialContext, but it is NOT found by the EclipseLink internals. My suspicion is that whatever classpath you set up did not get propagated to the loader that EclipseLink uses.

        Show
        ljnelson added a comment - Please see the attached test case which proves that this bug needs to be reopened. H2 is found on the classpath when you do a direct DataSource lookup from an InitialContext, but it is NOT found by the EclipseLink internals. My suspicion is that whatever classpath you set up did not get propagated to the loader that EclipseLink uses.
        Hide
        Bhavanishankar added a comment -

        As I had mentioned in the previous comment, you should try with 3.1-b05 or 3.1-SNAPSHOT of the maven plugin. Not sure why you are using 3.2-SNAPSHOT.

        Show
        Bhavanishankar added a comment - As I had mentioned in the previous comment, you should try with 3.1-b05 or 3.1-SNAPSHOT of the maven plugin. Not sure why you are using 3.2-SNAPSHOT.
        Hide
        ljnelson added a comment -

        Well, you had sent me a patched version of 3.2-SNAPSHOT; I figured that the "real" 3.2-SNAPSHOT would have the fix.

        Additionally, 3.1-b05 was not available yesterday.

        The good news is that 3.1-b05 IS available today, and the test case now runs. Thanks for your work.

        Show
        ljnelson added a comment - Well, you had sent me a patched version of 3.2-SNAPSHOT; I figured that the "real" 3.2-SNAPSHOT would have the fix. Additionally, 3.1-b05 was not available yesterday. The good news is that 3.1-b05 IS available today, and the test case now runs. Thanks for your work.
        Hide
        chrisatpinguin added a comment -

        Hi,

        I know this issue is closed, but I try to use the embedded-gf-plugin with a jdbc Resource for DB2. So I need to add the driver jars. But how do I have to do that? Could someone please give me a hint or show me an example of the plugin configuration.

        Show
        chrisatpinguin added a comment - Hi, I know this issue is closed, but I try to use the embedded-gf-plugin with a jdbc Resource for DB2. So I need to add the driver jars. But how do I have to do that? Could someone please give me a hint or show me an example of the plugin configuration.

          People

          • Assignee:
            Bhavanishankar
            Reporter:
            ljnelson
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: