嵌入码头服务器问题 [英] embedding jetty server problems

查看:110
本文介绍了嵌入码头服务器问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在将码头服务器嵌入到Java应用程序中时,我遇到了一些困难.我正在使用spring来配置实际对象,并且我可以构建webapp没问题-但是在启动服务器时遇到了这个问题...

I am having some struggles embedding a jetty server into a java app. I am using spring to configure the actual objects and I can build the webapp no problems - but I get this problem when starting up the server...

0 [main] INFO test.Server  - Starting server in 'c:/workspace/test/war/' on port 9090
34615 [main] INFO test.Server  - Using resource base: src/main/webapp
34615 [main] INFO test.Server  - Using descriptor file: src/main/webapp/WEB-INF/web.xml
2011-09-05 12:29:36.961:INFO::Logging to STDERR via org.mortbay.log.StdErrLog
36344 [main] INFO test.Server  - Starting Server!
2011-09-05 12:29:37.023:INFO::jetty-6.1H.22
2011-09-05 12:29:37.039:WARN::Failed startup of context org.mortbay.jetty.webapp.WebAppContext@8ab708{/TestServer,file:/C:/workspace/test/war/src/main/webapp/}
java.lang.ClassNotFoundException: org.mortbay.jetty.plus.webapp.EnvConfiguration
    at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
    at org.mortbay.util.Loader.loadClass(Loader.java:91)
    at org.mortbay.util.Loader.loadClass(Loader.java:71)
    at org.mortbay.jetty.webapp.WebAppContext.loadConfigurations(WebAppContext.java:859)
    at org.mortbay.jetty.webapp.WebAppContext.doStart(WebAppContext.java:431)
    at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)
    at org.mortbay.jetty.handler.HandlerWrapper.doStart(HandlerWrapper.java:130)
    at org.mortbay.jetty.Server.doStart(Server.java:224)
    at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)
    at test.Server.main(Server.java:84)
2011-09-05 12:29:37.054:INFO::Started SocketConnector@0.0.0.0:9090

问题似乎出在我的一些路径问题上……目录结构简单明了(什么行家推荐")-

The problem seems to be with some of my path stuff...the dir structure is straight forward (what maven 'recommends') -

工作区/测试/战争/ -src/main/java/test/Server.java -src/main/webapp/WEB-INF/web.xml

workspace/test/war/ -src/main/java/test/Server.java -src/main/webapp/WEB-INF/web.xml

除了它属于春季的东西,我已经在web.xml中设置了已经尝试过并且正确的设置(通过tomcat).

Other than that it falls into the spring stuff I have setup in the web.xml that has been tried and true (via tomcat).

main中的相关代码是这样(否则它是属性废话):

The relevant code in main is this (otherwise it is properties crap):

svrLogger.info ("Starting server in '" + home + "' on port " + port);

String rsrcBase = "src/main/webapp";
String webXml = rsrcBase + "/WEB-INF/web.xml";

svrLogger.info ("Using resource base: " + rsrcBase);
svrLogger.info ("Using descriptor file: " + webXml);

Server server = new Server(port);
WebAppContext webapp = new WebAppContext();

webapp.setContextPath ("/TestServer");
webapp.setDescriptor (home + "/" + webXml);
webapp.setResourceBase (home + "/" + rsrcBase);
webapp.setParentLoaderPriority (true);
server.setHandler(webapp);

svrLogger.info ("Starting Server!");
server.start();
server.join();
svrLogger.info ("Joined and exiting");

任何帮助都很好...很有帮助.这是我第一次尝试制作自己的Web服务器(因此也欢迎其他建议!)

Any help is well...helpful. This is the first time I have tried to make my own web server (so other advice is welcome too!)

推荐答案

尝试包含

<dependency>
    <groupId>org.eclipse.jetty</groupId>
    <artifactId>jetty-jndi</artifactId>
    <version>${jetty.version}</version>
</dependency>

它正在尝试加载此类,因为默认情况下未配置Jetty JNDI.

It's trying to load this class because in Jetty JNDI is not configured by default.

这是学习更多有关Jetty的好资源

This is a good resource to learn more about Jetty

https://jersey.java.net/documentation/latest/index.html

祝你好运!

这篇关于嵌入码头服务器问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆