eclipse-ee4j / glassfish

Eclipse GlassFish
https://eclipse-ee4j.github.io/glassfish/
383 stars 143 forks source link

Context class loader not correctly set during startup, deployment and admin cli invocation #5596

Closed glassfishrobot closed 16 years ago

glassfishrobot commented 16 years ago

On build 20 I am trying to setup a JDBC Connection Pool to an Oracle database. I downloaded the ojdbc6.jar from Oracle's website and copied it into <gf install>/glassfish/lib and restarted GlassFish. Next, I setup a connection pool with the command

./bin/asadmin create-jdbc-connection-pool --datasourceclassname oracle.jdbc.pool.OracleDataSource --restype javax.sql.DataSource --property user=astro:password=astro:url=jdbc\:oracle\:thin\:@localhost\:1521 :xe astro

After this, the command

./bin/asadmin list-jdbc-connection-pools

lists my connection pool. Next, I try to ping it with

./bin/asadmin ping-connection-pool astro

This gives the error

java.lang.ClassNotFoundException: oracle.jdbc.pool.OracleDataSource

The same error occurs when placing the driver jar in <gf install>/glassfish/domains/domain1/lib. And the same error occurs when I use the older ojdbc14.jar which works perfectly ok in GFv2.

Environment

Operating System: All Platform: Linux

Affected Versions

[V3]

glassfishrobot commented 6 years ago
glassfishrobot commented 16 years ago

@glassfishrobot Commented sherryshen said: cc

glassfishrobot commented 16 years ago

@glassfishrobot Commented kumara said: Change to status whiteboard for v3 bug tracking

glassfishrobot commented 16 years ago

@glassfishrobot Commented @h2002044 said: When the driver file is available in lib, application that is doing IC.lookup() is working fine. ds.getConnection() passes.

When issued ping-connection-pool, it fails.


[#|2008-08-22T18:23:23.828+0530|SEVERE|| javax.enterprise.resource.resourceadapter| _ThreadID=16;_ThreadName=Thread-3;|jdbc.exc_cnfe_ds java.lang.ClassNotFoundException: oracle.jdbc.pool.OracleDataSource at org.apache.felix.framework.Felix.loadBundleClass(Felix.java:1504) at org.apache.felix.framework.BundleImpl.loadClass(BundleImpl.java:358) at org.jvnet.hk2.osgiadapter.OSGiModuleImpl $2.loadClass(OSGiModuleImpl.java:295) at java.lang.ClassLoader.loadClass(ClassLoader.java:251) at com.sun.gjc.common.DataSourceObjectBuilder.getDataSourceObject(DataSourceObjectBuilder.java:252) at com.sun.gjc.common.DataSourceObjectBuilder.constructDataSourceObject(DataSourceObjectBuilder.java:106) at com.sun.gjc.spi.ManagedConnectionFactory.getDataSource(ManagedConnectionFactory.java:967) at com.sun.gjc.spi.DSManagedConnectionFactory.getDataSource(DSManagedConnectionFactory.java:135) at com.sun.gjc.spi.DSManagedConnectionFactory.createManagedConnection(DSManagedConnectionFactory.java:90) at com.sun.enterprise.connectors.service.ConnectorConnectionPoolAdminServiceImpl.getUnpooledConnection(ConnectorConnectionPoolAdminServiceImpl.java:589) at com.sun.enterprise.connectors.service.ConnectorConnectionPoolAdminServiceImpl.testConnectionPool(ConnectorConnectionPoolAdminServiceImpl.java:437) at com.sun.enterprise.connectors.ConnectorRuntime.pingConnectionPool(ConnectorRuntime.java:682) at org.glassfish.javaee.admin.PingJdbcConnectionPool.execute(PingJdbcConnectionPool.java:79) at com.sun.enterprise.v3.admin.CommandRunner.doCommand(CommandRunner.java:286) at com.sun.enterprise.v3.admin.CommandRunner.doCommand(CommandRunner.java:114) at com.sun.enterprise.v3.admin.CommandRunner.doCommand(CommandRunner.java:94) at com.sun.enterprise.v3.admin.AdminAdapter.doCommand(AdminAdapter.java:240) at com.sun.enterprise.v3.admin.AdminAdapter.service(AdminAdapter.java:166) at com.sun.grizzly.tcp.http11.GrizzlyAdapter.service(GrizzlyAdapter.java:148) at com.sun.grizzly.http.DefaultProcessorTask.invokeAdapter(DefaultProcessorTask.java:621) at com.sun.grizzly.http.DefaultProcessorTask.doProcess(DefaultProcessorTask.java:552) at com.sun.grizzly.http.DefaultProcessorTask.process(DefaultProcessorTask.java:800) at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:152) at com.sun.enterprise.v3.services.impl.HttpProtocolFilter.execute(HttpProtocolFilter.java:82) at com.sun.enterprise.v3.services.impl.GlassfishProtocolChain.executeProtocolFilter(GlassfishProtocolChain.java:70) at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:103) at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:89) at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:67) at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:56) at com.sun.grizzly.util.WorkerThreadImpl.processTask(WorkerThreadImpl.java:309) at com.sun.grizzly.util.WorkerThreadImpl.run(WorkerThreadImpl.java:168)

| #] |

[#|2008-08-22T18:23:23.897+0530|WARNING|| javax.enterprise.resource.resourceadapter| _ThreadID=16;_ThreadName=Thread-3;|Class name is wrong or classpath is not set for : oracle.jdbc.pool.OracleDataSource|#]

JDBC-RA uses ThreadContextClassLoader to look for the class. We assume that the TCC will be common-class-loader that has access to lib.

Transferring the bug to Jerome for investigation.

glassfishrobot commented 16 years ago

@glassfishrobot Commented wvreeven said: I tried to wrap the Oracle JDBC driver jar in an OSGi bundle, using bnd as described here

http://blog.springsource.com/main/2008/02/18/creating-osgi-bundles/

This didn't help unfortunately. Could it be that this issue and issue 5631 are sismlar issues?

glassfishrobot commented 16 years ago

@glassfishrobot Commented ss141213 said: To be compatible with V2, we need to set CommonClassLoader as the context class loader. This needs to happen in three places at least: 1. While running Startup services, as they are our new equivalent of LifeCycle modules of V2.

2. While running any Admin command.

3. During deployment/loading until we have created the application class loader.

This will not only address this bug, but also https://glassfish.dev.java.net/issues/show_bug.cgi?id=5568

glassfishrobot commented 16 years ago

@glassfishrobot Commented wvreeven said: Please disregard my reference to issue 5631. The workaround for that issue is to use JDK 5 while that doesn't solve this issue.

glassfishrobot commented 16 years ago

@glassfishrobot Commented arungupta said: Saw this exact error when used MySQL Connector/J jar in GLASSFISH_HOME/lib:

Aug 27, 2008 9:04:16 PM com.sun.gjc.common.DataSourceObjectBuilder getDataSourceObject SEVERE: jdbc.exc_cnfe_ds java.lang.ClassNotFoundException: com.mysql.jdbc.jdbc2.optional.MysqlConnectionPoolDataSource at org.apache.felix.framework.searchpolicy.R4SearchPolicyCore.findClass(R4SearchPolicyCore.java:200) at org.apache.felix.framework.searchpolicy.R4SearchPolicy.findClass(R4SearchPolicy.java:45) at org.apache.felix.framework.searchpolicy.ContentClassLoader.loadClass(ContentClassLoader.java:109) at java.lang.ClassLoader.loadClass(ClassLoader.java:251)

glassfishrobot commented 16 years ago

@glassfishrobot Commented kumara said: v3 defect tracking

glassfishrobot commented 16 years ago

@glassfishrobot Commented wvreeven said: Just tested this with ojdbc14.jar (quite an old jar) on build 23. All works ok now. Thanks so much for fixing this. Please close this issue.

glassfishrobot commented 16 years ago

@glassfishrobot Commented ss141213 said: No, don't close this bug. This is a very important bug.

Sahoo

glassfishrobot commented 16 years ago

@glassfishrobot Commented ss141213 said: The subject has been changed to reflect the root cause. Since it is a severe issue, its priority has been increased to P2.

glassfishrobot commented 16 years ago

@glassfishrobot Commented ss141213 said: Taking ownership per discussion with Jerome.

glassfishrobot commented 16 years ago

@glassfishrobot Commented ss141213 said: Fix details:

During startup and admin cli operation, it is set to CommonClassLoader. While deploying the application, it is set to that application's class loader. Sending core/kernel/src/main/java/com/sun/enterprise/v3/admin/CommandRunner.java Sending core/kernel/src/main/java/com/sun/enterprise/v3/server/AppServerStartup.java Sending core/kernel/src/main/java/com/sun/enterprise/v3/server/ApplicationLifecycle.java Sending core/kernel/src/test/java/com/sun/enterprise/v3/admin/ConfigAttributeSetTest.java Sending jdbc/admin/src/test/java/org/glassfish/jdbc/admin/cli/CreateJdbcResourceTest.java Sending jdbc/admin/src/test/java/org/glassfish/jdbc/admin/cli/DeleteJdbcResourceTest.java Sending jdbc/admin/src/test/java/org/glassfish/jdbc/admin/cli/ListJdbcResourcesTest.java Transmitting file data ....... Committed revision 22735.

glassfishrobot commented 16 years ago

@glassfishrobot Commented ss141213 said: The summary got overwritten by a vimperator command! fixing it...

glassfishrobot commented 16 years ago

@glassfishrobot Commented ss141213 said:

glassfishrobot commented 16 years ago

@glassfishrobot Commented wvreeven said: In build 26 this issue is fixed. I just confirmed that. Thanks!

glassfishrobot commented 16 years ago

@glassfishrobot Commented Was assigned to ss141213

glassfishrobot commented 7 years ago

@glassfishrobot Commented This issue was imported from java.net JIRA GLASSFISH-5596

glassfishrobot commented 16 years ago

@glassfishrobot Commented Reported by wvreeven

glassfishrobot commented 16 years ago

@glassfishrobot Commented Marked as fixed on Monday, September 29th 2008, 3:07:34 am