-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 11 posts ] 
Author Message
 Post subject: JDBC Driver class not foud - Oracle
PostPosted: Mon Aug 02, 2004 8:50 am 
Newbie

Joined: Mon Aug 02, 2004 8:32 am
Posts: 16
net.sf.hibernate.HibernateException: JDBC Driver class not found: oracle.jdbc.driver.OracleDriver


Hi!

My Hibernate Version: 2.1.4

This is the error occurs when i go to my testpage.

Here is my hibernate.properties file:




######################
### Query Language ###
######################

## define query language constants / function names

hibernate.query.substitutions true 1, false 0, yes 'Y', no 'N'

#################
### Platforms ###
#################


## Oracle

#hibernate.dialect=net.sf.hibernate.dialect.Oracle9Dialect
hibernate.dialect net.sf.hibernate.dialect.OracleDialect
hibernate.connection.driver_class oracle.jdbc.driver.OracleDriver
hibernate.connection.username xxxxx
hibernate.connection.password xxxxx
hibernate.connection.url jdbc:oracle:thin:@localhost:1521:timet


#################################
### Hibernate Connection Pool ###
#################################

hibernate.connection.pool_size 1

hibernate.show_sql true

## set the maximum JDBC 2 batch size (a nonzero value enables batching)

hibernate.jdbc.batch_size 0


## use streams when writing binary types to / from JDBC

hibernate.jdbc.use_streams_for_binary true


hibernate.max_fetch_depth 1


## enable CGLIB reflection optimizer (enabled by default)

hibernate.cglib.use_reflection_optimizer false

##########################
### Second-level Cache ###
##########################

hibernate.cache.region_prefix hibernate.test
hibernate.cache.use_query_cache true

## choose a cache implementation

hibernate.cache.provider_class net.sf.hibernate.cache.EmptyCacheProvider


My Code in the Java File:


import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;


import net.sf.hibernate.cfg.Configuration;
import net.sf.hibernate.Session;
import net.sf.hibernate.SessionFactory;
import net.sf.hibernate.Hibernate;
import net.sf.hibernate.cfg.*;


import testbed.model.Group;



/*
* Action Class for the Group
* reads the attributes and makes a decision
*/

public class GroupAction extends Action {

//Attributes
private String mTarget="success";
private String mName=null;
private int mOrder=0;

private Configuration mHibernate;

public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)
throws IOException, ServletException, Exception {

testLoad();

if(form != null) {

GroupForm f = (GroupForm)form;
mName=f.getName();
mOrder=f.getOrder();

//failure check
if(mName.equals("")){
mTarget="failure";
}

}

// Forward to the appropriate View
return (mapping.findForward(mTarget));
}



public void testLoad() throws Exception{

//SessionFactory sessions = mHibernate.buildSessionFactory();
//Session session = sessions.openSession();
//Class.forName("oracle.jdbc.driver.OracleDriver");
Configuration cfg=new Configuration();
cfg.addClass(Group.class);
SessionFactory sf = cfg.buildSessionFactory();
Session session = sf.openSession();

Group g = new Group();
g.setId(1);
g.setName("ertl bernahrd");
g.setDisplay_order(1);
session.save(g);
session.flush();
session.close();
}


}


Top
 Profile  
 
 Post subject:
PostPosted: Mon Aug 02, 2004 8:52 am 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
What do you think could be the problem if the error message is "I can't find your driver"?

_________________
JAVA PERSISTENCE WITH HIBERNATE
http://jpwh.org
Get the book, training, and consulting for your Hibernate team.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Aug 02, 2004 10:47 am 
Newbie

Joined: Mon Aug 02, 2004 8:32 am
Posts: 16
christian wrote:
What do you think could be the problem if the error message is "I can't find your driver"?


It's quite sure that it has to do something that the driver could not be found, but the driver is in the /lib Directory and it ist the classes12.jar Driver for the Oracle Database but it doesn't already work.

It would really be nice if I get some usefull information to solve that problem.

Thankx in advise


Top
 Profile  
 
 Post subject:
PostPosted: Mon Aug 02, 2004 10:50 am 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
Try to find your driver class with straight JDBC/SQL, without Hibernate.

_________________
JAVA PERSISTENCE WITH HIBERNATE
http://jpwh.org
Get the book, training, and consulting for your Hibernate team.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Aug 02, 2004 11:30 am 
Newbie

Joined: Mon Aug 02, 2004 8:32 am
Posts: 16
christian wrote:
Try to find your driver class with straight JDBC/SQL, without Hibernate.


I did an example with simple Java and Prepared Statements and it worked fine without any error ..
here is some example how i load the driver in that case where it worked.

So the driver class should also be right for hibernate ???
Thank you for futher help!



//Load and register Oracle driver
DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());

//Establish a connection
conn = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:timet", "xxx", "xxx");

String sql2 = "INSERT INTO maingroup VALUES (?,?,?)";

PreparedStatement pstmt2 = conn.prepareStatement(sql2)


Top
 Profile  
 
 Post subject: How does hibernate know which config file it should use
PostPosted: Mon Aug 02, 2004 11:55 am 
Newbie

Joined: Mon Aug 02, 2004 8:32 am
Posts: 16
If I am right then there exist two ways how to implement the configuration files:

One way is where we use the hibernate.properties file without any other Tomcat configuration.

Then on the other hand there is the possibility to configure the Tomcat and to use a hibernate.cfg.xml file.

So my Question is:
How does Hibernate know where to take the configuration from and in which directories these files have to be

Thank you for any answers!


Top
 Profile  
 
 Post subject:
PostPosted: Mon Aug 02, 2004 12:03 pm 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
No, this has nothing to do with Tomcat. Hibernate looks for hibernate.properties and loads it if it can be found in the classpath. It then looks for hibernate.cfg.xml and loads it if it can be found in the classpath. Both are equivalent, the XML however overrides any properties. Most people use the XML configuration, because it allows you to also declare mapping files, instead of adding them programatically to a Configuration.

If you set up a Datasource in Tomcat, you have to tell Hibernate how to get the Datasource one way or the other.

_________________
JAVA PERSISTENCE WITH HIBERNATE
http://jpwh.org
Get the book, training, and consulting for your Hibernate team.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 03, 2004 5:25 am 
Newbie

Joined: Mon Aug 02, 2004 8:32 am
Posts: 16
christian wrote:
No, this has nothing to do with Tomcat. Hibernate looks for hibernate.properties and loads it if it can be found in the classpath. It then looks for hibernate.cfg.xml and loads it if it can be found in the classpath. Both are equivalent, the XML however overrides any properties. Most people use the XML configuration, because it allows you to also declare mapping files, instead of adding them programatically to a Configuration.

If you set up a Datasource in Tomcat, you have to tell Hibernate how to get the Datasource one way or the other.




Hi!

I think i have a classpath problem because the error occurs only with hibernate and not with normal JCBC via prepared statements.

now we tried to set our classpath like the following:

setenv CLASSPATH /opt/local/common/java/tomcat/common/lib

(the ...common/lib directory is the directory where the file classes12.jar exists)


but it also does'nt work....

i really don't know what to do any more...

the error description


javax.servlet.ServletException: JDBC Driver class not found: oracle.jdbc.driver.OracleDriver
at org.apache.struts.action.RequestProcessor.processException(RequestProcessor.java:545)
at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:486)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:274)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)
at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:525)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:256)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2416)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:171)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:172)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:223)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:601)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:392)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:565)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:619)
at java.lang.Thread.run(Thread.java:534)


root cause

net.sf.hibernate.HibernateException: JDBC Driver class not found: oracle.jdbc.driver.OracleDriver
at net.sf.hibernate.connection.DriverManagerConnectionProvider.configure(DriverManagerConnectionProvider.java:63)
at net.sf.hibernate.connection.ConnectionProviderFactory.newConnectionProvider(ConnectionProviderFactory.java:83)
at net.sf.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:64)
at net.sf.hibernate.cfg.Configuration.buildSettings(Configuration.java:1132)
at net.sf.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:766)
at com.nokia.testbed.web.GroupAction.testLoad(GroupAction.java:125)
at com.nokia.testbed.web.GroupAction.execute(GroupAction.java:58)
at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:484)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:274)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)
at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:525)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:256)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2416)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:171)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:172)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:223)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:601)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:392)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:565)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:619)
at java.lang.Thread.run(Thread.java:534)




Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 03, 2004 5:52 am 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
Delete everything you have. Download fresh Tomcat and Hibernate package. Start with the Hibernate "Quickstart" documentation and follow it step by step, word by word.

_________________
JAVA PERSISTENCE WITH HIBERNATE
http://jpwh.org
Get the book, training, and consulting for your Hibernate team.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 03, 2004 7:19 am 
Newbie

Joined: Mon Aug 02, 2004 8:32 am
Posts: 16
2004-08-03 13:12:02,910|Thread-3|INFO |net.sf.hibernate.cfg.Configuration||processing foreign key constraints

2004-08-03 13:12:03,131|Thread-3|INFO |net.sf.hibernate.dialect.Dialect||Using dialect: net.sf.hibernate.dialect.OracleDialect

2004-08-03 13:12:03,139|Thread-3|INFO |net.sf.hibernate.cfg.SettingsFactory||Maximim outer join fetch depth: 1

2004-08-03 13:12:03,140|Thread-3|INFO |net.sf.hibernate.cfg.SettingsFactory||Use outer join fetching: true

2004-08-03 13:12:03,179|Thread-3|INFO |net.sf.hibernate.connection.DriverManagerConnectionProvider||Using Hibernate built-in connection pool (not for production use!)

2004-08-03 13:12:03,179|Thread-3|INFO |net.sf.hibernate.connection.DriverManagerConnectionProvider||Hibernate connection pool size: 1

2004-08-03 13:12:03,185|Thread-3|FATAL|net.sf.hibernate.connection.DriverManagerConnectionProvider||JDBC Driver class not found: oracle.jdbc.driver.OracleDriver

2004-08-03 13:12:03,213|Thread-3|WARN |org.apache.struts.action.RequestProcessor||Unhandled Exception thrown: class net.sf.hibernate.HibernateException


Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 03, 2004 7:42 am 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
Then your driver is not in the classpath. All Hibernate does is a Class.forName().

_________________
JAVA PERSISTENCE WITH HIBERNATE
http://jpwh.org
Get the book, training, and consulting for your Hibernate team.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 11 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.