Reputation: 515
I am writing a simple servlet and trying to create an instance of one of my classes, DataStore
, in the code.
This class is public and sits in a file called DataStore.java
in the same package as the Servlet code.
When I try to create a new instance in the code:
DataStore dStore = new DataStore();
I get the following exception:
java.lang.ClassNotFoundException: backend.DataStore
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1680)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1526)
at backend.AjaxServlet.createGame(AjaxServlet.java:196)
I tried creating an instance of this class in a differnet file and it worked great. Any idea what could be the cause of this?
Upvotes: 0
Views: 15012
Reputation: 115328
If JVM throws ClassNotFoundException the class is not found in classpath. It means that something is not configured correctly.
So, check the class (i mean file backend.DataStore.class
). It's path should be: your web application folder/WEB-INF/classes/backend/DataStore.class
. If this class is packaged into separate jar file this jar must be under YOUR_WEB_APP/WEB-INF/lib/yourjar.jar
Upvotes: 8