Marshall
Marshall

Reputation: 1195

Cannot connect to database using JDBC on Glassfish3

Is there any way to check whether my Glassfish acctually see ojdbc6.jar ?

I'm working with Netbeans 7.2.1, with JSF 2, Glassfish 3.1.2 and Oracle 11g. I want to connecto to this database.

So first I need to create connection pool in my Glassfish. I open localhost:4848 set 5 things:

  1. Resource Type: javax.sql.DataSource
  2. Class name of the data source: oracle.jdbc.pool.OracleDataSource
  3. Property: "user"
  4. Property: "password"
  5. Property: "url"

Save, reset server (just for sure), ping.... and the error: Class name is wrong or classpath is not set for: oracle.jdbc.pool.OracleDataSource

What have I already done:

  1. First check for ojdbc jars. From my Oracle dir I copied every jar that has "ojdbc" in name into "C:\glassfish3\glassfish\domains\domain1\lib".

  2. Second, check url properity. Inside Netbeans, switch into Services tab, right click on Databases, New connection... set data to connect (first I have to add, jodbc6.jar.. so I add exactly the same file - from glassfish folder). It works! connection is ok. I looked at Netbeans database url - the same as my url in glassfish gui. I also tried url with \, but it didn't help.

So, what else can it be? Maybe no.1 is not ok. So this is my question: How can I check whether my Glassfish acctually see ojdbc6.jar?

EDIT. When I run Glassfish i get some warnings:

WARNING: Multiple [2] JMX MBeanServer instances exist, we will use the server at index [0] : [com.sun.enterprise.v3.admin.DynamicInterceptor@704d54].

WARNING: JMX MBeanServer in use: [com.sun.enterprise.v3.admin.DynamicInterceptor@704d54] from index [0]

WARNING: JMX MBeanServer in use: [com.sun.jmx.mbeanserver.JmxMBeanServer@ed312d] from index [1]

Upvotes: 4

Views: 27378

Answers (6)

Tora
Tora

Reputation: 31

For payara server i copied ojdbc jar to {payara_installation_folder}\glassfish\lib,its works fine

Upvotes: 0

Madhu Pisipati
Madhu Pisipati

Reputation: 61

Copy the ojdbc6-11.1.0.jar (the ojdbc6 version could be different in your case ) to glassfish_installation\glassfish\lib

Restart glassfish server

Upvotes: 0

Tom Malaher
Tom Malaher

Reputation: 61

Note that when NetBeans runs glassfish on Windows, the "domains" directory it uses is in your home directory, not in C:\glassfish or C:\Program Files\glassfish

On my windows 7, running NetBeans 8.0.2 with Glassfish 4.1, I had to put the Oracle driver jar (ojdbc6.jar) into

c:/Users/t823517/AppData/Roaming/NetBeans/8.0.2/config/GF_4.1/domain1

Upvotes: 1

nuamehas
nuamehas

Reputation: 614

"..But how do you know it is 'ext' folder? And not just 'lib'? One guy says lib, other ext.."

Making the JDBC Driver JAR Files Accessible To integrate the JDBC driver into a GlassFish Server domain, copy the JAR files into the domain-dir/lib directory, then restart the server. This makes classes accessible to all applications or modules deployed on servers that share the same configuration. For more information about GlassFish Server class loaders, see "Class Loaders" in GlassFish Server Open Source Edition Application Development Guide. If you are using an Oracle database with EclipseLink extensions, copy the JAR files into the domain-dir/lib/ext directory, then restart the server. For details, see "Oracle Database Enhancements" in GlassFish Server Open Source Edition Application Development Guide

From here

Upvotes: 2

Stepan Yakovenko
Stepan Yakovenko

Reputation: 9226

May be netbeans create virtual app if you run glassfish from IDE. Try this way of adding jars: http://netbeans.org/kb/docs/javaee/entappclient.html

Upvotes: 0

Fathah Rehman P
Fathah Rehman P

Reputation: 8761

Copy all required jar files(ojdbc6.jar.....) to 'domains\domain1\lib\ext' folder. Then restart your glassfish. Then try to ping from glassfish, it will work

Upvotes: 22

Related Questions