我开发了一个正确部署在Apache Tomcat上的 Java 动态 Web 项目。现在我正在尝试在WebSphere Application Server 8.5上部署.war文件。企业应用程序已正确创建,但是当我尝试使用浏览器访问我的应用程序时,出现以下错误:
Error 404: javax.servlet.UnavailableException: SRVE0200E: Servlet [it.foo.simpleapp.SimpleApp]: Could not find required class - class java.lang.ClassNotFoundException: it.foo.simpleapp.SimpleApp
该应用程序非常简单:当GET到达时,它应该以text/html内容进行响应。
我很确定.war文件是正确的,但我是 WebSphere 部署的新手。
servlet 类是:
@WebServlet("/")
public class SimpleApp extends HttpServlet {
private static final long serialVersionUID = 1L;
public SimpleApp() {
super();
}
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.getWriter().print("<html><body><h1>SimpleApp servlet ready!</h1>");
response.getWriter().print("</body></html>");
response.setContentType("text/html");
}
}
web.xml文件是:
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0">
<display-name>SimpleApp</display-name>
</web-app>
提前致谢!