• Post Reply Bookmark Topic Watch Topic
  • New Topic

RestFul webservice using Hibernate with Oracle database is giving error

 
Tim Bee
Ranch Hand
Posts: 91
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If I use this code in a batch program, I do not get this error. I can access the tables and perform whatever I want.

Configuration configuration = new Configuration().configure();
StandardServiceRegistryBuilder builder = new StandardServiceRegistryBuilder().applySettings(configuration.getProperties());
SessionFactory factory = configuration.buildSessionFactory(builder.build());
Session session = factory.openSession();
Emp emp1 = new Emp();
int empID1 = 7938;
Transaction transaction = null;
try {
transaction = session.beginTransaction();
emp1 = (Emp) session.get(Emp.class, empID1);
System.out.println("eName = " + emp1.geteName());
System.out.println("Job = " + emp1.getJob());

transaction.commit();
} catch (HibernateException e) {
transaction.rollback();
e.printStackTrace();
} finally {
session.close();
}




When I use the same code as part of a RestFul Sprint webservice, i get this error.

SEVERE: Servlet.service() for servlet [mvc-dispatcher] in context with path [/SpringRestFulExample] threw exception [Request processing failed; nested exception is org.hibernate.boot.registry.classloading.spi.ClassLoadingException: Specified JDBC Driver oracle.jdbc.driver.OracleDriver could not be loaded] with root cause
java.lang.ClassNotFoundException: Could not load requested class : oracle.jdbc.driver.OracleDriver
at org.hibernate.boot.registry.classloading.internal.ClassLoaderServiceImpl$AggregatedClassLoader.findClass(ClassLoaderServiceImpl.java:201)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:344)

 
Paul Clapham
Sheriff
Posts: 21882
36
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Then you don't have the Oracle JDBC driver jar in a place where that code expects to load jars from.

So when you're configuring your web service in whatever container you're using to support it, you should make sure that the Oracle jar gets put in the right place. (However without knowing anything about the environment you're using I can't suggest in more detail where the jar should go.)
 
Tim Bee
Ranch Hand
Posts: 91
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Paul Clapham wrote:Then you don't have the Oracle JDBC driver jar in a place where that code expects to load jars from.

So when you're configuring your web service in whatever container you're using to support it, you should make sure that the Oracle jar gets put in the right place. (However without knowing anything about the environment you're using I can't suggest in more detail where the jar should go.)


When I try to specify that through the Maven POM file, it gives an error. Is that where it is done?
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!