Every time im trying to access a normal java class from servlet (from other project) it gives me classNotFound exception, any idea how to fix this problem thanks in advance
Asked
Active
Viewed 6,989 times
2 Answers
5
You need to make sure that the class is available to the servlet container. How you do that will partly depend on exactly what servlet container you're using, but you could always put the jar file in WEB-INF/lib
or the class file in WEB-INF/classes
(under the right folder structure of course).
Hopefully your servlet container documentation will give more details - for example, the Tomcat 6.0 documentation includes this page which gives details about exactly where Tomcat looks for classes.

Jon Skeet
- 1,421,763
- 867
- 9,128
- 9,194
-
I add the jar file to WEB-INF/lib and everything works fine, thanks for helping – Mohd_Q Jun 14 '10 at 08:43
0
You should also make sure that your class includes a package statement. I don't believe that Tomcat looks kindly on classes in the default no-package.

duffymo
- 305,152
- 44
- 369
- 561
-
Everything works good by adding the jar file to the WEB-INF/lib anyway thanks for help – Mohd_Q Jun 14 '10 at 08:45