Jetty - 在不同的端口上分离webapp

时间:2014-08-05 12:11:32

标签: java tomcat servlets jetty jetty-9

我使用 Jetty Server 在一个单独的端口' 1288'中运行一个简单的servlet Web应用程序。如果我将其置于默认的“webapps”中,我就可以运行webapp'文件夹并在默认情况下运行' 8080'地点。但是,如果我尝试在不同的端口' 1288' 中对新配置文件' myAppServer.xml' ,我的webapp放在' app-webapps' 文件夹中。

我也很生气,因为我得到一个与tomcat相关的异常 org.apache.tomcat.InstanceManager在ServletContext中设置(Full StackTrace粘贴在下面)

请告诉我哪里出错了。

文件:myAppServer.xml

<Configure id="AppServer" class="org.eclipse.jetty.server.Server">
<Set name="handler">
    <New id="Handlers" class="org.eclipse.jetty.server.handler.HandlerCollection">
        <Set name="handlers">
            <Array type="org.eclipse.jetty.server.Handler">
                <Item>
                    <New id="AppContexts" class="org.eclipse.jetty.server.handler.ContextHandlerCollection"/>
                </Item>
                <Item>
                    <New class="org.eclipse.jetty.server.handler.DefaultHandler"/>
                </Item>
            </Array>
        </Set>
    </New>
</Set>

<Call name="addConnector">
    <Arg>
        <New class="org.eclipse.jetty.server.ServerConnector">
            <Arg name="server"><Ref refid="AppServer" /></Arg>
            <Set name="port">1288</Set>
        </New>
    </Arg>
</Call>

<Call name="addBean">
    <Arg>
        <New id="DeploymentManager" class="org.eclipse.jetty.deploy.DeploymentManager">
            <Set name="contexts">
                <Ref refid="AppContexts" />
            </Set>

            <Call id="webappprovider" name="addAppProvider">
                <Arg>
                    <New class="org.eclipse.jetty.deploy.providers.WebAppProvider">
                        <Set name="monitoredDirName"><Property name="jetty.base" default="." />/<Property name="jetty.deploy.monitoredDirName" default="app-webapps"/></Set>
                        <Set name="monitoredDirName"><Property name="jetty.home" default="." />/app-webapps</Set>
                        <Set name="defaultsDescriptor"><Property name="jetty.home" default="." />/etc/webdefault.xml</Set>
                        <Set name="configurationManager">
                            <New class="org.eclipse.jetty.deploy.PropertiesConfigurationManager"/>
                        </Set>
                        <Set name="scanInterval">0</Set>
                        <Set name="extractWars">true</Set>
                    </New>
                </Arg>
            </Call>
        </New>
    </Arg>
</Call>
</Configure>

执行以下命令运行我的服务器。

**java -jar start.jar etc/myAppServer.xml**

我能够看到具有指定端口ID的Web应用程序: http://mylocalhost:1288

此服务器已知的上下文是:     / ColorApp ---&gt; oejwWebAppContext @ edf68b {/ ColorApp,file:../ AppData / Local / Temp / jetty-0.0.0.0-1288-ColorApp.war-_ColorApp-any-4734518656386866307.dir / webapp /,AVAILABLE} {.. \ Jetty Servers \码头 - 分布 - 9.2.2.v20140723 \ APP-web应用\ ColorApp.war}

但是当我点击时,我无法运行示例并获得以下异常, HTTP ERROR 500

访问/ ColorApp_Tomcar /时出现问题。原因是:

Server Error

Caused by:

org.apache.jasper.JasperException: java.lang.IllegalStateException: No  org.apache.tomcat.InstanceManager set in ServletContext
at org.apache.jasper.servlet.JspServletWrapper.getServlet(JspServletWrapper.java:177)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:369)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:403)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:347)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:769)
at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:585)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:143)
at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:595)
at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:223)
at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1125)
at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:515)
at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:185)
at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1059)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141)
at org.eclipse.jetty.server.Dispatcher.forward(Dispatcher.java:191)
at org.eclipse.jetty.server.Dispatcher.forward(Dispatcher.java:72)
at org.eclipse.jetty.servlet.DefaultServlet.doGet(DefaultServlet.java:585)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:687)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:769)
at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:585)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:143)
at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:577)
at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:223)
at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1125)
at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:515)
at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:185)
at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1059)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141)
at org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:215)
at org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:110)
at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:97)
at org.eclipse.jetty.server.Server.handle(Server.java:485)
at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:290)
at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:248)
at org.eclipse.jetty.io.AbstractConnection$2.run(AbstractConnection.java:540)
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:606)
at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:535)
at java.lang.Thread.run(Thread.java:745)
Caused by: 

java.lang.IllegalStateException: No org.apache.tomcat.InstanceManager set in ServletContext
at org.apache.jasper.runtime.InstanceManagerFactory.getInstanceManager(InstanceManagerFactory.java:32)
at org.apache.jasper.servlet.JspServletWrapper.getServlet(JspServletWrapper.java:171)
... 39 more
Caused by:

java.lang.IllegalStateException: No org.apache.tomcat.InstanceManager set in ServletContext
    at org.apache.jasper.runtime.InstanceManagerFactory.getInstanceManager(InstanceManagerFactory.java:32)
    at org.apache.jasper.servlet.JspServletWrapper.getServlet(JspServletWrapper.java:171)
    at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:369)
    at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:403)
    at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:347)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
    at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:769)
    at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:585)
    at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:143)
    at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:595)
    at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:223)
    at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1125)
    at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:515)
    at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:185)
    at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1059)
    at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141)
    at org.eclipse.jetty.server.Dispatcher.forward(Dispatcher.java:191)
    at org.eclipse.jetty.server.Dispatcher.forward(Dispatcher.java:72)
    at org.eclipse.jetty.servlet.DefaultServlet.doGet(DefaultServlet.java:585)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:687)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
    at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:769)
    at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:585)
    at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:143)
    at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:577)
    at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:223)
    at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1125)
    at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:515)
    at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:185)
    at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1059)
    at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141)
    at org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:215)
    at org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:110)
    at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:97)
    at org.eclipse.jetty.server.Server.handle(Server.java:485)
    at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:290)
    at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:248)
    at org.eclipse.jetty.io.AbstractConnection$2.run(AbstractConnection.java:540)
    at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:606)
    at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:535)
    at java.lang.Thread.run(Thread.java:745)
Powered by Jetty://

1 个答案:

答案 0 :(得分:0)

没有理由为什么更改端口应该具有这样的效果,除非您的错误处理错误/损坏并且您在该端口上运行了现有的Jetty服务器(或者可能是Tomcat服务器)。

因此,第一步是退出所有Java应用程序,然后使用操作系统的任务管理器终止剩下的所有内容。