*
The moose likes Tomcat and the fly likes Tomcat Throwing java.lang.ClassNotFoundException Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Tomcat
Bookmark "Tomcat Throwing java.lang.ClassNotFoundException" Watch "Tomcat Throwing java.lang.ClassNotFoundException" New topic
Author

Tomcat Throwing java.lang.ClassNotFoundException

Somnath Mallick
Ranch Hand

Joined: Mar 04, 2009
Posts: 477
Hi Everyone,

It seems that my Tomcat 6.0.28 has run into some problems. I was running an Servlet/JSP project in Eclipse today. And I found that its throwing some errors. I have made a post in the JDBC section as well.
http://www.coderanch.com/t/476480/JDBC/java/Unable-Load-Driver
At first i thought that i must coded something wrong but it seems that all third party classes which need JARS to be added in the Classpath are causing the same problem!!! Now even the POI API is causing issues. although i have all the JARS added in the Classpath of the project.

This is what i got:
Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

Somnath Mallick wrote:seems that all third party classes which need JARS to be added in the Classpath


did you add into tomcat\lib folder ?
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41114
    
  45
did you add into tomcat\lib folder ?

Such libraries should be added to the WEB-INF/lib folder of the web app that uses them, not to Tomcat's lib folder.


Ping & DNS - my free Android networking tools app
Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

Ulf Dittmer wrote:
did you add into tomcat\lib folder ?

Such libraries should be added to the WEB-INF/lib folder of the web app that uses them, not to Tomcat's lib folder.


well ulf.but most of the time[i experienced] it is not loaded by container. what could be the problem?.[example, i was tried this by jdbc-connector.jar]
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41114
    
  45
So, *is* the library in the WEB-INF/lib folder, and did you restart the web app after placing it there? Earlier you were talking about "classpath of the project" which sounds like an Eclipse thing that is irrelevant to Tomcat.
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 15957
    
  19

JDBC jars SHOULD usually be placed in TOMCAT_HOME/lib. Application-specific resources such as Apache POI SHOULD usually be placed in the WAR's WEB-INF/lib folder, since they're not intended to be server-shared resources nor to be accessible from subsystems outside the webapp (like JDBC connection pools).


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

Joined: Jan 28, 2008
Posts: 5575

thanks Tim and Ulf
Somnath Mallick
Ranch Hand

Joined: Mar 04, 2009
Posts: 477
Well that was the problem! Some idiot had deleted the lib folder from the WEB-INF over the weekend! I had placed all the jars there knew that they were there.
Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

Somnath Mallick wrote:Some idiot had deleted the lib folder from the WEB-INF over the weekend!


Anyway thanks for that Idiot. because i get more clarification from this topic .
Theen-Theen Tan
Greenhorn

Joined: May 18, 2011
Posts: 1
Caused by: org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot load JDBC driver class 'oracle.jdbc.xa.client.OracleXADataSource'
at org.apache.tomcat.dbcp.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:1136)
at org.apache.tomcat.dbcp.dbcp.BasicDataSource.getConnection(BasicDataSource.java:880)
at org.springframework.scheduling.quartz.LocalDataSourceJobStore$2.getConnection(LocalDataSourceJobStore.java:129)
at org.quartz.utils.DBConnectionManager.getConnection(DBConnectionManager.java:112)
at org.quartz.impl.jdbcjobstore.JobStoreCMT.getNonManagedTXConnection(JobStoreCMT.java:164)
... 71 more
Caused by: java.lang.ClassNotFoundException: oracle.jdbc.xa.client.OracleXADataSource
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:169)
at org.apache.tomcat.dbcp.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:1130)


My data sources and transactionmanager are declared in context.xml, and the beans that are failing to create is part of a Spring context of the application.

I am seeing the error above will all the transaction and oracle driver located in by WEB-INF/lib We do not want to have anything in tomcat/lib

Is it possible?

Thanks!
 
 
subject: Tomcat Throwing java.lang.ClassNotFoundException
 
Similar Threads
Unable to Load the Driver!
Spring Webservices: FrameworkServlet exception
NEWBIE Q: How to parse an XML HTTP-POST request in servlets using JDOM?
java.lang.ClassNotFoundException: oracle:jdbc:driver:OracleDriver
java.lang.ClassNotFoundException: com.mysql.jdbc.Driver