Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/325.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java Quercus未在嵌入式码头6中运行_Java_Jetty_Quercus - Fatal编程技术网

Java Quercus未在嵌入式码头6中运行

Java Quercus未在嵌入式码头6中运行,java,jetty,quercus,Java,Jetty,Quercus,在过去的几个月里,我一直在尝试在我的应用程序中嵌入Jetty和Quercus,但还没有成功。我使用的是Jetty版本6.1.26和Quercus 4.0.25 我已经用我的应用程序打包了以下jar:jetty-6.1.26.jar、jetty-util-6.1.26.jar和servlet-api-2.5-20081211.jar,它们是我从jetty/lib目录复制的 以下是我在自己的线程上运行的代码: public void run(){ try{ server =

在过去的几个月里,我一直在尝试在我的应用程序中嵌入Jetty和Quercus,但还没有成功。我使用的是Jetty版本6.1.26和Quercus 4.0.25

我已经用我的应用程序打包了以下jar:jetty-6.1.26.jar、jetty-util-6.1.26.jar和servlet-api-2.5-20081211.jar,它们是我从jetty/lib目录复制的

以下是我在自己的线程上运行的代码:

public void run(){
    try{
        server = new Server(Plugin.port);

        WebAppContext wac = new WebAppContext();
        wac.setWar(Plugin.resourceBase);
        wac.setDescriptor(Plugin.resourceBase + "WEB-INF/web.xml");
        wac.setContextPath("/");
        wac.setParentLoaderPriority(true);
        server.setHandler(wac);

        server.setStopAtShutdown(true);

        server.start();

        Plugin.instance.getLogger().log(Level.INFO, "Started web server at port " + Plugin.port);
    }catch(Exception e){
        Plugin.instance.getLogger().log(Level.SEVERE, "Cannot start web server at port " + Plugin.port + "!");
        Plugin.instance.getLogger().log(Level.SEVERE, e.getMessage());
    }
}
在资源库目录中,我有一个WEB-INF文件夹,其中包含一个WEB.xml文件以及Quercus的WEB-INF/lib和/licenses。lib文件夹中的jar是cdi-16.jar、javaee-16.jar、javamail-141.jar和resin.jar

web.xml在其web应用程序标记下具有以下内容:

<servlet>
<servlet-name>Quercus Servlet</servlet-name>
<servlet-class>com.caucho.quercus.servlet.QuercusServlet</servlet-class>
<init-param>
  <param-name>license-directory</param-name>
  <param-value>WEB-INF/licenses</param-value>
</init-param>
</servlet>

<servlet-mapping>
<servlet-name>Quercus Servlet</servlet-name>
  <url-pattern>*.php</url-pattern>
</servlet-mapping>

<welcome-file-list>
  <welcome-file>index.php</welcome-file>
</welcome-file-list>
如果有人能提供帮助,我们将不胜感激


另外,如果您对我应该使用什么版本的Jetty和Quercus有建议,那也会很有帮助。我只使用Jetty 6,因为它是关于嵌入文档最多的版本。

最近我也这么做了

  • 码头6.1.26
  • 从这里来的栎树
然后,我将war解压缩到当前工作目录中的一个文件夹quercus中,无需任何修改

在嵌入式Jetty中设置如下:

    WebAppContext webapp = new WebAppContext();
    webapp.setContextPath("/");
    webapp.setWar("./quercus");

    server.setHandler(webapp);

尝试从Quercus war中删除javaee-16.jar。我将从未来的Quercus发行版中删除它。谢谢。

不,那也不行。编译时如何打包Jetty JAR?我只是将他们的文件复制到一个jar中,并在eclipse中将其作为构建路径添加,然后将其复制到最终程序的jar中。所有jar都在lib文件夹中。这似乎是一个类加载问题。什么是
Plugin.resourceBase
?可能是谷歌的消息:
javax.servlet.UnavailableException:servlet类What.ever.class不是javax.servlet.servlet
我已经在谷歌上搜索了几个月,没有找到答案。Plugin.resourceBase基本上是一个默认值为“/plugins/WebServer/web/”的字符串,但可以由用户更改。我将尝试不将jar打包在一起进行编译,看看这是否有帮助。
    WebAppContext webapp = new WebAppContext();
    webapp.setContextPath("/");
    webapp.setWar("./quercus");

    server.setHandler(webapp);