0

Dealing with Jetty (v 8) instance running embedded under a JPOS QBean. For sake of simplicity, I'd like to add Jersey based servlet based REST web service using configuration onlly without having to program the servlet registration. I do have the JXB annotated POJO resource components where the jersey packages setting is pointing to, but that's not important yet.

To my simplistic mind, the following added to the Jetty webdefault.xml should do the trick:

<!-- JPOS As WebSvc -->
<servlet>
<servlet-name>jpos</servlet-name>
<servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class>
<init-param>
  <param-name>com.sun.jersey.api.json.POJOMappingFeature</param-name>
  <param-value>true</param-value>
</init-param>
 <init-param>
  <param-name>com.sun.jersey.config.property.packages</param-name>
  <param-value>com.test.rest.svc</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping> <servlet-name>jpos</servlet-name> <url-pattern>/jpos/*</url-pattern></servlet-mapping>

However, it seems this entry is simply not registered at all, as I see only default and jsp servlets initialized in the logs.

I was looking at the jetty.xml contents and have added a custom handler for different purposes, but it's not clear if a servlet can be added via the Handler collection settings. It seems the built-in ServletHandler is already initialized and is loading the default and jsp servlets, so I don't think I can list that in the jetty.xml to add my servlet (even if I knew how to configure it).

4

1 回答 1

0

结果很简单,只需将 Jersey servlet 配置放入其自己的 web.xml 并将该文件放在配置的 webapps 根目录下,如下所示:
webapps
^^^^root
^^^^^^^index.html
^^^ ^^^^WEB-INF ^^^^^^^^^^
web.xml

于 2012-12-06T14:26:24.413 回答