【问题标题】:Jetty: HTTP ERROR: 503/ Service Unavailable码头:HTTP 错误:503/服务不可用
【发布时间】:2012-04-20 18:26:04
【问题描述】:

我是 Jetty 新手,我尝试在此处运行示例程序“http://www.codeproject.com/Articles/128145/Run-Jetty-Web-Server-Within-Your-Application” 但我在页面“http://localhost:8585/runJetty/”上收到错误消息

"HTTP ERROR: 503
Problem accessing /runJetty/. Reason: 
    Service Unavailable
--------------------------------------------------------------------------------
Powered by Jetty:// "

我从 eclipse 得到的错误日志:

2012-04-20 11:14:32.522:INFO:oejs.Server:jetty-8.1.3.v20120416
2012-04-20 11:14:32.617:WARN:oejx.XmlParser:FATAL@file:/C:/Users/***/workspace/Test/WEB-INF/web.xml line:1 col:7 : org.xml.sax.SAXParseException: The processing instruction target matching "[xX][mM][lL]" is not allowed.
2012-04-20 11:14:32.617:WARN:oejw.WebAppContext:Failed startup of context o.e.j.w.WebAppContext{/runJetty,file:/C:/Users/***/workspace/Test/}
org.xml.sax.SAXParseException: The processing instruction target matching "[xX][mM][lL]" is not allowed.
at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source)
at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.fatalError(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLScanner.reportFatalError(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLScanner.scanPIData(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanPIData(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLScanner.scanPI(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$PrologDriver.next(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)
at javax.xml.parsers.SAXParser.parse(Unknown Source)
at org.eclipse.jetty.xml.XmlParser.parse(XmlParser.java:199)
at org.eclipse.jetty.xml.XmlParser.parse(XmlParser.java:215)
at org.eclipse.jetty.webapp.Descriptor.parse(Descriptor.java:60)
at org.eclipse.jetty.webapp.WebDescriptor.parse(WebDescriptor.java:143)
at org.eclipse.jetty.webapp.MetaData.setWebXml(MetaData.java:165)
at org.eclipse.jetty.webapp.WebXmlConfiguration.preConfigure(WebXmlConfiguration.java:55)
at org.eclipse.jetty.webapp.WebAppContext.preConfigure(WebAppContext.java:417)
at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:453)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:59)
at org.eclipse.jetty.server.handler.HandlerCollection.doStart(HandlerCollection.java:224)
at org.eclipse.jetty.server.handler.ContextHandlerCollection.doStart(ContextHandlerCollection.java:167)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:59)
at org.eclipse.jetty.server.handler.HandlerWrapper.doStart(HandlerWrapper.java:90)
at org.eclipse.jetty.server.Server.doStart(Server.java:262)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:59)
at blog.runjetty.server.JettyServer.start(JettyServer.java:22)
at blog.runjetty.ui.listener.ServerStartStopActionListner.actionPerformed(ServerStartStopActionListner.java:38)
at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
at java.awt.Component.processMouseEvent(Unknown Source)
at javax.swing.JComponent.processMouseEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Window.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$000(Unknown Source)
at java.awt.EventQueue$1.run(Unknown Source)
at java.awt.EventQueue$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.AccessControlContext$1.doIntersectionPrivilege(Unknown Source)
at java.security.AccessControlContext$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue$2.run(Unknown Source)
at java.awt.EventQueue$2.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.AccessControlContext$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
2012-04-20 11:14:32.648:INFO:oejs.AbstractConnector:Started SelectChannelConnector@0.0.0.0:8585

我的 xml 文件

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee 
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" 
version="2.4">
    <welcome-file-list>
        <welcome-file>page/index.jsp</welcome-file> 
    </welcome-file-list>
</web-app> 

我的 JSP 文件

<%@ page language="java" contentType="text/html; charset=ISO-8859-1 pageEncoding="ISO-8859-1"%> 
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01     Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html> 
    <head> 
        <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
        <title>Embedding Jetty</title>
    </head>
    <body>
        <h2>Running Jetty web server from our application!!</h2>
    </body>
</html>  

【问题讨论】:

  • 回滚到原来的问题。如果您还有其他问题,请不要用它替换这个问题。只是问一个新问题。另外,如果答案帮助您解决了问题,请点击复选标记接受。

标签: java xml jetty


【解决方案1】:

2012-04-20 11:14:32.617:WARN:oejx.XmlParser:FATAL@file:/C:/Users/***/workspace/Test/WEB-INF/web.xml line:1 col: 7 : org.xml.sax.SAXParseException: 处理指令目标匹配“[xX][mM][lL]”是不允许的。

您的日志说,您的 web.xml 格式不正确。第 1 行,第 7 列。可能是 UTF-8 Byte-Order-Marker

尝试验证您的 xml 格式是否正确且没有 BOM。 Java 不使用 BOM。

【讨论】:

  • 没有 web.xml 没有人能帮上忙。
【解决方案2】:

实际上,我解决了这个问题。我通过 eclipse jetty 插件运行它。

  1. 我的 Eclipse 中没有 JDK 库,这就是为什么消息一直显示我需要安装完整的 JDK,这是主要原因。

  2. 我安装了两个版本的 jetty 插件,分别是 jetty7 和 jetty8。我认为它们相互冲突或其他什么,所以我删除了 jetty7,它可以工作!

【讨论】:

  • 我遇到了一些类似的问题,出于某种(现在未知)原因,我在我的 pom 中添加了 tomcat jasper-compiler 以进行测试设置,并且想知道为什么它没有以与通常相同的设置开始.把它拿出来,然后像魅力一样工作。
【解决方案3】:

这些答案都不适合我。

我不得不删除所有已部署的 java web 应用程序:

  • Windows/显示视图/其他...
  • 转到服务器文件夹并选择“服务器”
  • 在 localhost 上右键单击 J2EE Preview
  • 单击以添加和删除...单击全部删除

然后在服务器上运行项目

错误消失了!

在部署另一个项目之前,您必须停止服务器,因为服务器不会找到它。否则会报404错误

【讨论】:

    【解决方案4】:

    我遇到了同样的问题。我通过从 xml 文件中删除换行符来解决它。我做了

    <operationBindings>
        <OperationBinding>
            <operationType>update</operationType>
            <operationId>makePdf</operationId>
            <serverObject>
                <className>com.myclass</className>
                <lookupStyle>new</lookupStyle>
            </serverObject>
            <serverMethod>makePdf</serverMethod>
        </OperationBinding>
    </operationBindings>
    

    而不是...

    <serverObject>
                <className>com.myclass
    </className>
                <lookupStyle>new</lookupStyle>
    </serverObject>
    

    【讨论】:

      【解决方案5】:

      从工作区移除/删除项目。并将项目重新导入工作区。 这种方法对我有用。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2012-08-17
        • 2021-06-16
        • 1970-01-01
        • 2017-03-26
        • 2014-05-02
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多