I'm working on simple project, what I'm doing is building Jar file then use a class from this jar in my project, the project running tomcat and to run servlet on it. I'm using Postman to post requests then running the servlet, in the servlet i'm trying to define a new variable then I got java.lang.ClassNotFoundException.
package coms;
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.ibm.jms.JMSMessageProducer;
public class TestA extends HttpServlet {
private static final long serialVersionUID = 1L;
private String message;
public void init() throws ServletException {
// Do required initialization
message = "Hello World";
}
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
JMSMessageProducer msgProdObj = new JMSMessageProducer();
msgProdObj.send(request, response);
}
public void destroy() {
// do nothing.
}
}
JMSMessageProducer is the class that defined in the Jar
As you can see in the classPath, the class found in the added jar, and it's imported in the code : ] 1
After searching in web I understand that the Jar should found also in WEB-INF/lib, so I added it as you can see in picture below:
But also this not helped.
I also saw that the code compiled without errors, it's looks like run time error.
Do any body know the problem here ?
Appreciate your efforts.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.