Hello to all,

Despite I added all necessary .jar files to project, I always take boring exception warnings that say "class not found". I added the code and exception output below. I'll be so happy if someone can help me.

Thanx in advance..
With regards,
T
-----------------------------------------------------

protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		KisiHelper kh = new KisiHelper();  // ======> *Exception Warning!!!*
		try {			
			JSONArray arr = kh.getAll();
			response.getWriter().write(arr.toString());
		} catch(Exception e) {
			e.printStackTrace();
		}
	}

---------------------------------------------------------

public class KisiHelper {
	
	public JSONArray getAll() {	
		JSONArray arr = null;
		
		try {
			System.out.println("KisiHelper calisti..");
			SessionFactory sessionFactory = new Configuration().configure().buildSessionFactory();
			Session session = sessionFactory.openSession();
			Transaction transaction = session.beginTransaction();
			String hql = "from Kisi";
		    Query query = session.createQuery(hql);
		    List<Kisi> list = query.list();
			List<Kisi> kisiList = list;
		    arr = JSONArray.fromObject(kisiList);
		    transaction.commit();
		    session.close();
		} catch(Exception e) {
			e.printStackTrace();
		}
		return arr;
	}
}

----------------------------------------------------------------

*Exception:*

java.lang.ClassNotFoundException: org.hibernate.Session
	at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1387)
	at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1233)
	at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
*	at servlets.tabloDoldur.doGet(tabloDoldur.java:34)*
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
	at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:849)
	at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
	at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:454)
	at java.lang.Thread.run(Thread.java:619)

Recommended Answers

All 10 Replies

The error is exactly what it says, the classloader was not able to locate your class. Where have you placed the Hibernate jar files?

I placed my jar files into my project under the WEB-INF folder..

Is it in the lib folder of WEB-INF? It'd be difficult to suggest anything without looking at the actual project structure. Have you tested this out with a standalone application? Are you using an IDE to develop and run this web app?

I'm using Eclipse Galileo on Ubuntu 9.10. I added all my external jars into my server's (which is Apache Tomcat 6.0) "lib" folder. Now this exception has gone but unfortunately now it gives another exception : "java.lang.ClassNotFoundException: org.apache.commons.lang.exception.NestableRuntimeException" I googled this exception and added commons-lang-2.5 jar, still the same..

You should never add any application specific jar to your server's lib folder; add them to the `lib` folder of your WEB-INF folder. And the ClassNotFoundException is a clear indication that specified class is not on your runtime classpath. Also, post the entire stack-trace for reference.

You should never add any application specific jar to your server's lib folder; add them to the `lib` folder of your WEB-INF folder. And the ClassNotFoundException is a clear indication that specified class is not on your runtime classpath. Also, post the entire stack-trace for reference.

OK, I did exactly what you said. Now all my external jar files are under my project's WEB-INF folder. But the exception is still active. I attached my build path in Eclipse.

The screenshot you have attached shows compile time dependencies...

OK, let's tackle this in a different way. Right click on your project -> Export -> Web -> War File and export your project as a WAR file. Browse this WAR file (just like any other archive) and see if you can see your jar files in the WEB-INF/lib directory. If you can't, then there is something wrong with the way you have configured your project.

The screenshot you have attached shows compile time dependencies...

OK, let's tackle this in a different way. Right click on your project -> Export -> Web -> War File and export your project as a WAR file. Browse this WAR file (just like any other archive) and see if you can see your jar files in the WEB-INF/lib directory. If you can't, then there is something wrong with the way you have configured your project.

OK, I did exactly what you said. And I saw my jar files and also the exception's jar file. (org.apache.commons.lang.exception.NestableRuntimeException) I attached their screen captures too..

The problem here is that instead of having the commons jar file in the WEB-INF/lib folder, you have a commons-lang folder. This doesn't work for the simple reason that it's the jar files in the WEB-INF/lib folder which are on the classpath and not the jar files which are present in any of the sub-directories of the WEB-INF/lib folder. Move just the commons-lang-2.5.jar file directly under the lib folder and it should work out to be fine.

commented: Thank you so much for your helps and patient. +1

thank you so much dear moderator ~s.o.s~ for your great helps and your patient to my mistakes. It works fine now.. Thanks a lot again..

With regards,
Talha

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.