• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

RestFul webservice using Hibernate with Oracle database is giving error

 
Ranch Hand
Posts: 101
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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)

 
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 101
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
reply
    Bookmark Topic Watch Topic
  • New Topic