AHA...I discovered my mistake! I had been using CXFNonSpringServlet instead
of CXFNonSpringJaxrsServlet...I didn't realize there was a JAX-RS specific
version. Using that servlet and setting the javax.ws.rs.Application
parameter to my JAX-RS service worked like a champ.
For anyone who may be interested, it's similar to the wiki page I posted but
tweaked to add the init param...
CXFNonSpringServlet cxf = new CXFNonSpringJaxrsServlet();
...
ServletHolder servlet = new ServletHolder(cxf);
servlet.setInitParameter("javax.ws.rs.Application",
"com.acme.MyServiceImpl");
servlet.setName("services");
servlet.setForcedPath("services");
root.addServlet(servlet, "/*");
Voila...I now use my existing Jetty server to deploy the CXF JAX-RS
services.
jmdev wrote:
>
> Sam...Did you deploy your own WAR's and servlets to the CXF-Jetty server?
> If so, how did you get access to the underlying context? Looking at the
> engine-factory XML configuration it appears that I can add handlers, but I
> didn't see anything for WAR's or servlets. Thanks for the help...
>
> Even so I would ideally like to deploy the CXF JAX-RS services on my
> currently configured Jetty instance. Is that possible? Is there an
> Endpoint.publish(...) equivalent for JAX-RS?
>
>
> Sam.Wang wrote:
>>
>> Hi jmdev:
>>
>> I have same issue like yours and I use other method to resolve this
>> issue.
>> I deploy my project files to the CXF-Jetty server, and remove original
>> tomcat. And now, it works fine.
>>
>>
>> jmdev wrote:
>>>
>>> I have successfully gotten my JAX-RS services to run in CXF using the
>>> following Spring configuration
>>>
>>> <import resource="classpath:META-INF/cxf/cxf.xml"/>
>>> <import
>>> resource="classpath:META-INF/cxf/cxf-extension-jaxrs-binding.xml"/>
>>> <import resource="classpath:META-INF/cxf/cxf-extension-http-jetty.xml"/>
>>> ...
>>>
>>> <jaxrs:server id="myServices" address="https://localhost:9000">
>>> <jaxrs:serviceBeans>
>>> <ref bean="myService"/>
>>> </jaxrs:serviceBeans>
>>> </jaxrs:server>
>>>
>>> However, I already have a Jetty server running on port 8080 in my
>>> application and this will create a second Jetty server on port 9000. I
>>> was wondering if it is possible to attach the JAX-RS services to my
>>> existing Jetty server? I was hoping for something similar to the
>>> Endpoint.publish(...) approach taken with JAX-WS as can be found in this
>>> example
>>>
>>> http://cwiki.apache.org/CXF20DOC/servlet-transport.html
>>> http://cwiki.apache.org/CXF20DOC/servlet-transport.html
>>>
>>> Any pointers would be much appreciated!
>>>
>>>
>>
>>
>
>
--
View this message in context:
http://www.nabble.com/JAX-RS-using-an-existing-Jetty-server--tp24870514p24901366.html
Sent from the cxf-user mailing list archive at Nabble.com.