Я пытаюсь запустить Tomcat, но все равно получаю сообщение об ошибке Server Tomcat v9.0 Server at localhost failed to start.
Я пытался добавить commons-logging-1.2.jar
, чтобы решить проблему, но это все еще не работает. Приветствуется любое понимание! Ниже приведен журнал ошибок (ОБНОВЛЕНО). Это указывает на ошибку сопоставления сервлета с моим countycreate jsp file.
INFO: Starting Servlet engine: [Apache Tomcat/9.0.37]
Jul 11, 2020 2:13:02 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[/Trial-servlet]]
at java.util.concurrent.FutureTask.report(Unknown Source)
at java.util.concurrent.FutureTask.get(Unknown Source)
at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:916)
at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:841)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1384)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1374)
at java.util.concurrent.FutureTask.run(Unknown Source)
at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75)
at java.util.concurrent.AbstractExecutorService.submit(Unknown Source)
at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:909)
at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:262)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
at org.apache.catalina.core.StandardService.startInternal(StandardService.java:421)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:930)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
at org.apache.catalina.startup.Catalina.start(Catalina.java:738)
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:342)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:473)
Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/Trial-servlet]]
at org.apache.catalina.util.LifecycleBase.handleSubClassException(LifecycleBase.java:440)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:198)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1384)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1374)
at java.util.concurrent.FutureTask.run(Unknown Source)
at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75)
at java.util.concurrent.AbstractExecutorService.submit(Unknown Source)
at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:909)
... 21 more
Caused by: java.lang.IllegalArgumentException: Invalid <url-pattern> [countycreate] in servlet mapping
at org.apache.catalina.core.StandardContext.addServletMappingDecoded(StandardContext.java:3176)
at org.apache.catalina.Context.addServletMappingDecoded(Context.java:881)
at org.apache.catalina.startup.ContextConfig.configureContext(ContextConfig.java:1603)
at org.apache.catalina.startup.ContextConfig.webConfig(ContextConfig.java:1377)
at org.apache.catalina.startup.ContextConfig.configureStart(ContextConfig.java:983)
at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:302)
at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:123)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5044)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
... 27 more
Jul 11, 2020 2:13:02 PM org.apache.catalina.core.ContainerBase startInternal
SEVERE: A child container failed during start
java.util.concurrent.ExecutionException: org.apache.catalina.LifecycleException: A child container failed during start
at java.util.concurrent.FutureTask.report(Unknown Source)
at java.util.concurrent.FutureTask.get(Unknown Source)
at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:916)
at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:262)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
at org.apache.catalina.core.StandardService.startInternal(StandardService.java:421)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:930)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
at org.apache.catalina.startup.Catalina.start(Catalina.java:738)
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:342)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:473)
Caused by: org.apache.catalina.LifecycleException: A child container failed during start
at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:928)
at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:841)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1384)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1374)
at java.util.concurrent.FutureTask.run(Unknown Source)
at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75)
at java.util.concurrent.AbstractExecutorService.submit(Unknown Source)
at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:909)
... 13 more
Caused by: java.util.concurrent.ExecutionException: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/Trial-servlet]]
at java.util.concurrent.FutureTask.report(Unknown Source)
at java.util.concurrent.FutureTask.get(Unknown Source)
at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:916)
... 21 more
Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/Trial-servlet]]
at org.apache.catalina.util.LifecycleBase.handleSubClassException(LifecycleBase.java:440)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:198)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1384)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1374)
at java.util.concurrent.FutureTask.run(Unknown Source)
at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75)
at java.util.concurrent.AbstractExecutorService.submit(Unknown Source)
at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:909)
... 21 more
Caused by: java.lang.IllegalArgumentException: Invalid <url-pattern> [countycreate] in servlet mapping
at org.apache.catalina.core.StandardContext.addServletMappingDecoded(StandardContext.java:3176)
at org.apache.catalina.Context.addServletMappingDecoded(Context.java:881)
at org.apache.catalina.startup.ContextConfig.configureContext(ContextConfig.java:1603)
at org.apache.catalina.startup.ContextConfig.webConfig(ContextConfig.java:1377)
at org.apache.catalina.startup.ContextConfig.configureStart(ContextConfig.java:983)
at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:302)
at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:123)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5044)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
... 27 more
Это мой веб. xml file:
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" version="3.1">
<display-name>County</display-name>
<welcome-file-list>
<welcome-file>CountyCreate.jsp</welcome-file>
</welcome-file-list>
<!--
<servlet>
<servlet-name>CountyCreate</servlet-name>
<servlet-class>servlet.CountyCreate</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>CountyCreate</servlet-name>
<url-pattern>/countycreate</url-pattern>
</servlet-mapping>
-->
</web-app>
И это один из моих сервлетов файл .. Этот файл находится в папке sr c> сервлета в моем каталоге:
package whetherweather.servlet;
import java.io.IOException;
import java.sql.SQLException;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import whetherweather.dal.DemographicDao;
import whetherweather.dal.CountyDao;
import whetherweather.model.County;
@WebServlet("/usercreate")
public class CountyCreate extends HttpServlet {
protected CountyDao countyDao;
@Override
public void init() throws ServletException {
countyDao = CountyDao.getInstance();
}
@Override
public void doGet(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {
// Map for storing messages.
Map<String, String> messages = new HashMap<String, String>();
req.setAttribute("messages", messages);
//Just render the JSP.
req.getRequestDispatcher("/CountyCreate.jsp").forward(req, resp);
}
@Override
public void doPost(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {
// Map for storing messages.
Map<String, String> messages = new HashMap<String, String>();
req.setAttribute("messages", messages);
// Retrieve and validate county id.
Integer countyId = Integer.parseInt(req.getParameter("idCounty"));
if (countyId == null) {
messages.put("success", "Invalid idCounty");
} else {
// Create county.
Integer getcountyId = Integer.parseInt(req.getParameter("idCounty"));
String getCountyName = req.getParameter("CountyName");
Integer getDemoId = Integer.parseInt(req.getParameter("Demographics_idDemographics"));
String getState = req.getParameter("State");
try {
// Exercise: parse the input for StatusLevel.
County county = new County(getcountyId, getCountyName, getDemoId, getState);
county = countyDao.create(county);
messages.put("success", "Successfully created " + countyId);
} catch (SQLException e) {
e.printStackTrace();
throw new IOException(e);
}
}
req.getRequestDispatcher("/CountyCreate.jsp").forward(req, resp);
}
}