File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Tomcat and the fly likes Web application Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Products » Tomcat
Bookmark "Web application" Watch "Web application" New topic
Author

Web application

deepa karra
Ranch Hand

Joined: Apr 04, 2008
Posts: 46
How can i solve the following jdbc error when running a webapplication on tomcat?
Here is the error message from the logfile.

May 31, 2010 4:02:12 PM org.apache.catalina.startup.HostConfig checkResources
INFO: Undeploying context [/UserExample]
May 31, 2010 4:02:22 PM org.apache.catalina.startup.HostConfig deployWAR
INFO: Deploying web application archive UserExample.war
May 31, 2010 4:02:23 PM org.springframework.web.context.ContextLoader initWebApplicationContext
INFO: Root WebApplicationContext: initialization started
May 31, 2010 4:02:23 PM org.springframework.context.support.AbstractApplicationContext prepareRefresh
INFO: Refreshing org.springframework.web.context.support.XmlWebApplicationContext@1bb3e9a: display name [Root WebApplicationContext]; startup date [Mon May 31 16:02:23 CEST 2010]; root of context hierarchy
May 31, 2010 4:02:23 PM org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
INFO: Loading XML bean definitions from ServletContext resource [/WEB-INF/applicationContext.xml]
May 31, 2010 4:02:23 PM org.springframework.context.support.AbstractApplicationContext obtainFreshBeanFactory
INFO: Bean factory for application context [org.springframework.web.context.support.XmlWebApplicationContext@1bb3e9a]: org.springframework.beans.factory.support.DefaultListableBeanFactory@c524dd
May 31, 2010 4:02:23 PM org.springframework.beans.factory.support.DefaultListableBeanFactory preInstantiateSingletons
INFO: Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@c524dd: defining beans [dataSource,sessionFactory,transactionManager,IUserDao,IUserService,org.springframework.aop.config.internalAutoProxyCreator,org.springframework.transaction.annotation.AnnotationTransactionAttributeSource#0,org.springframework.transaction.interceptor.TransactionInterceptor#0,org.springframework.transaction.config.internalTransactionAdvisor,userAction]; root of factory hierarchy
May 31, 2010 4:02:23 PM org.springframework.beans.factory.support.DefaultSingletonBeanRegistry destroySingletons
INFO: Destroying singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@c524dd: defining beans [dataSource,sessionFactory,transactionManager,IUserDao,IUserService,org.springframework.aop.config.internalAutoProxyCreator,org.springframework.transaction.annotation.AnnotationTransactionAttributeSource#0,org.springframework.transaction.interceptor.TransactionInterceptor#0,org.springframework.transaction.config.internalTransactionAdvisor,userAction]; root of factory hierarchy
May 31, 2010 4:02:23 PM org.springframework.web.context.ContextLoader initWebApplicationContext
SEVERE: Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Error setting property values; nested exception is org.springframework.beans.PropertyBatchUpdateException; nested PropertyAccessExceptions (1) are:
PropertyAccessException 1: org.springframework.beans.MethodInvocationException: Property 'driverClassName' threw exception; nested exception is java.lang.IllegalStateException: Could not load JDBC driver class [oracle.jdbc.driver.OracleDriver]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1278)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1010)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:472)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409)
at java.security.AccessController.doPrivileged(Native Method)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:380)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:264)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:221)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:261)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:429)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:729)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:381)
at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:255)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:199)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:45)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3972)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4467)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:791)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:771)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:546)
at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:905)
at org.apache.catalina.startup.HostConfig.deployWARs(HostConfig.java:740)
at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:500)
at org.apache.catalina.startup.HostConfig.check(HostConfig.java:1345)
at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:303)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
at org.apache.catalina.core.ContainerBase.backgroundProcess(ContainerBase.java:1337)
at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1601)
at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1610)
at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.run(ContainerBase.java:1590)
at java.lang.Thread.run(Thread.java:619)
Caused by: org.springframework.beans.PropertyBatchUpdateException; nested PropertyAccessExceptions (1) are:
PropertyAccessException 1: org.springframework.beans.MethodInvocationException: Property 'driverClassName' threw exception; nested exception is java.lang.IllegalStateException: Could not load JDBC driver class [oracle.jdbc.driver.OracleDriver]
at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:104)
at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:59)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1275)
... 32 more
May 31, 2010 4:02:23 PM org.apache.catalina.core.StandardContext start
SEVERE: Error listenerStart
May 31, 2010 4:02:23 PM org.apache.catalina.core.StandardContext start
SEVERE: Context [/UserExample] startup failed due to previous errors
Andrew Monkhouse
author and jackaroo
Marshal Commander

Joined: Mar 28, 2003
Posts: 11404
    
  81

Could not load JDBC driver class [oracle.jdbc.driver.OracleDriver]

Do you have the Oracle driver jar (zip) file in the application class path or the Tomcat class path?


The Sun Certified Java Developer Exam with J2SE 5: paper version from Amazon, PDF from Apress, Online reference: Books 24x7 Personal blog
deepa karra
Ranch Hand

Joined: Apr 04, 2008
Posts: 46
i have oracleice.jar,ojdbc14.jar
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14687
    
  16

deepa karra wrote:i have oracleice.jar,ojdbc14.jar

Where exactly ?


[My Blog]
All roads lead to JavaRanch
deepa karra
Ranch Hand

Joined: Apr 04, 2008
Posts: 46
i have ojdbc14.jar in web-inf\lib
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 15951
    
  19

deepa karra wrote:i have ojdbc14.jar in web-inf\lib


Remove it from there and place it in your TOMCAT_HOME/lib directory. Database drivers should normally be in the container's classpath.


Customer surveys are for companies who didn't pay proper attention to begin with.
deepa karra
Ranch Hand

Joined: Apr 04, 2008
Posts: 46
I removed ojdbc jar from web-inf/lib and placed it in TOMCAT_HOME/lib directory.
Now the log is

Jun 2, 2010 9:04:18 AM org.apache.catalina.startup.HostConfig checkResources
INFO: Undeploying context [/UserExample]
Jun 2, 2010 9:04:29 AM org.apache.catalina.startup.HostConfig deployWAR
INFO: Deploying web application archive UserExample.war
Jun 2, 2010 9:04:31 AM org.apache.catalina.core.StandardContext start
SEVERE: Error listenerStart
Jun 2, 2010 9:04:31 AM org.apache.catalina.core.StandardContext start
SEVERE: Context [/UserExample] startup failed due to previous errors
deepa karra
Ranch Hand

Joined: Apr 04, 2008
Posts: 46
I created an example to integrate struts,spring and hibernate based on the tutorial. I have an error which asks for hibernate.cfg.xml.

type Exception report

message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

org.hibernate.SessionException: Error! Please, check your JDBC/JDNI Configurations and Database Server avaliability.
Could not open or put a Hibernate Session in ValueStack: /hibernate.cfg.xml not found
com.googlecode.s2hibernate.struts2.plugin.interceptors.SessionTransactionInjectorInterceptor.intercept(SessionTransactionInjectorInterceptor.java:134)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236)
org.apache.struts2.impl.StrutsActionProxy.execute(StrutsActionProxy.java:52)
org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:488)
org.apache.struts2.dispatcher.FilterDispatcher.doFilter(FilterDispatcher.java:395)

Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 15951
    
  19

That is correct. You need a hibernate.cfg.xml file in your WAR's WEB-INF/classes directory to define the persistence classes to Hibernate.
deepa karra
Ranch Hand

Joined: Apr 04, 2008
Posts: 46
i am defining all the properties in applicationcontext.xml. Do i still need a hibernate.cfg.xml?
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Web application
 
Similar Threads
Getting Error in setting property values
Exception in thread "main" org.springframework.beans.factory.BeanCreationException
NotWritablePropertyException,BeanCreationException
Tomcat + Spring + Hibernate: PropertyNotFoundException
Getting exception of org.dom4j.DocumentException : feature read only while deploying war file in tom