简体   繁体   中英

Integrating WebService (JAX-RS) with Java Stripes

I have a web application developed in Stripes. Now I need to develop RESTful webservices (probably using JAX-RS) in the same app. How do I integrate my Stripes application to contain these webservices, is there any sample available, or any other method other than JAX-RS?

As Stripes is a web application framework (ie, mainly presentation tier) whereas JAX-RS is a standard for doing RESTful web services (ie, mainly business logic tier), I'd be strongly tempted to have two separate servlets, one for the Stripes part and one for the JAX-RS part. The Stripes part would then access the JAX-RS part for its back-end.

It is probably possible to deploy both parts in the same container, but I've not a lot of experience with that.

(You'll want to select which JAX-RS implementation you're using fairly early. The ones I know of are Jersey and CXF, and they have enough differences — driven from different sets of use cases — that you won't want to switch between them.)

I have the same problem now. JAX-WS servlet should work in combination with Stripes servlet and here is the problem.

web.xml excerpt:

<servlet>
    <servlet-name>StripesDispatcher</servlet-name>
    <servlet-class>net.sourceforge.stripes.controller.DispatcherServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
</servlet>

<filter-mapping>
    <filter-name>StripesFilter</filter-name>
    <servlet-name>StripesDispatcher</servlet-name>
    <dispatcher>REQUEST</dispatcher>
    <dispatcher>FORWARD</dispatcher>
</filter-mapping> 

<servlet-mapping>
    <servlet-name>StripesDispatcher</servlet-name>
    <url-pattern>*.action</url-pattern>
</servlet-mapping>

<servlet>
    <servlet-name>WebConnectorService</servlet-name>
    <servlet-class>my.sample.application.WebConnectorService</servlet-class>
</servlet>

<servlet-mapping>
    <servlet-name>WebConnectorService</servlet-name>
    <url-pattern>/ws</url-pattern>
</servlet-mapping>

In this case JAX-WS servlet is working but all the other requests are not processed by Stripes. Does anybody have any new updates to the issue? Thanks.

UPDATE: I have figured out that requests were processed by both servlets however the problem is because now the application has context root equal to the name of the WAR package. However I have

<context-root>/</context-root>

in jboss-web.xml and it behaves as expected in case WebConnector servlet is not included. As soon as WebConnector servlet is included in web.xml, the configuration above is ignored.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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