aspose file tools*
The moose likes EJB and other Java EE Technologies and the fly likes Unable to inject @Resource into ApplicationClient using ACC Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "Unable to inject @Resource into ApplicationClient using ACC" Watch "Unable to inject @Resource into ApplicationClient using ACC" New topic
Author

Unable to inject @Resource into ApplicationClient using ACC

Arun Kandregula
Greenhorn

Joined: Dec 19, 2005
Posts: 26
Hi,

I am trying to inject a @Resource into Application Client.

Here is my ApplicationClient:



I am using GlassFish application Server and Oracle 10g database.

Step 1.
-------
I created a connection pool with (just for testing) [ on Glassfish admin console http://localhost:4848] :

Name: abc
Datasource Classname: oracle.jdbc.pool.OracleDataSource
Resource Type: javax.sql.DataSource
URL : jdbc:oracle:thin:@localhost:1521:myservicename
user name: scott
password : tiger

Ping was successful.

Step 2
--------
I create JDBC > JDBC Resource.

JNDI Name: jdbc/abcd
Pool Name : abc (selected 'abc' from dropdown)


I have this CLASSPATH = javaee.jar; [ provided by Glassfish ]
appserv-rt.jar; [ provided by Glassfish ]
ojdbc14.jar; [provided by oracle ]

MANIFEST.MF has correct entry :
-------------------------------------
Main-Class: arun.di.ResourceInjectionDemo

I packaged my application client into c.jar. [c for client]

This is how I am invoking my application client:

C:\arun\ejb3practice\DI\ApplicationClient>appclient -client c.jar
Jun 24, 2009 12:26:11 AM com.sun.gjc.common.DataSourceObjectBuilder getDataSourc
eObject
SEVERE: RAR5099 : Wrong class name or classpath for Datasource Object
java.lang.ClassNotFoundException: oracle.jdbc.pool.OracleDataSource
at com.sun.enterprise.loader.EJBClassLoader.findClassData(EJBClassLoader
.java:738)
at com.sun.enterprise.loader.EJBClassLoader.findClass(EJBClassLoader.jav
a:628)

...........
...........

WARNING: RAR5038:Unexpected exception while creating resource for pool abc. Exce
ption : Class name is wrong or classpath is not set for : oracle.jdbc.pool.Oracl
eDataSource
Jun 24, 2009 12:26:11 AM com.sun.enterprise.connectors.ConnectionManagerImpl int
ernalGetConnection
WARNING: RAR5117 : Failed to obtain/create connection from connection pool [ abc
]. Reason : Class name is wrong or classpath is not set for : oracle.jdbc.pool.
OracleDataSource
Jun 24, 2009 12:26:11 AM com.sun.gjc.spi.base.DataSource getConnection
WARNING: RAR5114 : Error allocating connection : [Error in allocating a connecti
on. Cause: Class name is wrong or classpath is not set for : oracle.jdbc.pool.Or
acleDataSource]
Jun 24, 2009 12:26:11 AM com.sun.enterprise.appclient.MainWithModuleSupport <ini
t>
WARNING: ACC003: Application threw an exception.
java.sql.SQLException: Error in allocating a connection. Cause: Class name is wr
ong or classpath is not set for : oracle.jdbc.pool.OracleDataSource
at com.sun.gjc.spi.base.DataSource.getConnection(DataSource.java:115)
at arun.di.ResourceInjectionDemo.main(ResourceInjectionDemo.java:17)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
....

C:\arun\ejb3practice\DI\ApplicationClient>


I dont know why it is saying Caused by: java.sql.SQLException: Error in allocating a connection. Cause: Class
name is wrong or classpath is not set for : oracle.jdbc.pool.OracleDataSource.

I have ojdbc14.jar in my CLASSPATH.
C:\arun\ejb3practice\DI\ApplicationClient>set CLASSPATH
CLASSPATH=;C:\arun\softwares\Java\Java Kingdom\GlassFish\glassfish\lib\javaee.ja
r;C:\arun\softwares\Java\Java Kingdom\GlassFish\glassfish\lib\appserv-rt.jar;;C:
\oracle\product\10.2.0\db_1\jdbc\lib\ojdbc14.jar;



NOTE: Also, before starting the domain1 of Glassfish, I have copied ojdbc14.jar to glassfish\domains\domain1\lib\ext dir.

Please tell me where I am wrong.


Thanks.
Arun Kumar Kandregula.
SCBCD 1.3 92%
SCJP 1.4 98%
Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 10290
    
168

Cause: Class name is wrong or classpath is not set for : oracle.jdbc.pool.OracleDataSource


I have ojdbc14.jar in my CLASSPATH.
C:\arun\ejb3practice\DI\ApplicationClient>set CLASSPATH


Application servers don't usually use the CLASSPATH environment variable. They instead have their own scripts where the classpath is set. How do you start the Application client container? Is there a script for that? You might want to look at it to see if any classpath is being set there and then place your jar in the appropriate location.

Or you might also try adding a "Class-Path" attribute in the MANIFEST.MF file of your client jar file to point to the Oracle JDBC jar file. See this for details.

[My Blog] [JavaRanch Journal]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Unable to inject @Resource into ApplicationClient using ACC