【问题标题】:Jetty Configuration: problems with dtd码头配置:dtd 的问题
【发布时间】:2015-06-20 08:41:59
【问题描述】:

我正在使用嵌入到 gradle 项目中的码头,并带有 jetty.xml 用于服务器配置。码头有一个 XML 配置来使用 jettyRunWar(gradle 插件)。

这是 build.gradle 中的 jettyRunWar:

jettyRunWar{
    contextPath = "/"
    httpPort = 8080
    jettyConfig = file("./jetty.xml")
    reload = "automatic"
    scanIntervalSeconds = 10
    webApp = file("./build/libs/relevanteme.war")
}

这是 jetty.xml(配置)。

<?xml version="1.0"  encoding="ISO-8859-1"?>
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure_9_0.dtd">

<Configure id="Server" class="org.eclipse.jetty.server.Server">

    <Set name="port"><SystemProperty name="jetty.port" default="8080"/></Set>

    <New id="webApp" class="org.eclipse.jetty.webapp.WebAppContext">
            <Set name="contextPath">/</Set>
            <Set name="war"><SystemProperty name="jetty.home" default="."/>./build/libs/relevanteme.war</Set>

            <Call name="addServlet">
            <Arg>vjsantojaca.relevante.background.servlets.IdentifyServlet</Arg>
            </Call>
    </New>

    <New id="Relevante" class="org.eclipse.jetty.plus.jndi.Resource">
        <Arg>jdbc/Relevante</Arg>
        <Arg>
            <New class="com.mysql.jdbc.jdbc2.optional.MysqlConnectionPoolDataSource">
               <Set name="Url">jdbc:mysql://localhost:3306/mail_classmachine</Set>
               <Set name="User">classmach</Set>
               <Set name="Password">lTk54ifRd</Set>
            </New>
         </Arg>
    </New>

    <Set name="handler">
        <New class="org.eclipse.jetty.server.handler.HandlerCollection">
            <Set name="handlers">
                <Array type="org.eclipse.jetty.server.Handler">
                    <Item>
                        <Ref refid="webApp" />
                    </Item>
                    <Item>
                        <New class="org.eclipse.jetty.server.handler.DefaultHandler" />
                    </Item>
                </Array>
            </Set>
        </New>
    </Set>

</Configure>

当我在 gradle 中运行命令 jettyRunWar 并 gradle 下载码头 xml 配置的 dtd 时,它给了我以下信息...

[org.mortbay.log] parsing: sid=file:/home/vjsantojaca/Developer/Relevante/relevanteme-web-2.0/jetty.xml,pid=null
[org.mortbay.log] resolveEntity(-//Jetty//Configure//EN, http://www.eclipse.org/jetty/configure_9_0.dtd)
[org.mortbay.log] Can't exact match entity in redirect map, trying configure_9_0.dtd
[sun.net.www.protocol.http.HttpURLConnection] sun.net.www.MessageHeader@5df6163a5 pairs: {GET /jetty/configure_9_0.dtd HTTP/1.1: null}{User-Agent: Java/1.8.0_31}{Host: www.eclipse.org}{Accept: text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2}{Connection: keep-alive}
[sun.net.www.protocol.http.HttpURLConnection] sun.net.www.MessageHeader@2d313c8c14 pairs: {null: HTTP/1.1 200 OK}{Date: Tue, 14 Apr 2015 15:49:05 GMT}{Server: Apache}{Last-Modified: Tue, 11 Mar 2014 16:28:22 GMT}{ETag: "4e2795-239e-4f45735653580"}{Accept-Ranges: bytes}{Content-Length: 9118}{Vary: Accept-Encoding}{Access-Control-Allow-Origin: http://eclipse.org ; https://eclipse.org ; http://www.eclipse.org ; https://www.eclipse.org}{Access-Control-Allow-Methods: GET}{X-NodeID: (null)}{Keep-Alive: timeout=3, max=200}{Connection: Keep-Alive}{Content-Type: text/x-dtd}

为什么会这样?

谢谢!!

【问题讨论】:

    标签: xml gradle jetty embedded-jetty


    【解决方案1】:

    org.mortbay.log 的引用表示您使用的是Jetty-7 之前的古老版本(可能是Jetty 6)。

    这就是你沮丧的原因。

    您的 jettyRunWar 没有使用 Jetty 9,它使用的是 Jetty 6(?)

    【讨论】:

    • 虽然我使用的 jetty 版本是 9 版,但 Gradle 的官方 jetty 插件是针对 7 之前的版本,如你所说。如果我使用另一个插件,它会工作。非常感谢。
    • 您能帮我处理一下this issue 吗?非常感谢!!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-06-27
    • 1970-01-01
    相关资源
    最近更新 更多