2017-10-09 34 views
0

我的工作简单的项目,我在做什么,是构建Jar文件,然后使用一个类从这个罐子在我的项目,该项目运行Tomcat和在其上运行servlet。我使用Postman发布请求,然后运行servlet,在servlet中,我试图定义一个新变量,然后得到java.lang.ClassNotFoundException。抛出java.lang.ClassNotFoundException:com.ibm.jms.xxxxxxxxxx

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的是,在罐中定义

正如你可以在classpath中所见,类在加入罐中发现的类,它的代码输入: ![enter image description here] 1

在网络搜索后,我明白Jar也应该在WEB-INF/lib中找到,所以我添加了它,如下图所示:

enter image description here

但是这也没有帮助。

我也看到,该代码没有错误编译,它看起来像运行时错误。

做任何身体知道这里的问题?

欣赏你的努力。

enter image description here

+0

你能请把堆栈跟踪以获取更多信息 – Yogi

+0

我加堆栈跟踪 – bashar

回答

0

深入研究后,我发现我失踪添加在Tomcat中lanch配置的罐子。

这样做,我打开Tomcat配置窗口enter image description here

点击“打开启动配置”

在Classpath选项卡中单击“添加JAR文件...”之后添加缺少的JAR enter image description here

即重新启动Tomcat,它的工作现在

相关问题