[英]How to run an Eclipse Dynamic Web Application with Apache Tomcat Server?
I tried running Apache Tomcat Server on Eclipse and got into the following problems: 我尝试在Eclipse上运行Apache Tomcat Server并遇到以下问题:
SEVERE: Servlet.service() for servlet [jsp] in context with path [] threw exception [java.lang.AbstractMethodError: javax.servlet.jsp.JspFactory.getJspApplicationContext(Ljavax/servlet/ServletContext;)Ljavax/servlet/jsp/JspApplicationContext;] with root cause java.lang.AbstractMethodError: javax.servlet.jsp.JspFactory.getJspApplicationContext(Ljavax/servlet/ServletContext;)Ljavax/servlet/jsp/JspApplicationContext;
I managed to solve the above 3 problems by doing the following steps: 我设法通过执行以下步骤解决了上述3个问题:
1- Double click your server (tomcat in this case) [if you can't see it go to Windows -> Show/View -> Other -> Server -> Servers
]. 1-双击您的服务器(在本例中为tomcat)[如果您看不到它转到Windows -> Show/View -> Other -> Server -> Servers
]。 Your server name will look something like: "Tomcat v7.0 Server at localhost". 您的服务器名称类似于:“localhost上的Tomcat v7.0服务器”。
Double click the server and make sure the Server Locations is set to : "Use Tomcat installation (takes control of Tomcat installation)". 双击服务器并确保将服务器位置设置为:“使用Tomcat安装(控制Tomcat安装)”。 If you can't edit the servers location: Stop the server, right-click the server and select Publish
. 如果无法编辑服务器位置:停止服务器, right-click the server and select Publish
。 If still you cant edit it: 如果你仍然无法编辑它:
Right click the server --> Add and Remove and remove your project then publish it again. 右键单击服务器 - >添加和删除并删除项目,然后再次发布。
The reason for selecting "Use Tomcat installation" is that Catalina_Base will point to a temporary location and will look something like: 选择“使用Tomcat安装”的原因是Catalina_Base将指向一个临时位置,看起来像:
"-Dcatalina.base="C:\workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp1"
This will cause a 404 Error even when trying to open Apache Tomcat Start Page. 即使在尝试打开Apache Tomcat Start Page时,这也会导致404错误。 When selecting "Use Tomcat Installation" the Catalina_Home and Catalina_Base values will be the same and both will point to the Tomcat Installation Directory: Example: 选择“使用Tomcat安装”时,Catalina_Home和Catalina_Base值将相同,并且两者都将指向Tomcat安装目录:示例:
-Dcatalina.base="C:\apache-tomcat-7.0.37" -Dcatalina.home="C:\apache-tomcat-7.0.37"
To see the Arguments: 要查看参数:
Double Click the Server then click on "Open launch configuration", the values will appear in the "Arguments" tab. 双击服务器,然后单击“打开启动配置”,这些值将显示在“参数”选项卡中。
2- When using dependencies (ex External Jar files), make sure the files are in : Web-Inf/lib and then add them to the class-path by doing the following: 2-使用依赖项(ex External Jar文件)时,请确保文件位于:Web-Inf / lib,然后通过执行以下操作将它们添加到类路径:
Right-click the project --> Build-path --> Configure Build Path Select the "Libraries" tab Click Add External JARs and select the jar files in Web-Inf/lib 右键单击项目 - >构建路径 - >配置构建路径选择“库”选项卡单击“添加外部JAR”,然后在Web-Inf / lib中选择jar文件
Next you need to deploy dependencies: To do this: 接下来,您需要部署依赖项:要执行此操作:
Right-Click the project -> Properties From the left side select "Deployment Assembly" On the right hand side click Add -> Java Build Path Entries -> Next Add all the jar files your project needs. 右键单击项目 - >属性从左侧选择“部署程序集”在右侧单击添加 - > Java构建路径条目 - >下一步添加项目所需的所有jar文件。
Otherwise, you'll get a class not found exception for the used jar files. 否则,您将获得使用过的jar文件的类找不到异常。
3- Make sure Web-Inf/lib does not contain any jar files from Apache Tomcat, as this will cause redundancies and will give the exception above! 3-确保Web-Inf / lib不包含来自Apache Tomcat的任何jar文件,因为这会导致冗余并且会给出上述异常!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.