在开发Java EE应用程序(学校练习)时,一切似乎都正常工作。但是由于我已经在我的eclipse项目上添加了一个新的servlet,我的tomcat拒绝启动,重启过程也用完了。即使延长时间限制以完成服务器操作也无济于事。
这个问题似乎是由我的网络引起的。xml文件,因为当我删除标记时,一切都像时钟一样运行。虽然我可以通过右键单击servlet来启动它,但这不是目的。我需要这个网站。xml,以便使用URL模式调用我的servlet和jsp。
日志只显示服务器准备启动,但没有显示错误。如果你不介意看一看,这是我给我带来麻烦的代码。我的web.xml填充了与此完全相同的代码,没有一个阻止tomcat正常启动。
<servlet>
<servlet-name>BookYourFlightServlet</servlet-name>
<servlet-class>com.sdzee.servlets.BookYourFlightServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>BookYourFlightServlet</servlet-name>
<url-pattern>/bookYourFlightServlet</url-pattern>
</servlet-mapping>
我也把我的项目转移到我的Ubuntu电脑上,以便在那里测试它,但同样的事情。
再次失败:以下是日志报告:
avr. 10, 2013 9:28:25 PM org.apache.catalina.core.AprLifecycleListener init
INFO: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: C:\Program Files\Java\jre7\bin;C:\Windows\Sun\Java\bin;C:\Windows\system32;C:\Windows;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;.
avr. 10, 2013 9:28:25 PM org.apache.tomcat.util.digester.SetPropertiesRule begin
WARNING: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.jee.server:pro' did not find a matching property.
avr. 10, 2013 9:28:25 PM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["http-bio-8080"]
avr. 10, 2013 9:28:25 PM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["ajp-bio-8009"]
avr. 10, 2013 9:28:25 PM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 1015 ms
avr. 10, 2013 9:28:25 PM org.apache.catalina.core.StandardService startInternal
INFO: Démarrage du service Catalina
avr. 10, 2013 9:28:25 PM org.apache.catalina.core.StandardEngine startInternal
INFO: Starting Servlet Engine: Apache Tomcat/7.0.39
avr. 10, 2013 9:28:26 PM org.apache.catalina.loader.WebappClassLoader validateJarFile
INFO: validateJarFile(C:\Users\moi\Desktop\mes workspaces\WorkSpace\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\pro\WEB-INF\lib\servlet-api.jar) - jar not loaded. See Servlet Spec 2.3, section 9.7.2. Offending class: javax/servlet/Servlet.class
avr. 10, 2013 9:28:26 PM org.apache.catalina.core.ContainerBase startInternal
SEVERE: A child container failed during start
java.util.concurrent.ExecutionException: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/pro]]
at java.util.concurrent.FutureTask$Sync.innerGet(Unknown Source)
at java.util.concurrent.FutureTask.get(Unknown Source)
at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:1123)
at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:800)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549)
at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)
at java.util.concurrent.FutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/pro]]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:154)
... 7 more
Caused by: java.lang.IllegalArgumentException: The servlets named [BookFlightServlet] and [com.sdzee.servlets.BookFlightServlet] are both mapped to the url-pattern [/bookFlightServlet] which is not permitted
at org.apache.catalina.deploy.WebXml.addServletMapping(WebXml.java:335)
at org.apache.catalina.startup.ContextConfig.processAnnotationWebServlet(ContextConfig.java:2457)
at org.apache.catalina.startup.ContextConfig.processAnnotationsStream(ContextConfig.java:2139)
at org.apache.catalina.startup.ContextConfig.processAnnotationsFile(ContextConfig.java:2100)
at org.apache.catalina.startup.ContextConfig.processAnnotationsFile(ContextConfig.java:2093)
at org.apache.catalina.startup.ContextConfig.processAnnotationsFile(ContextConfig.java:2093)
at org.apache.catalina.startup.ContextConfig.processAnnotationsFile(ContextConfig.java:2093)
at org.apache.catalina.startup.ContextConfig.webConfig(ContextConfig.java:1300)
at org.apache.catalina.startup.ContextConfig.configureStart(ContextConfig.java:878)
at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:369)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:90)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5269)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
... 7 more
avr. 10, 2013 9:28:26 PM org.apache.catalina.core.ContainerBase startInternal
SEVERE: A child container failed during start
java.util.concurrent.ExecutionException: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost]]
at java.util.concurrent.FutureTask$Sync.innerGet(Unknown Source)
at java.util.concurrent.FutureTask.get(Unknown Source)
at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:1123)
at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:302)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.StandardService.startInternal(StandardService.java:443)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:732)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.startup.Catalina.start(Catalina.java:684)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:322)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:456)
Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost]]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:154)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549)
at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)
at java.util.concurrent.FutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: org.apache.catalina.LifecycleException: A child container failed during start
at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:1131)
at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:800)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
... 7 more
avr. 10, 2013 9:28:26 PM org.apache.catalina.startup.Catalina start
SEVERE: Catalina.start:
org.apache.catalina.LifecycleException: Failed to start component [StandardServer[8005]]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:154)
at org.apache.catalina.startup.Catalina.start(Catalina.java:684)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:322)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:456)
Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardService[Catalina]]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:154)
at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:732)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
... 7 more
Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina]]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:154)
at org.apache.catalina.core.StandardService.startInternal(StandardService.java:443)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
... 9 more
Caused by: org.apache.catalina.LifecycleException: A child container failed during start
at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:1131)
at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:302)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
... 11 more
avr. 10, 2013 9:28:26 PM org.apache.catalina.startup.Catalina start
INFO: Server startup in 745 ms
我的Servlet:
package com.sdzee.servlets;
import java.io.IOException;
import com.sdzee.beans.ReservationBean;
import com.sdzee.dao.DAOFactory;
import com.sdzee.dao.UtilisateurDao;
import com.sdzee.forms.BookFlightForm;
@WebServlet("/bookFlightServlet")
public class BookFlightServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
private static final String VIEW = "/WEB-INF/JSP/bookYourFlight.jsp";
public static final String ATT_BOOKING = "booking";
public static final String ATT_FORM = "form";
public static final String CONF_DAO_FACTORY = "daofactory";
private UtilisateurDao utilisateurDao;
// ========================================================================
public void init() throws ServletException {
/* Récupération d'une instance de notre DAO Utilisateur */
this.utilisateurDao = ((DAOFactory) getServletContext().getAttribute(
CONF_DAO_FACTORY)).getUtilisateurDao();
}
protected void doGet(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {
/* Affichage de la page d'inscription */
this.getServletContext().getRequestDispatcher(VIEW)
.forward(request, response);
}
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
BookFlightForm form = new BookFlightForm(utilisateurDao);
/* Traitement de la requête et récupération du bean en résultant */
ReservationBean reservationBean = form.registerFlightMethod(request);
request.setAttribute(ATT_FORM, form);
request.setAttribute(ATT_BOOKING, reservationBean);
this.getServletContext().getRequestDispatcher(VIEW)
.forward(request, response);
System.out.println("Dopost method");
}
}
我的Jsp文件
<%@ page pageEncoding="UTF-8" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Book Flight</title>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<link type="text/css" rel="stylesheet" href="styles/form.css" />
</head>
<body>
<form method="post" action="bookFlightServlet">
<fieldset>
<legend>Reservation</legend>
<p>You can book your flight with this form.</p>
<label for="country">Country <span class="requis">*</span></label>
<input type="text" id="country" name="country" value="<c:out value="${reservationBean.country}"/>" size="20" maxlength="60" />
<span class="erreur">${form.erreurs['country']}</span>
<br />
<label for="departureDay">Departure Date <span class="requis">*</span></label>
<input type="text" id="departureDay" name="departureDay" value="<c:out value="${reservationBean.departureDay}"/>" size="20" maxlength="60" />
<span class="erreur">${form.erreurs['departureDay']}</span>
<br />
<input type="submit" value="BOOK" class="sansLabel" />
<br />
<p class="${empty form.erreurs ? 'succes' : 'erreur'}">${form.resultat}</p>
</fieldset>
</form>
</body>
</html>
Web.xml文件
<servlet>
<servlet-name>BookFlightServlet</servlet-name>
<servlet-class>com.sdzee.servlets.BookFlightServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>BookFlightServlet</servlet-name>
<url-pattern>/bookFlightServlet</url-pattern>
</servlet-mapping>
我认为您正在声明Servlet com.sdzee.servlets。BookFlightServlet两次。通过将相同的servlet(具有不同的名称:一个带有包,另一个没有包)映射到相同的url apptern,容器将无法启动,因为这是不允许的!!
由于此异常,启动失败。
名为[BookFlightServlet]和[com . sdzee . Servlet . BookFlightServlet]的servlet都映射到了不允许的url模式[/bookFlightServlet]
您不能用2个servlets处理HTTP请求。为servlet-name标记使用唯一的名称,并将URL模式映射到单独的servlet类。您不能这样做的原因是,没有办法同时跨两个servlet线程有意义地提交HTTP响应。
有一个相关的线程,所以有人犯了类似的错误。你也可以从中学习。
本文向大家介绍Eclipse添加新server时无法选择Tomcat7的解决方法,包括了Eclipse添加新server时无法选择Tomcat7的解决方法的使用技巧和注意事项,需要的朋友参考一下 在Eclipse中创建了一个Web工程后,需要将该工程部署到Tomcat中进行发布。有时就会遇到在New Server对话框中选择了Tomcat 6/7后却无法单击“Next”按钮的问题,如下图所示: 这
在将OmniFaces库添加到Apache Tomcat7并将CDI(遵循此链接)添加到Apache Tomcat7之后,我遇到了一个错误,并且我使用的是Maven。 严重:启动java.util.concurrent.ExecutionException时子容器失败:org.apache.Catalina.LifeCycleException:无法启动组件[StandardEngine[Cata
问题内容: 当请求到达处理文件上传的servlet时,在该servlet中启动一个新线程是一个好主意,该线程将处理与上传的文件一起提供的另一段数据。我想以此同时处理这两项工作。 问题答案: 这不仅是一个坏主意,而且也行不通。原因如下:您的文件上传请求最终将命中方法。只要您使用此方法,容器就会保持连接打开。从该方法返回后(如果您决定在一个单独的线程中处理传入数据,则将提早完成),容器将假定您已完成请
我找遍了整个网络和堆栈交换,找不到任何关于这个问题的其他参考。
我安装了Java 7: ➜ ~ java-版本java版本“1.7.0_76”java(TM)SE运行时环境(构建1.7.0_76-b13)java热点(TM)64位服务器虚拟机(构建24.76-b04,混合模式)➜ ~ 我下载了Eclipse4.3,启动时收到错误信息,表示需要: 要打开“Eclipse”,您需要安装遗留的JavaSE6运行时”。 除了安装JavaSE7运行时,我还需要安装Jav
我使用Mac 10.9 OSX Mavericks和Eclipse IDEJavaEE开发人员(开普勒)。 我使用eclipse中的“新服务器”选项和最新的JDK-JavaSE 7[1.7.0_55]安装了Glassfish 4.0。 但是当尝试启动服务器时,我收到此错误 - “在本地主机上启动GlassFish 4.0”期间发生内部错误。java.lang.NullPointerExceptio