简体   繁体   English

如何使用焊接模块配置嵌入式Jetty

[英]How to configure embedded Jetty with weld module

I am embedding a Jetty 9.2 server in my JSF web app. 我在我的JSF Web应用程序中嵌入了一个Jetty 9.2服务器。 It is supposed to be very easy to enable Weld in Jetty 9.1+ by enabling the Weld module, but I see no way to do that with the embedded server. 通过启用Weld模块,可以很容易地在Jetty 9.1+中启用Weld,但我认为无法通过嵌入式服务器实现这一点。 Are there any examples of how to do this, and which classes are affected? 是否有任何示例如何执行此操作以及哪些类受到影响?

These are my listeners in web.xml: 这些是我在web.xml中的监听器:

<listener>
  <listener-class>org.jboss.weld.environment.servlet.BeanManagerResourceBindingListener</listener-class>
</listener>
<listener>
  <listener-class>org.jboss.weld.environment.servlet.Listener</listener-class>
</listener>

This is how I'm starting my server: 这就是我启动服务器的方式:

    Server theServer = new Server();
    ServerConnector connector = new ServerConnector(theServer);
    connector.setHost(getHost());
    connector.setPort(getPort());
    connector.setIdleTimeout(getTimeout());
    theServer.addConnector(connector);
    WebAppContext webApp = new WebAppContext();
    webApp.setContextPath("/");
    File f = new File(getFileName());
    webApp.setWar(f.getAbsolutePath());
    webApp.setServer(theServer);
    theServer.setHandler(webApp);
    theServer.start();
    theServer.join()

I got some help from Jesse McConnell at WebTide. 我在WebTide得到了Jesse McConnell的帮助。

I needed to add the following file to my classpath: https://github.com/eclipse/jetty.project/blob/master/jetty-cdi/src/main/config/modules/cdi.mod 我需要将以下文件添加到我的类路径: https//github.com/eclipse/jetty.project/blob/master/jetty-cdi/src/main/config/modules/cdi.mod

I also needed to add the jetty-cdi jar to my pom. 我还需要将jetty-cdi jar添加到我的pom中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM