尽管文档声称使用嵌入式码头运行应用程序非常容易,但我一直非常沮丧并且不成功。据我所知,问题是它无法找到/加载web.xml或在整个jar中找到我的webapp目录。我的应用程序的结构是:
mexp
mexp
mexp.json (properties file)
mexp-jetty
JettyWebApp.class (contains my main method)
mexp-webapp
(etc.)
我有多个模块,但我认为那些是重要的模块,而不是这个问题。我使用maven-shade插件在mexp-jetty目录中构建jar(也许这是我的第一个错误)。
我正在项目目录的根目录中运行它(尝试),使用:
java -XX:+UseConcMarkSweepGC -XX:PermSize=64M -XX:MaxPermSize=256M -Xms1G -Xmx1G -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/tmp -jar mexp-jetty/target/mexp-jetty-3.0-SNAPSHOT.jar mexp/mexp.json
这是我在JettyWebApp中的主要方法:
public static void main(String[] args) throws Exception {
Server server = new Server();
MBeanContainer mbContainer = new MBeanContainer(ManagementFactory.getPlatformMBeanServer());
server.addBean(mbContainer);
// parse json input from a json file - demonstrably works fine
MEXPJsonProps mexpJsonProps = parseJsonInput(args);
Map<String, Object> httpProps = mexpJsonProps.getHttp();
HttpConfiguration httpConfiguration = new HttpConfiguration();
int outputBufferSize = httpProps.get("outputBufferSize") instanceof Double
? Double.class.cast(httpProps.get("outputBufferSize")).intValue()
: (Integer) httpProps.get("outputBufferSize");
httpConfiguration.setOutputBufferSize(outputBufferSize);
ServerConnector http = new ServerConnector(server,new HttpConnectionFactory(httpConfiguration));
int port = httpProps.get("port") instanceof Double
? Double.class.cast(httpProps.get("port")).intValue()
: (Integer) httpProps.get("port");
http.setPort(port);
int idleTimeout = httpProps.get("idleTimeout") instanceof Double
? Double.class.cast(httpProps.get("idleTimeout")).intValue()
: (Integer) httpProps.get("idleTimeout");
http.setIdleTimeout(idleTimeout);
ServerConnector httpAdmin = new ServerConnector(server,new HttpConnectionFactory(httpConfiguration));
int adminPort = httpProps.get("adminPort") instanceof Double
? Double.class.cast(httpProps.get("adminPort")).intValue()
: (Integer) httpProps.get("adminPort");
httpAdmin.setPort(adminPort);
httpAdmin.setIdleTimeout(idleTimeout);
// Set the connector
server.setConnectors(new Connector[] { http, httpAdmin });
WebAppContext context = new WebAppContext();
context.setClassLoader(Thread.currentThread().getContextClassLoader());
// web.xml location
String webXmlLocation = "/WEB-INF/web.xml";
// webXmlLocation = JettyWebApp.class.getClassLoader().getParent().getResource(webXmlLocation).toString();
context.setDescriptor(webXmlLocation);
// resourceBase
String resourceBase = "../mexp-webapp/src/main/webapp/";
// resourceBase = Thread.currentThread().getContextClassLoader().getResource(resourceBase).toString();
context.setResourceBase(resourceBase);
context.setContextPath("/");
context.setParentLoaderPriority(true);
// Set the handler
server.setHandler(context);
server.start();
server.join();
}
mexp-码头/ pom.xml中:
<build>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>1.7.1</version>
<configuration>
<createDependencyReducedPom>true</createDependencyReducedPom>
<filters>
<filter>
<artifact>*:*</artifact>
<excludes>
<exclude>META-INF/*.SF</exclude>
<exclude>META-INF/*.DSA</exclude>
<exclude>META-INF/*.RSA</exclude>
</excludes>
</filter>
</filters>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<transformers>
<transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer" />
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>com.pronto.JettyWebApp</mainClass>
</transformer>
<transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
<resource>META-INF/spring.handlers</resource>
</transformer>
<transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
<resource>META-INF/spring.schemas</resource>
</transformer>
</transformers>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
除了遵循教程(http://wiki.eclipse.org/Jetty/Tutorial/Embedding_Jetty)中的建议之外,我还做了一些搜索,在StackOverflow和其他地方找到了一些想法,但到目前为止还没有任何工作。我读了例如
context.setDescriptor(JettyWebApp.class.getClassLoader().getParent().getResource("/WEB-INF/web.xml").toString());
比
更可取context.setDescriptor("/WEB-INF/web.xml");
没有快乐。我还尝试了JettyWebApp.class.getClassLoader()和Thread.currentThread()。getContextClassLoader(),以及尝试每个的父级。不。
我不确定下一步该尝试什么。我非常感谢任何帮助。谢谢!
ETA:这是System.err的转储。我没有看到任何有用的东西,但也许你可以。
Sep 14, 2014 12:49:36 PM org.eclipse.jetty.util.log.Log initialized
INFO: Logging initialized @82ms
Sep 14, 2014 12:49:37 PM org.eclipse.jetty.server.Server doStart
INFO: jetty-9.2.z-SNAPSHOT
Sep 14, 2014 12:49:37 PM org.eclipse.jetty.server.handler.ContextHandler doStart
INFO: Started o.e.j.w.WebAppContext@47041bea{/,file:/Volumes/Nimue/Development/pronto/mexp-webapp/src/main/webapp,AVAILABLE}
Sep 14, 2014 12:49:37 PM org.eclipse.jetty.server.AbstractConnector doStart
INFO: Started ServerConnector@543a2dec{HTTP/1.1}{0.0.0.0:8080}
Sep 14, 2014 12:49:37 PM org.eclipse.jetty.server.AbstractConnector doStart
INFO: Started ServerConnector@3227f076{HTTP/1.1}{0.0.0.0:8081}
Sep 14, 2014 12:49:37 PM org.eclipse.jetty.server.Server doStart
INFO: Started @637ms
org.eclipse.jetty.server.Server@4b11a903 - STARTED
+= qtp1554994663{STARTED,8<=11<=200,i=1,q=0} - STARTED
| +- 11 qtp1554994663-11-selector-ServerConnectorManager@7310860e/0 RUNNABLE @ sun.nio.ch.KQueueArrayWrapper.kevent0(Native Method)
| +- 12 qtp1554994663-12-selector-ServerConnectorManager@7310860e/1 RUNNABLE @ sun.nio.ch.KQueueArrayWrapper.kevent0(Native Method)
| +- 13 qtp1554994663-13-acceptor-0@10f71ff4-ServerConnector@543a2dec{HTTP/1.1}{0.0.0.0:8080} RUNNABLE @ sun.nio.ch.ServerSocketChannelImpl.accept0(Native Method)
| +- 14 qtp1554994663-14-selector-ServerConnectorManager@7529a559/0 RUNNABLE @ sun.nio.ch.KQueueArrayWrapper.kevent0(Native Method)
| +- 15 qtp1554994663-15-selector-ServerConnectorManager@7529a559/1 RUNNABLE @ sun.nio.ch.KQueueArrayWrapper.kevent0(Native Method)
| +- 16 qtp1554994663-16-selector-ServerConnectorManager@7310860e/2 RUNNABLE @ sun.nio.ch.KQueueArrayWrapper.kevent0(Native Method)
| +- 17 qtp1554994663-17-selector-ServerConnectorManager@7529a559/2 RUNNABLE @ sun.nio.ch.KQueueArrayWrapper.kevent0(Native Method)
| +- 18 qtp1554994663-18-selector-ServerConnectorManager@7310860e/3 RUNNABLE @ sun.nio.ch.KQueueArrayWrapper.kevent0(Native Method)
| +- 20 qtp1554994663-20-selector-ServerConnectorManager@7529a559/3 RUNNABLE @ sun.nio.ch.KQueueArrayWrapper.kevent0(Native Method)
| +- 22 qtp1554994663-22-acceptor-0@27ad6dbe-ServerConnector@3227f076{HTTP/1.1}{0.0.0.0:8081} RUNNABLE @ sun.nio.ch.ServerSocketChannelImpl.accept0(Native Method)
| +- 23 qtp1554994663-23 TIMED_WAITING @ sun.misc.Unsafe.park(Native Method) IDLE
+- org.eclipse.jetty.jmx.MBeanContainer@3ba102ef
| +- org.eclipse.jetty.security.SecurityHandler$1@6a0d8573=org.eclipse.jetty.security:context=ROOT,type=securityhandler$1,id=0
| +- org.eclipse.jetty.servlet.ListenerHolder@22d16a1f=org.eclipse.jetty.servlet:context=ROOT,type=listenerholder,id=1
| +- org.eclipse.jetty.io.ArrayByteBufferPool@fb8a556=org.eclipse.jetty.io:context=HTTP/1.1@543a2dec,type=arraybytebufferpool,id=0
| +- o.e.j.w.WebAppContext@47041bea{/,file:/Volumes/Nimue/Development/pronto/mexp-webapp/src/main/webapp,AVAILABLE}=org.eclipse.jetty.webapp:context=ROOT,type=webappcontext,id=0
| +- org.eclipse.jetty.server.ServerConnector$ServerConnectorManager@7529a559=org.eclipse.jetty.server:context=HTTP/1.1@3227f076,type=serverconnector$serverconnectormanager,id=0
| +- default@5c13d641==org.eclipse.jetty.servlet.DefaultServlet,0,true=org.eclipse.jetty.servlet:context=ROOT,type=servletholder,name=default,id=0
| +- qtp1554994663-13-acceptor-0@10f71ff4-ServerConnector@543a2dec{HTTP/1.1}{0.0.0.0:8080}=org.eclipse.jetty.server:context=HTTP/1.1@543a2dec,type=abstractconnector$acceptor,id=0
| +- HttpConfiguration@603170cc{32768,8192/8192,https://:0,[]}=org.eclipse.jetty.server:context=HTTP/1.1@543a2dec,type=httpconfiguration,id=0
| +- org.eclipse.jetty.util.thread.ScheduledExecutorScheduler@523f39f2=org.eclipse.jetty.util.thread:context=HTTP/1.1@543a2dec,type=scheduledexecutorscheduler,id=0
| +- org.eclipse.jetty.security.ConstraintSecurityHandler@25bcb56b=org.eclipse.jetty.security:context=ROOT,type=constraintsecurityhandler,id=0
| +- ServerConnector@543a2dec{HTTP/1.1}{0.0.0.0:8080}=org.eclipse.jetty.server:context=HTTP/1.1@543a2dec,type=serverconnector,id=0
| +- HttpConnectionFactory@5a73fe03{HTTP/1.1}=org.eclipse.jetty.server:context=HTTP/1.1@3227f076,type=httpconnectionfactory,id=0
| +- qtp1554994663-22-acceptor-0@27ad6dbe-ServerConnector@3227f076{HTTP/1.1}{0.0.0.0:8081}=org.eclipse.jetty.server:context=HTTP/1.1@3227f076,type=abstractconnector$acceptor,id=0
| +- jsp@19c47==org.apache.jasper.servlet.JspServlet,0,true=org.eclipse.jetty.servlet:context=ROOT,type=servletholder,name=jsp,id=0
| +- HttpConnectionFactory@5ef4f91d{HTTP/1.1}=org.eclipse.jetty.server:context=HTTP/1.1@543a2dec,type=httpconnectionfactory,id=0
| +- org.eclipse.jetty.io.ArrayByteBufferPool@bc8ba5=org.eclipse.jetty.io:context=HTTP/1.1@3227f076,type=arraybytebufferpool,id=0
| +- org.eclipse.jetty.util.thread.ScheduledExecutorScheduler@5b094702=org.eclipse.jetty.util.thread:context=ROOT,type=scheduledexecutorscheduler,id=0
| +- sun.nio.ch.ServerSocketChannelImpl[/0:0:0:0:0:0:0:0:8081]=sun.nio.ch:context=HTTP/1.1@3227f076,type=serversocketchannelimpl,id=0
| +- org.eclipse.jetty.util.thread.ScheduledExecutorScheduler@43fa0859=org.eclipse.jetty.util.thread:context=HTTP/1.1@3227f076,type=scheduledexecutorscheduler,id=0
| +- org.eclipse.jetty.servlet.ErrorPageErrorHandler@743ee38c=org.eclipse.jetty.servlet:context=ROOT,type=errorpageerrorhandler,id=0
| +- [/]=>default=org.eclipse.jetty.servlet:context=ROOT,type=servletmapping,name=default,id=0
| +- ServerConnector@3227f076{HTTP/1.1}{0.0.0.0:8081}=org.eclipse.jetty.server:context=HTTP/1.1@3227f076,type=serverconnector,id=0
| +- org.eclipse.jetty.server.Server@4b11a903=org.eclipse.jetty.server:type=server,id=0
| +- org.eclipse.jetty.server.session.SessionHandler@126b227=org.eclipse.jetty.server.session:context=ROOT,type=sessionhandler,id=0
| +- org.eclipse.jetty.server.session.HashSessionIdManager@8cb09b6=org.eclipse.jetty.server.session:type=hashsessionidmanager,id=0
| +- [*.jsp, *.jspf, *.jspx, *.xsp, *.JSP, *.JSPF, *.JSPX, *.XSP]=>jsp=org.eclipse.jetty.servlet:context=ROOT,type=servletmapping,name=jsp,id=0
| +- org.eclipse.jetty.server.session.HashSessionManager@120b0058=org.eclipse.jetty.server.session:context=ROOT,type=hashsessionmanager,id=0
| +- org.eclipse.jetty.servlet.ServletHandler@d385acb=org.eclipse.jetty.servlet:context=ROOT,type=servlethandler,id=0
| +- org.eclipse.jetty.server.ServerConnector$ServerConnectorManager@7310860e=org.eclipse.jetty.server:context=HTTP/1.1@543a2dec,type=serverconnector$serverconnectormanager,id=0
| +- org.eclipse.jetty.jmx.MBeanContainer@3ba102ef=org.eclipse.jetty.jmx:type=mbeancontainer,id=0
| +- org.eclipse.jetty.security.DefaultAuthenticatorFactory@615d5d35=org.eclipse.jetty.security:context=ROOT,type=defaultauthenticatorfactory,id=0
| +- sun.nio.ch.ServerSocketChannelImpl[/0:0:0:0:0:0:0:0:8080]=sun.nio.ch:context=HTTP/1.1@543a2dec,type=serversocketchannelimpl,id=0
| +- org.eclipse.jetty.servlet.ListenerHolder@216c6a89=org.eclipse.jetty.servlet:context=ROOT,type=listenerholder,id=0
| +- qtp1554994663{STARTED,8<=11<=200,i=1,q=0}=org.eclipse.jetty.util.thread:type=queuedthreadpool,id=0
| +- {}=java.util.concurrent:type=concurrenthashmap,id=0
+= ServerConnector@543a2dec{HTTP/1.1}{0.0.0.0:8080} - STARTED
| +~ org.eclipse.jetty.server.Server@4b11a903 - STARTED
| +~ qtp1554994663{STARTED,8<=11<=200,i=1,q=0} - STARTED
| += org.eclipse.jetty.util.thread.ScheduledExecutorScheduler@523f39f2 - STARTED
| +- org.eclipse.jetty.io.ArrayByteBufferPool@fb8a556
| += HttpConnectionFactory@5ef4f91d{HTTP/1.1} - STARTED
| | +- HttpConfiguration@603170cc{32768,8192/8192,https://:0,[]}
| | +~ org.eclipse.jetty.jmx.MBeanContainer@3ba102ef
| += org.eclipse.jetty.server.ServerConnector$ServerConnectorManager@7310860e - STARTED
| | +- org.eclipse.jetty.io.SelectorManager$ManagedSelector@35595365 keys=0 selected=0 id=0
| | | +- org.eclipse.jetty.io.SelectorManager$ManagedSelector.select(SelectorManager.java:537)
| | | +- sun.nio.ch.KQueueSelectorImpl@3e1fc537 keys=0
| | +- org.eclipse.jetty.io.SelectorManager$ManagedSelector@17ccbdbe keys=0 selected=0 id=1
| | | +- org.eclipse.jetty.io.SelectorManager$ManagedSelector.select(SelectorManager.java:537)
| | | +- sun.nio.ch.KQueueSelectorImpl@4ab118d8 keys=0
| | +- org.eclipse.jetty.io.SelectorManager$ManagedSelector@30d63337 keys=0 selected=0 id=2
| | | +- org.eclipse.jetty.io.SelectorManager$ManagedSelector.select(SelectorManager.java:537)
| | | +- sun.nio.ch.KQueueSelectorImpl@47a72fc8 keys=0
| | +- org.eclipse.jetty.io.SelectorManager$ManagedSelector@31321838 keys=0 selected=0 id=3
| | +- org.eclipse.jetty.io.SelectorManager$ManagedSelector.select(SelectorManager.java:537)
| | +- sun.nio.ch.KQueueSelectorImpl@6eee1626 keys=0
| +~ org.eclipse.jetty.jmx.MBeanContainer@3ba102ef
| +- sun.nio.ch.ServerSocketChannelImpl[/0:0:0:0:0:0:0:0:8080]
| +- qtp1554994663-13-acceptor-0@10f71ff4-ServerConnector@543a2dec{HTTP/1.1}{0.0.0.0:8080}
+= ServerConnector@3227f076{HTTP/1.1}{0.0.0.0:8081} - STARTED
| +~ org.eclipse.jetty.server.Server@4b11a903 - STARTED
| +~ qtp1554994663{STARTED,8<=11<=200,i=1,q=0} - STARTED
| += org.eclipse.jetty.util.thread.ScheduledExecutorScheduler@43fa0859 - STARTED
| +- org.eclipse.jetty.io.ArrayByteBufferPool@bc8ba5
| += HttpConnectionFactory@5a73fe03{HTTP/1.1} - STARTED
| | +- HttpConfiguration@603170cc{32768,8192/8192,https://:0,[]}
| | +~ org.eclipse.jetty.jmx.MBeanContainer@3ba102ef
| += org.eclipse.jetty.server.ServerConnector$ServerConnectorManager@7529a559 - STARTED
| | +- org.eclipse.jetty.io.SelectorManager$ManagedSelector@50f051af keys=0 selected=0 id=0
| | | +- org.eclipse.jetty.io.SelectorManager$ManagedSelector.select(SelectorManager.java:537)
| | | +- sun.nio.ch.KQueueSelectorImpl@67ae0d02 keys=0
| | +- org.eclipse.jetty.io.SelectorManager$ManagedSelector@53d8337b keys=0 selected=0 id=1
| | | +- org.eclipse.jetty.io.SelectorManager$ManagedSelector.select(SelectorManager.java:537)
| | | +- sun.nio.ch.KQueueSelectorImpl@2e0baf4c keys=0
| | +- org.eclipse.jetty.io.SelectorManager$ManagedSelector@121be32 keys=0 selected=0 id=2
| | | +- org.eclipse.jetty.io.SelectorManager$ManagedSelector.select(SelectorManager.java:537)
| | | +- sun.nio.ch.KQueueSelectorImpl@53cd7dc7 keys=0
| | +- org.eclipse.jetty.io.SelectorManager$ManagedSelector@57fcbecc keys=0 selected=0 id=3
| | +- org.eclipse.jetty.io.SelectorManager$ManagedSelector.select(SelectorManager.java:537)
| | +- sun.nio.ch.KQueueSelectorImpl@6244b0f8 keys=0
| +~ org.eclipse.jetty.jmx.MBeanContainer@3ba102ef
| +- sun.nio.ch.ServerSocketChannelImpl[/0:0:0:0:0:0:0:0:8081]
| +- qtp1554994663-22-acceptor-0@27ad6dbe-ServerConnector@3227f076{HTTP/1.1}{0.0.0.0:8081}
+= o.e.j.w.WebAppContext@47041bea{/,file:/Volumes/Nimue/Development/pronto/mexp-webapp/src/main/webapp,AVAILABLE} - STARTED
| += org.eclipse.jetty.server.session.SessionHandler@126b227 - STARTED
| | += org.eclipse.jetty.server.session.HashSessionManager@120b0058 - STARTED
| | | +~ org.eclipse.jetty.jmx.MBeanContainer@3ba102ef
| | | += org.eclipse.jetty.util.thread.ScheduledExecutorScheduler@5b094702 - STARTED
| | | +~ org.eclipse.jetty.server.session.HashSessionIdManager@8cb09b6 - STARTED
| | | +~ org.eclipse.jetty.security.SecurityHandler$1@6a0d8573
| | += org.eclipse.jetty.security.ConstraintSecurityHandler@25bcb56b - STARTED
| | | +- org.eclipse.jetty.security.DefaultAuthenticatorFactory@615d5d35
| | | += org.eclipse.jetty.servlet.ServletHandler@d385acb - STARTED
| | | | += org.eclipse.jetty.servlet.ListenerHolder@216c6a89 - STARTED
| | | | += org.eclipse.jetty.servlet.ListenerHolder@22d16a1f - STARTED
| | | | += default@5c13d641==org.eclipse.jetty.servlet.DefaultServlet,0,true - STARTED
| | | | | +- maxCacheSize=256000000
| | | | | +- etags=false
| | | | | +- dirAllowed=true
| | | | | +- gzip=false
| | | | | +- maxCachedFileSize=200000000
| | | | | +- redirectWelcome=false
| | | | | +- acceptRanges=true
| | | | | +- welcomeServlets=false
| | | | | +- aliases=false
| | | | | +- useFileMappedBuffer=true
| | | | | +- maxCachedFiles=2048
| | | | += jsp@19c47==org.apache.jasper.servlet.JspServlet,0,true - STARTED
| | | | | +- fork=false
| | | | | +- logVerbosityLevel=DEBUG
| | | | | +- scratchdir=/private/var/folders/75/nvnl8bcd211gmkbw1tk2r35c0000gp/T/jetty-0.0.0.0-8080-webapp-_-any-840299613557258711.dir/jsp
| | | | | +- xpoweredBy=false
| | | | | +- compilerSourceVM=1.7
| | | | | +- compilerTargetVM=1.7
| | | | | +- com.sun.appserv.jsp.classpath=/Users/barclayadunn/Library/Java/Extensions/libJNPRAuthKit.jnilib:/Library/Java/JavaVirtualMachines/jdk1.7.0_67.jdk/Contents/Home/jre/lib/ext/dnsns.jar:/Library/Java/JavaVirtualMachines/jdk1.7.0_67.jdk/Contents/Home/jre/lib/ext/localedata.jar:/Library/Java/JavaVirtualMachines/jdk1.7.0_67.jdk/Contents/Home/jre/lib/ext/sunec.jar:/Library/Java/JavaVirtualMachines/jdk1.7.0_67.jdk/Contents/Home/jre/lib/ext/sunjce_provider.jar:/Library/Java/JavaVirtualMachines/jdk1.7.0_67.jdk/Contents/Home/jre/lib/ext/sunpkcs11.jar:/Library/Java/JavaVirtualMachines/jdk1.7.0_67.jdk/Contents/Home/jre/lib/ext/zipfs.jar:/System/Library/Java/Extensions/AppleScriptEngine.jar:/System/Library/Java/Extensions/dns_sd.jar:/System/Library/Java/Extensions/j3daudio.jar:/System/Library/Java/Extensions/j3dcore.jar:/System/Library/Java/Extensions/j3dutils.jar:/System/Library/Java/Extensions/jai_codec.jar:/System/Library/Java/Extensions/jai_core.jar:/System/Library/Java/Extensions/libAppleScriptEngine.jnilib:/System/Library/Java/Extensions/libJ3D.jnilib:/System/Library/Java/Extensions/libJ3DAudio.jnilib:/System/Library/Java/Extensions/libJ3DUtils.jnilib:/System/Library/Java/Extensions/libmlib_jai.jnilib:/System/Library/Java/Extensions/libQTJNative.jnilib:/System/Library/Java/Extensions/mlibwrapper_jai.jar:/System/Library/Java/Extensions/MRJToolkit.jar:/System/Library/Java/Extensions/QTJava.zip:/System/Library/Java/Extensions/vecmath.jar:/usr/lib/java/libjdns_sd.jnilib
| | | | +- [/]=>default
| | | | +- [*.jsp, *.jspf, *.jspx, *.xsp, *.JSP, *.JSPF, *.JSPX, *.XSP]=>jsp
| | | | +~ org.eclipse.jetty.jmx.MBeanContainer@3ba102ef
| | | +~ org.eclipse.jetty.jmx.MBeanContainer@3ba102ef
| | | |
| | | +> null
| | | +> null
| | | +> null
| | | +> []
| | | +> /={TRACE.omission={RoleInfo[],None}, TRACE={RoleInfo,F,C[],None}}
| | +~ org.eclipse.jetty.jmx.MBeanContainer@3ba102ef
| += org.eclipse.jetty.servlet.ErrorPageErrorHandler@743ee38c - STARTED
| | +~ org.eclipse.jetty.jmx.MBeanContainer@3ba102ef
| +~ org.eclipse.jetty.jmx.MBeanContainer@3ba102ef
| |
| +> sun.misc.Launcher$AppClassLoader@4c0c7539
| | +- file:/Volumes/Nimue/Development/pronto/mexp-jetty/mexp-jetty/target/mexp-jetty-3.0-SNAPSHOT.jar
| | +- sun.misc.Launcher$ExtClassLoader@45e41830
| +> javax.servlet.context.tempdir=/private/var/folders/75/nvnl8bcd211gmkbw1tk2r35c0000gp/T/jetty-0.0.0.0-8080-webapp-_-any-840299613557258711.dir
| +> org.apache.catalina.jsp_classpath=/Volumes/Nimue/Development/pronto/mexp-jetty/mexp-jetty/target/mexp-jetty-3.0-SNAPSHOT.jar
| +> org.eclipse.jetty.server.Executor=qtp1554994663{STARTED,8<=11<=200,i=1,q=0}
+- {}
+- {}
+- {}
+= org.eclipse.jetty.server.session.HashSessionIdManager@8cb09b6 - STARTED
|
+> sun.misc.Launcher$AppClassLoader@4c0c7539
+- file:/Volumes/Nimue/Development/pronto/mexp-jetty/mexp-jetty/target/mexp-jetty-3.0-SNAPSHOT.jar
+- sun.misc.Launcher$ExtClassLoader@45e41830
答案 0 :(得分:0)
WebAppContext
需要有效网络应用的完整路径。
webXmlLocation
和resourceBase
的参赛作品自动无效。
此外,您尝试指向src/main/webapp
这一事实意味着您试图指向一个不完整的网络应用,该网络应用没有WEB-INF/lib
或WEB-INF/classes
。
我们还在配置中看到spring,spring to wireup本身的组件通常使用servlet规范的功能,这些功能要求容器查找/发现/初始化它们。看到这些在您的环境中不存在,实际上什么都没有开始。
要使用src/main/webapp
运行应用程序需要一个对非开发运行时环境无效的配置,使用完全充实的有效webapp目录测试环境可能更有意义。
答案 1 :(得分:0)
我的解决方案是回归“战争”方法。来自embedded jetty tutorial:
public static void main(String[] args) throws Exception
{
String jetty_home = System.getProperty("jetty.home","..");
Server server = new Server(8080);
WebAppContext webapp = new WebAppContext();
webapp.setContextPath("/");
webapp.setWar(jetty_home+"/webapps/test.war");
server.setHandler(webapp);
server.start();
server.join();
}