在 Eclipse IDE 中,我尝试在 Jetty Server 9 中以离线模式运行基本的 Web 应用程序。
注意: 我在 Eclipse IDE 中从市场安装了 Jetty Server。
我已经提到了 eclipse IDE 版本和 Jetty 服务器版本及其配置
Eclipse IDE 版本:2024-06 (4.32.0) 和构建 ID:20240606-1231
错误日志
____ ___ __ __ __ ___
/ __/___/ (_)__ ___ ___ __ / /__ / /_/ /___ __ / _ \
/ _// __/ / / _ \(_-</ -_) / // / -_) __/ __/ // / \_, /
/___/\__/_/_/ .__/___/\__/ \___/\__/\__/\__/\_, / /___/
/_/ /___/
2024-08-31 06:16:58.209:INFO::main: Logging initialized @375ms to org.eclipse.jetty.util.log.StdErrLog
Configuration: > C:\Users\GOVIND~1\AppData\Local\Temp\eclipseJettyPlugin.config.WebTest.xml
Version: 9.4.49.v20220914
Context: /WebTest
Port: 8080
Classpath: C:/Users/GOVIND KNT/eclipse_jetty/WebTest/build/classes
2024-08-31 06:16:58.708:INFO:oejs.Server:main: jetty-9.4.49.v20220914; built: 2022-09-14T01:07:36.601Z; git: 4231a3b2e4cb8548a412a789936d640a97b1aa0a; jvm 22.0.2+9
2024-08-31 06:16:59.115:WARN:oejw.WebAppContext:main: Failed startup of context o.e.j.w.WebAppContext@13b6aecc{/WebTest,file:///C:/Users/GOVIND%20KNT/eclipse_jetty/WebTest/src/main/webapp/,STOPPED}{C:\Users\GOVIND KNT\eclipse_jetty\WebTest\src\main\webapp}
java.net.UnknownHostException: www.eclipse.org
at java.base/sun.nio.ch.NioSocketImpl.connect(NioSocketImpl.java:567)
at java.base/java.net.SocksSocketImpl.connect(SocksSocketImpl.java:327)
at java.base/java.net.Socket.connect(Socket.java:752)
at java.base/sun.security.ssl.SSLSocketImpl.connect(SSLSocketImpl.java:304)
at java.base/sun.security.ssl.BaseSSLSocketImpl.connect(BaseSSLSocketImpl.java:181)
at java.base/sun.net.NetworkClient.doConnect(NetworkClient.java:183)
at java.base/sun.net.www.http.HttpClient.openServer(HttpClient.java:531)
at java.base/sun.net.www.http.HttpClient.openServer(HttpClient.java:636)
at java.base/sun.net.www.protocol.https.HttpsClient.<init>(HttpsClient.java:264)
at java.base/sun.net.www.protocol.https.HttpsClient.New(HttpsClient.java:377)
at java.base/sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.getNewHttpClient(AbstractDelegateHttpsURLConnection.java:193)
at java.base/sun.net.www.protocol.http.HttpURLConnection.plainConnect0(HttpURLConnection.java:1243)
at java.base/sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:1129)
at java.base/sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(AbstractDelegateHttpsURLConnection.java:179)
at java.base/sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1691)
at java.base/sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1615)
at java.base/sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java:223)
at java.xml/com.sun.org.apache.xerces.internal.impl.XMLEntityManager.setupCurrentEntity(XMLEntityManager.java:691)
at java.xml/com.sun.org.apache.xerces.internal.impl.XMLEntityManager.startEntity(XMLEntityManager.java:1443)
at java.xml/com.sun.org.apache.xerces.internal.impl.XMLEntityManager.startDTDEntity(XMLEntityManager.java:1409)
at java.xml/com.sun.org.apache.xerces.internal.impl.XMLDTDScannerImpl.setInputSource(XMLDTDScannerImpl.java:257)
at java.xml/com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$DTDDriver.dispatch(XMLDocumentScannerImpl.java:1182)
at java.xml/com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$DTDDriver.next(XMLDocumentScannerImpl.java:1070)
at java.xml/com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$PrologDriver.next(XMLDocumentScannerImpl.java:973)
at java.xml/com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:635)
at java.xml/com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(XMLNSDocumentScannerImpl.java:113)
at java.xml/com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:551)
at java.xml/com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:890)
at java.xml/com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:826)
at java.xml/com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:134)
at java.xml/com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1225)
at java.xml/com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:643)
at java.xml/com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl.parse(SAXParserImpl.java:326)
at org.eclipse.jetty.xml.XmlParser.parse(XmlParser.java:244)
at org.eclipse.jetty.webapp.Descriptor.parse(Descriptor.java:53)
at org.eclipse.jetty.webapp.WebDescriptor.parse(WebDescriptor.java:213)
at org.eclipse.jetty.webapp.MetaData.setDefaults(MetaData.java:167)
at org.eclipse.jetty.webapp.WebXmlConfiguration.preConfigure(WebXmlConfiguration.java:48)
at org.eclipse.jetty.webapp.WebAppContext.preConfigure(WebAppContext.java:488)
at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:523)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:73)
at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:169)
at org.eclipse.jetty.server.Server.start(Server.java:423)
at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:110)
at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:97)
at org.eclipse.jetty.server.Server.doStart(Server.java:387)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:73)
at net.sourceforge.eclipsejetty.starter.jetty9.Jetty9Adapter.start(Jetty9Adapter.java:68)
at net.sourceforge.eclipsejetty.starter.common.AbstractJettyLauncherMain.launch(AbstractJettyLauncherMain.java:84)
at net.sourceforge.eclipsejetty.starter.jetty9.Jetty9LauncherMain.main(Jetty9LauncherMain.java:42)
2024-08-31 06:16:59.164:INFO:oejs.AbstractConnector:main: Started ServerConnector@1d9b7cce{HTTP/1.1, (http/1.1)}{0.0.0.0:8080}
2024-08-31 06:16:59.164:INFO:oejs.Server:main: Started @1360ms
-----------------------------------------------
Jetty startup finished in 1.2 s.
Used memory: 6.0 MB of 20.0 MB (3.9 GB maximum)
Console available: type "help".
-----------------------------------------------
我的网络应用程序有一个非常基本的 index.html:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
</body>
</html>
web.xml:
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="https://jakarta.ee/xml/ns/jakartaee" xsi:schemaLocation="https://jakarta.ee/xml/ns/jakartaee https://jakarta.ee/xml/ns/jakartaee/web-app_5_0.xsd" id="WebApp_ID" version="5.0">
<display-name>WebTest</display-name>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.jsp</welcome-file>
<welcome-file>default.htm</welcome-file>
</welcome-file-list>
</web-app>
您似乎想要使用 Java 22,因为您需要使用 Jetty 12 或更高版本,因为 JVM 的许多更改正在破坏您对 Jetty 的使用。 (在您的情况下,这是 XML dtd 验证更改)。
注意:您可以在 Jetty 12 上的
javax.servlet
环境中使用 ee8
。