I have a tomcat project: tomcat/webapps/Project
. That project makes use of org.json
library, the dependency is written in pom.xml
file:
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20180813</version>
</dependency>
I have installed maven
on my server and run this command, while in the Project
directory:
mvn install
Then I checked /root/.m2/repository/org/json/20180813
folder and the file json-20180813.jar
is there!
However when I restart my server: shutdown.sh
and try to make use of my app, the error is still there:
javax.servlet.ServletException: java.lang.NoClassDefFoundError: org/json/JSONObject
Why does this happen and how to fix it?
EDIT: People pointed out the copying of the jar to tomcat/lib
directory. I did it and it worked. However, I would also be interested in a more permanent solution, so that I wouldn't be forced to do this again with other jars in the future.