在码头部署静态内容

时间:2019-02-25 13:54:26

标签: java jetty jetty-9

我正在尝试在码头上静态部署应用程序,但是使用xml配置文件,因为我正在使用虚拟主机。

我创建此文件xml以进行部署:

<?xml version="1.0"  encoding="ISO-8859-1"?>
<!DOCTYPE Configure PUBLIC "-//Mort Bay Consulting//DTD Configure//EN" 
  "http://www.eclipse.org/jetty/configure.dtd">
<Configure class="org.eclipse.jetty.webapp.WebAppContext">
    <Set name="contextPath">/mail</Set>
    <!--<Call name="setInitParameter">
        <Arg>org.eclipse.jetty.servlet.Default.useFileMappedBuffer</Arg>
        <Arg>false</Arg>
    </Call> -->
    <Set name="handler">
    <New class="org.eclipse.jetty.server.handler.ResourceHandler">
      <Set name="resourceBase">/ccmail</Set>
      <Set name="directoriesListed">true</Set>
    </New>
  </Set>

    <Set name="virtualHosts">
    <Array type="java.lang.String">
      <Item>apps.cairunet.ad.br</Item>     
    </Array>
  </Set> 

</Configure>

我的文件夹应用程序的名称为ccmail。位于webapps/ccmail 我已经尝试传递到以下路径:

<Set name="resourceBase">/ccmail</Set>

<Set name="resourceBase">ccmail</Set>

<Set name="resourceBase">./ccmail</Set>

<Set name="resourceBase">webapps/ccmail</Set>

<Set name="resourceBase">/webapps/ccmail</Set>

任何人都不适合我。

Jetty启动此错误:

  

2019-02-25 09:36:46.422:WARN:oejs.ServletContextHandler:main:   不应直接调用ServletContextHandler.setHandler。采用   insertHandler或setSessionHandler等2019-02-25   09:36:46.484:WARN:oejw.WebInfConfiguration:main:无法生成   作为Webapp tmp目录名称一部分的resourceBase:   java.lang.IllegalStateException:没有为它设置resourceBase或war   context 2019-02-25 09:36:46.500:WARN:oejw.WebAppContext:main:失败   上下文启动o.e.j.w.WebAppContext@7d0587f1 {/ mail,nul

     

l,UNAVAILABLE,apps.cairunet.ad.br} java.lang.IllegalStateException:否   为上下文设置resourceBase或war           在org.eclipse.jetty.webapp.WebInfConfiguration.unpack(WebInfConfiguration.java:577)           在org.eclipse.jetty.webapp.WebInfConfiguration.preConfigure(WebInfConfiguration.java:152)           在org.eclipse.jetty.webapp.WebAppContext.preConfigure(WebAppContext.java:506)           在org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:544)           在org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)           在org.eclipse.jetty.deploy.bindings.StandardStarter.processBinding(StandardStarter.java:46)           在org.eclipse.jetty.deploy.AppLifeCycle.runBindings(AppLifeCycle.java:192)           在org.eclipse.jetty.deploy.DeploymentManager.requestAppGoal(DeploymentManager.java:505)           在org.eclipse.jetty.deploy.DeploymentManager.addApp(DeploymentManager.java:151)           在org.eclipse.jetty.deploy.providers.ScanningAppProvider.fileAdded(ScanningAppProvider.java:180)           在org.eclipse.jetty.deploy.providers.WebAppProvider.fileAdded(WebAppProvider.java:453)           在org.eclipse.jetty.deploy.providers.ScanningAppProvider $ 1.fileAdded(ScanningAppProvider.java:64)           在org.eclipse.jetty.util.Scanner.reportAddition(Scanner.java:610)           在org.eclipse.jetty.util.Scanner.reportDifferences(Scanner.java:529)           在org.eclipse.jetty.util.Scanner.scan(Scanner.java:392)           在org.eclipse.jetty.util.Scanner.doStart(Scanner.java:313)           在org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)           在org.eclipse.jetty.deploy.providers.ScanningAppProvider.doStart(ScanningAppProvider.java:150)           在org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)           在org.eclipse.jetty.deploy.DeploymentManager.startAppProvider(DeploymentManager.java:579)           在org.eclipse.jetty.deploy.DeploymentManager.doStart(DeploymentManager.java:240)           在org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)           在org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:138)           在org.eclipse.jetty.server.Server.start(Server.java:415)           在org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:117)           在org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:113)           在org.eclipse.jetty.server.Server.doStart(Server.java:382)           在org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)           在org.eclipse.jetty.xml.XmlConfiguration $ 1.run(XmlConfiguration.java:1572)           在org.eclipse.jetty.xml.XmlConfiguration $ 1.run(XmlConfiguration.java:1512)           在java.security.AccessController.doPrivileged(本机方法)           在org.eclipse.jetty.xml.XmlConfiguration.main(XmlConfiguration.java:1511)           在sun.reflect.NativeMethodAccessorImpl.invoke0(本机方法)处           在sun.reflect.NativeMethodAccessorImpl.invoke(未知来源)           在sun.reflect.DelegatingMethodAccessorImpl.invoke(未知来源)           在java.lang.reflect.Method.invoke(未知来源)           在org.eclipse.jetty.start.Main.invokeMain(Main.java:220)           在org.eclipse.jetty.start.Main.start(Main.java:490)           在org.eclipse.jetty.start.Main.main(Main.java:77)2019-02-25 09:36:46.578:INFO:oejs.AbstractConnector:main:已启动   ServerConnector @ 27808f31 {HTTP / 1.1,[http / 1.1]} {0.0.0.0:8080}   2019-02-25 09:36:46.594:INFO:oejs.Server:main:已启动@ 2970ms

1 个答案:

答案 0 :(得分:1)

  

注意:请注意您的DOCTYPE,声明的内容是从Jetty 7.x到Jetty 8.x,对于Jetty 9.x是不正确的

请勿混合ResourceHandler和WebAppContext / ServletContextHandler。

input[type="number"]

最基本的支持是不要在您的<?xml version="1.0" encoding="ISO-8859-1"?> <!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure_9_3.dtd"> <Configure class="org.eclipse.jetty.webapp.WebAppContext"> <Set name="contextPath">/mail</Set> <Set name="virtualHosts"> <Array type="java.lang.String"> <Item>apps.cairunet.ad.br</Item> </Array> </Set> </Configure> 中引用/ccmail

它以<Configure>的形式存在就足够了,它将为您部署${jetty.base}/webapps/ccmail/作为静态资源库。

但是,如果要将静态资源与虚拟主机结合在一起,则可以使用具有备用基础的WebAppContext或新的ResourceHandler。

备用碱基示例: Serving static files from alternate path in embedded Jetty

ResourceHandler用法示例: https://www.eclipse.org/jetty/documentation/current/static-content-deployment.html

/ccmail