Publishing a NonSpring Web Service with CXF

We are updating the webservice engine in our suite of applications from AXIS1.1 to CXF3.0.2. I have several problems with publishing web services in our applications.

From what I understand there is a SPRING approach to publishing services in CXF and there is a spring approach. My preference is to use the spring approach as our application is built on top of STRUTS and I don't want to introduce SPRING as part of this upgrade process. I am open to choosing the SPRING approach to publishing a CXF webservice if I have no other options.

Here is my spring approach to publishing a webservice:

I have a servlet that extends org.apache.cxf.transport.servlet.CXFNonSpringServlet and overrides the loadBus (ServletConfig) method (Below is the code snippet for the loadBus method). This servlet is configured in the web.xml file to receive all requests outgoing with the / services / * URL pattern

@Override
public void loadBus(ServletConfig servletConfig)
{
   super.loadBus(servletConfig);
   Bus bus = getBus();
   BusFactory.setDefaultBus(bus);
   Endpoint ep = Endpoint.create(new myWebService());
   ep.publish("/myService");
}

      

The Endpoint class in the above code snippet is javax.xml.ws.Endpoint. I expect to see published services from the URL http://www.myhost.com/contextRoot/services/ . But I see everything with the url: "No services found" - Obviously, the publication failed. The exception stack trace in the server console looks like this:

java.lang.IllegalArgumentException: Cannot create URL for this address / MYSERVICE at com.sun.xml.ws.transport.http.server.EndpointImpl.publish (EndpointImpl.java:237) at com.chase.ccs.servlet.CCSCXFNonSpringServlet .loadBus (CCSCXFNonSpringServlet.java:37) at org.apache.cxf.transport.servlet.CXFNonSpringServlet.init (CXFNonSpringServlet.java:76) at com.ibm.ws.webcontainer.raservlet.Servlet9 ) at com.ibm.ws.webcontainer.servlet.ServletWrapperImpl.init (ServletWrapperImpl.java:168) at com.ibm.ws.webcontainer.servlet.ServletWrapper.load (ServletWrapper.java:1283) at com.ibm.ws. webcontainer.filter.WebAppFilterManager.invokeFilters (WebAppFilterManager.java:973) at com.ibm.ws.webcontainer.webapp.WebApp.handleRequest (WebApp.java:3703) at com.ibm.ws.webcontainer.webapp.WebGroup.handleRequest (WebGroup.java304) at com.ibm.ws.webcontainer.WebContainer.handleRequest (WebContainer.java:953) at com.ibm.ws.webcontainer.WSWebContainer.handleRequest (WSWeb1655) at .ibm.ws.webcontainer.channel.WCChannelLink.ready (WCChannelLink.java:195) at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleDiscrimination (HttpInboundLink.java:452) at .http.channel.inbound.impl.HttpInboundLink.handleNewRequest (HttpInboundLink.java:511) at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.processRequest (HttpInboundLink.java511) .channel.inbound.impl.HttpInboundLink.ready (HttpInboundLink.java:276) at com.ibm.ws.tcp.channel.impl.NewConnectionInitialReadCallback.sendToDiscriminators (NewConnectionInitialRead :Callback.java214) at com.ibm.ws.tcp.channel.impl.NewConnectionInitialReadCallback.complete (NewConnectionInitialReadCallback.java:113) at com.ibm.ws.tcp.channel.impl.AioReadCompletionListener.future16Completed (AioReadCompletionListener.future165Completed) .ibm.io.async.AbstractAsyncFuture.invokeCallback (AbstractAsyncFuture.java:217) at com.ibm.io.async.AsyncChannelFuture.fireCompletionActions (AsyncChannelFuture.java:161) at com.ibm.io.asuture .java: 138) at com.ibm.io.async.ResultHandler.complete (ResultHandler.java:204) at com.ibm.io.async.ResultHandler.runEventProcessingLoop (ResultHandler.java:775) at com.ibm.io. async.ResultHandler $ 2.run (ResultHandler.java:905) at com.ibm.ws.util.ThreadPool $ Worker.run (ThreadPool.java:1650)NewConnectionInitialReadCallback.complete (NewConnectionInitialReadCallback.java:113) at com.ibm.ws.tcp.channel.impl.AioReadCompletionListener.futureCompleted (AioReadCompletionListener.java:165) at com.ibm.io. 217) at com.ibm.io.async.AsyncChannelFuture.fireCompletionActions (AsyncChannelFuture.java:161) at com.ibm.io.async.AsyncFuture.completed (AsyncFuture.java:138) at com.ibm.io.Haslerc.Result .complete (ResultHandler.java:204) at com.ibm.io.async.ResultHandler.runEventProcessingLoop (ResultHandler.java:775) at com.ibm.io.async.ResultHandler $ 2.run (ResultHandler.java:905) at com .ibm.ws.util.ThreadPool $ Worker.run (ThreadPool.java:1650)NewConnectionInitialReadCallback.complete (NewConnectionInitialReadCallback.java:113) at com.ibm.ws.tcp.channel.impl.AioReadCompletionListener.futureCompleted (AioReadCompletionListener.java:165) at com.ibm.io. 217) at com.ibm.io.async.AsyncChannelFuture.fireCompletionActions (AsyncChannelFuture.java:161) at com.ibm.io.async.AsyncFuture.completed (AsyncFuture.java:138) at com.ibm.io.Haslerc.Result .complete (ResultHandler.java:204) at com.ibm.io.async.ResultHandler.runEventProcessingLoop (ResultHandler.java:775) at com.ibm.io.async.ResultHandler $ 2.run (ResultHandler.java:905) at com .ibm.ws.util.ThreadPool $ Worker.run (ThreadPool.java:1650)channel.impl.AioReadCompletionListener.futureCompleted (AioReadCompletionListener.java:165) at com.ibm.io.async.AbstractAsyncFuture.invokeCallback (AbstractAsyncFuture.java:217) at com.ibm.io.asynelc.Futcutc. 161) at com.ibm.io.async.AsyncFuture.completed (AsyncFuture.java:138) at com.ibm.io.async.ResultHandler.complete (ResultHandler.java:204) at com.ibm.io.async.ResultHandler .runEventProcessingLoop (ResultHandler.java:775) at com.ibm.io.async.ResultHandler $ 2.run (ResultHandler.java:905) at com.ibm.ws.util.ThreadPool $ Worker.run (ThreadPool.java:1650)channel.impl.AioReadCompletionListener.futureCompleted (AioReadCompletionListener.java:165) at com.ibm.io.async.AbstractAsyncFuture.invokeCallback (AbstractAsyncFuture.java:217) at com.ibm.io.asynelc.Futcutc. 161) at com.ibm.io.async.AsyncFuture.completed (AsyncFuture.java:138) at com.ibm.io.async.ResultHandler.complete (ResultHandler.java:204) at com.ibm.io.async.ResultHandler .runEventProcessingLoop (ResultHandler.java:775) at com.ibm.io.async.ResultHandler $ 2.run (ResultHandler.java:905) at com.ibm.ws.util.ThreadPool $ Worker.run (ThreadPool.java:1650)async.AsyncChannelFuture.fireCompletionActions (AsyncChannelFuture.java:161) at com.ibm.io.async.AsyncFuture.completed (AsyncFuture.java:138) at com.ibm.io.async.Result:andler.complete (ResultHandler.complete) (ResultHandler.complete) at com.ibm.io.async.ResultHandler.runEventProcessingLoop (ResultHandler.java:775) at com.ibm.io.async.ResultHandler $ 2.run (ResultHandler.java:905) at com.ibm.ws.util.ThreadPool $ Worker.run (ThreadPool.java:1650)async.AsyncChannelFuture.fireCompletionActions (AsyncChannelFuture.java:161) at com.ibm.io.async.AsyncFuture.completed (AsyncFuture.java:138) at com.ibm.io.async.Result:andler.complete (ResultHandler.complete) (ResultHandler.complete) at com.ibm.io.async.ResultHandler.runEventProcessingLoop (ResultHandler.java:775) at com.ibm.io.async.ResultHandler $ 2.run (ResultHandler.java:905) at com.ibm.ws.util.ThreadPool $ Worker.run (ThreadPool.java:1650)ThreadPool $ Worker.run (ThreadPool.java:1650)ThreadPool $ Worker.run (ThreadPool.java:1650)

What am I missing or where did I go wrong?

+3


source to share


2 answers


I also faced the same situation. you can change your loadBus method as follows. it worked for me.



@Override 
public void loadBus(ServletConfig servletConfig){
super.loadBus(servletConfig);
ServerFactoryBean factory = new ServerFactoryBean();
factory.setBus(bus);
factory.setServiceClass(myWebService.class);
factory.setAddress("/myService");
factory.create();
}

      

0


source


I know this answer may be a little late, but I ran into a similar problem (cxf 3.1.4). In my case, the jar cxf-rt-frontend-jaxws was not in my application class path. Adding it solved my problem.



0


source







All Articles