2

I am creating a web service with spring + jetty + cxf using the following:

<import resource="classpath:META-INF/cxf/cxf.xml" />
<import resource="classpath:META-INF/cxf/cxf-servlet.xml" />
<jaxws:endpoint id="helloWorld" implementor="com.test.EndpointImp" address="http://localhost:9002/test">
</jaxws:endpoint>

This all works as expected and very well. Now I need to "serve" some servlets. Is there anyway I can get to the jetty Server instance that is created for this, so that I can add the servlets? I dont want to create another Jetty instance on another port just for the servlets I need to use.

Any information will be greatly appreciated.

Paul
  • 4,812
  • 3
  • 27
  • 38
  • I think [my post](http://stackoverflow.com/a/8866816/267197) is relevant to your problem. In particular follow [this article](http://cxf.apache.org/docs/servlet-transport.html) which shows how to have several servlets. – dma_k Feb 18 '12 at 19:03
  • Thats perfect. Post an answer so I can mark it as correct! – Paul Feb 21 '12 at 09:27

2 Answers2

1

The solution you are looking for is described in this article. The key points (which I also mentioned in my post) are to use org.apache.cxf.transport.servlet.CXFServlet in your web.xml, don't forget to import META-INF/cxf/cxf-servlet.xml (you did so) and also use relative address="/myservice" attribute. In this case CXF routines will not launch embedded Jetty but use this servlet for processing the inbound requests.

Community
  • 1
  • 1
dma_k
  • 10,431
  • 16
  • 76
  • 128
-1

Of course a webapp can handle at the same time some WebServices and servlets.

I suppose your web services are in a web application. Thus you should have a web.xml (in WEB-INF). You can add your servlets declarations in this web.xml.

Jetty should start your webapp.

We can't help you more if you don't give us more details of your project (Maven based or not, how do you launch Jetty, etc...).

Jean-Philippe Briend
  • 3,455
  • 29
  • 41
  • I will gladly give you more details, what would you like to know? Thats all I have in my spring config file. My applications is launched as standalone and not in a web container. – Paul Feb 17 '12 at 20:55