I am trying to get a search web application running and needs to use another Java project to do all the backend operations. I exported the project into a jar file and added it to my dynamic webapp project. The first thing I tried was “Add External jars” from Properties > Java Build Path. This didn’t work so I also tried adding the jar in WEB-INF/lib which also did not work. How do I correctly add the jar file so I can use that project in my webapp?
More specifically this the error I get:
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
javax.servlet.ServletException: Servlet execution threw an exception
root cause
java.lang.NoClassDefFoundError: org/apache/accumulo/core/client/Instance
com.afspq.model.Results.getResults(Results.java:46)
com.afspq.web.ProcessQuery.doGet(ProcessQuery.java:31)
javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
root cause
java.lang.ClassNotFoundException: org.apache.accumulo.core.client.Instance
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1680)
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1526)
com.afspq.model.Results.getResults(Results.java:46)
com.afspq.web.ProcessQuery.doGet(ProcessQuery.java:31)
javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
note The full stack trace of the root cause is available in the Apache Tomcat/6.0.35 logs.
This was sort of a painful process but I had to manually add all the jar files from Accumulo, Hadoop and Zookeeper. I had to add the jar files to two locations. One was the build path (Right click Web project > Properties > Java Build Path > Add external jars), and the other was the WebContent/WEB-INF/lib folder in my Web project. This fixed it for me. For some reason Maven was not adding the dependencies although they were all specified in my pom.xml.