0

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)

Edited by peter_budo: Editing text, please do not use bold writing on whole post

2
Contributors
10
Replies
14
Views
7 Years
Discussion Span
Last Post by talha06
Featured Replies
  • 3
    ~s.o.s~ 2,560   7 Years Ago

    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 … Read More

0

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

0

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

0

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?

0

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..

0

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.

0

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.

Attachments Screenshot-1.png 154.1 KB
0

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.

Edited by ~s.o.s~: n/a

0

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..

Attachments exceptions-class.png 68.36 KB jars.png 63.51 KB
3

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.

Edited by ~s.o.s~: n/a

Votes + Comments
Thank you so much for your helps and patient.
0

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

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.