Hello Dan,
I tried different ways to do it but I did not get successful result.
What did I do wrong?
In the listener code:
--------------------------------------------------------------------------------------------
...
Bus bus = BusFactory.newInstance().createBus();
BusFactory.setDefaultBus(bus);
// snap of code from AbstractCXFServlet.replaceDestinationFactory()
DestinationFactoryManager dfm =
bus.getExtension(DestinationFactoryManager.class);
try {
DestinationFactory df = dfm.getDestinationFactory("
http://cxf.apache.org/transports/http/configuration");
if (df instanceof ServletTransportFactory) {
ServletTransportFactory servletTransportFactory =
(ServletTransportFactory)df;
LOG.info("DESTIONFACTORY_ALREADY_REGISTERED");
return;
}
} catch (BusException e) {
}
DestinationFactory factory = new ServletTransportFactory(bus);
for (String s : factory.getTransportIds()) {
bus.getExtension(DestinationFactoryManager.class).registerDestinationFactory(s,
factory);
}
LOG.info("REPLACED_HTTP_DESTIONFACTORY");
DestinationFactoryManager factoryManager =
bus.getExtension(DestinationFactoryManager.class);
String address = "
http://localhost:8080/ws-examples/soap/services/TicketOrderService";
TicketOrderServiceImpl implementor = new TicketOrderServiceImpl();
Endpoint.publish(address, implementor);
...
--------------------------------------------------------------------------------------------
In the MyCxfNonSpringServlet
-----------------------------------------------------------------------------------------------
...
@Override
public void loadBus(ServletConfig servletConfig) throws ServletException {
super.loadBus(servletConfig);
LOG.info("loadBus method entering");
Bus bus = getBus();
BusFactory.setDefaultBus(bus);
}
@Override
public ServletController createServletController(ServletConfig
servletConfig) {
DestinationFactoryManager dfm =
bus.getExtension(DestinationFactoryManager.class);
try {
servletTransportFactory = (ServletTransportFactory)
dfm.getDestinationFactory("
http://cxf.apache.org/transports/http/configuration");
} catch (Exception e) {
e.printStackTrace();
}
return super.createServletController(servletConfig);
}
...
-----------------------------------------------------------------------------------------------
In the process of deployment were not exceptions.
On a console:
[INFO] WebServiceLoader - REPLACED_HTTP_DESTIONFACTORY
On a browser at url:
http://localhost:8080/ws-examples/soap/services/TicketOrderService?wsdl
"No service was found."
On Wed, Oct 1, 2008 at 8:51 PM, Daniel Kulp <[EMAIL PROTECTED]> wrote:
>
>
> I think it's possible, but it's certainly not trivial.
>
> Looking at the code in the AbstractCXFServlet, it LOOKS like you could
> do:
>
> 1) Before creating your services, if you create a bus and add the servlet
> transport into it. You can take that code from
> replaceDestinationFactory in the AbstractCXFSerlvlet. That should
> allow the services to register fine.
>
> 2) In you servlet subclass, override the createServletController to do:
>
> DestinationFactoryManager dfm =
> bus.getExtension(DestinationFactoryManager.class);
> servletTransportFactory = (SerlvetTransportFactory)
> dfm.getDestinationFactory(
> "http://cxf.apache.org/transports/http/configuration");
> super.createServletController(....);
>
> That looks like it SHOULD work.
>
> Dan
>
>
>
> On Wednesday 01 October 2008, Alexey Zavizionov wrote:
> > Hello list,
> >
> > Is there a CXF API methods to hold on deploy service from listener
> > before MyCxfNonSpringServlet servlet is started.
> > Will it work with register service to the servlet context outside
> > servlet code?
> >
> > Thanks and regards,
> > Alexey.
> >
> > On Tue, Sep 30, 2008 at 11:30 AM, Alexey Zavizionov <
> >
> > [EMAIL PROTECTED]> wrote:
> > > Thanks for reply,
> > >
> > > NOTE: I have a listener which starts before MyCxfNonSpringServlet is
> > > deployed.
> > > All code for registering endpoint I moved to the listener.
> > >
> > > How can I register the servlets transport factory with the bus?
> > >
> > > Regards,
> > > Alexey.
> > >
> > > On Mon, Sep 29, 2008 at 8:36 PM, Daniel Kulp <[EMAIL PROTECTED]>
> wrote:
> > >> It looks like the servlets transport factory is not registered with
> > >> the bus.
> > >> Are you subclassing our CXFNonSpringServlet or similar to make sure
> > >> the appropriate transport is setup to handle that namespace?
> > >>
> > >> Dan
> > >>
> > >> On Monday 29 September 2008 5:26:39 am Alexey Zavizionov wrote:
> > >> > Hello list,
> > >> >
> > >> > I published services within test unit and in a servlet
> > >> > (nonspring) successfully with command "Endpoint.publish(address,
> > >> > object);".
> > >> >
> > >> > But, the same thing has failed within listener (in the Tomcat ).
> > >> >
> > >> > Does somebody have publish your service within listener?
> > >> >
> > >> > INFO: Creating Service
> > >> > {http://exoplatform.org/soap/cxf}TicketOrderServicefrom<http://exoplatform.org/soap/cxf%7DTicketOrderServicefrom>
> <http://ex
> > >> >oplatform.org/soap/cxf%7DTicketOrderServicefrom>class
> > >> > org.exoplatform.services.ws.soap.jsr181.TicketOrderService
> > >> > org.picocontainer.PicoIntrospectionException: Failed when calling
> > >> > start
> > >>
> > >> on
> > >>
> > >> > [EMAIL PROTECTED]
> > >> > at
> > >>
> > >>
> org.picocontainer.defaults.LifecycleVisitor.traverse(LifecycleVisitor.java:
> > >> >81) at
> > >>
> > >> org.picocontainer.defaults.LifecycleVisitor.start(LifecycleVisitor.
> > >>java:113
> > >>
> > >> >) at
> > >>
> > >> org.picocontainer.defaults.DefaultPicoContainer.start(DefaultPicoCo
> > >>ntainer.
> > >>
> > >> >java:369) at
> > >>
> > >> org.exoplatform.container.StandaloneContainer.getInstance(Standalon
> > >>eContain
> > >>
> > >> >er.java:124) at
> > >>
> > >> org.exoplatform.container.StandaloneContainer.getInstance(Standalon
> > >>eContain
> > >>
> > >> >er.java:91) at
> > >>
> > >> org.exoplatform.ws.frameworks.servlet.StandaloneContainerInitialize
> > >>dListene
> > >>
> > >> >r.contextInitialized(StandaloneContainerInitializedListener.java:7
> > >> >1) at
> > >>
> > >> org.apache.catalina.core.StandardContext.listenerStart(StandardCont
> > >>ext.java
> > >>
> > >> >:3827) at
> > >>
> > >> org.apache.catalina.core.StandardContext.start(StandardContext.java
> > >>:4336)
> > >>
> > >> > at
> > >>
> > >>
> org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:
> > >> >761) at
> > >> > org.apache.catalina.core.ContainerBase.addChild(ContainerBase.jav
> > >> >a:741) at
> > >> > org.apache.catalina.core.StandardHost.addChild(StandardHost.java:
> > >> >525) at
> > >>
> > >> org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.
> > >>java:626
> > >>
> > >> >) at
> > >>
> > >> org.apache.catalina.startup.HostConfig.deployDescriptors(HostConfig
> > >>.java:55
> > >>
> > >> >3) at
> > >> > org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java
> > >> >:488) at
> > >> > org.apache.catalina.startup.HostConfig.start(HostConfig.java:1138
> > >> >) at
> > >>
> > >> org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.ja
> > >>va:311)
> > >>
> > >> > at
> > >>
> > >> org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(Lifecy
> > >>cleSuppo
> > >>
> > >> >rt.java:120) at
> > >> > org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1
> > >> >023) at
> > >> > org.apache.catalina.core.StandardHost.start(StandardHost.java:719
> > >> >) at
> > >> > org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1
> > >> >015) at
> > >> > org.apache.catalina.core.StandardEngine.start(StandardEngine.java
> > >> >:443) at
> > >> > org.apache.catalina.core.StandardService.start(StandardService.ja
> > >> >va:448) at
> > >> > org.apache.catalina.core.StandardServer.start(StandardServer.java
> > >> >:710) at
> > >> > org.apache.catalina.startup.Catalina.start(Catalina.java:552) at
> > >> > sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at
> > >>
> > >> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImp
> > >>l.java:3
> > >>
> > >> >9) at
> > >>
> > >> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcc
> > >>essorImp
> > >>
> > >> >l.java:25) at java.lang.reflect.Method.invoke(Method.java:585)
> > >> > at
> > >>
> > >> org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288)
> > >>
> > >> > at
> > >>
> > >> org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)
> > >>
> > >> > Caused by: java.lang.RuntimeException: Could not find destination
> > >>
> > >> factory
> > >>
> > >> > for transport http://schemas.xmlsoap.org/soap/http
> > >> > at
> > >>
> > >> org.apache.cxf.binding.soap.SoapTransportFactory.getDestination(Soa
> > >>pTranspo
> > >>
> > >> >rtFactory.java:76) at
> > >> > org.apache.cxf.endpoint.ServerImpl.initDestination(ServerImpl.jav
> > >> >a:90) at
> > >> > org.apache.cxf.endpoint.ServerImpl.<init>(ServerImpl.java:69) at
> > >>
> > >> org.apache.cxf.frontend.ServerFactoryBean.create(ServerFactoryBean.
> > >>java:117
> > >>
> > >> >) at
> > >>
> > >> org.apache.cxf.jaxws.JaxWsServerFactoryBean.create(JaxWsServerFacto
> > >>ryBean.j
> > >>
> > >> >ava:168) at
> > >>
> > >> org.exoplatform.services.ws.impl.cxf.CXFUtils.complexDeployService(
> > >>CXFUtils
> > >>
> > >> >.java:83) at
> > >>
> > >> org.exoplatform.services.ws.impl.cxf.WebServiceLoader.start(WebServ
> > >>iceLoade
> > >>
> > >> >r.java:82) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native
> > >> > Method)
> > >>
> > >> at
> > >>
> > >> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImp
> > >>l.java:3
> > >>
> > >> >9) at
> > >>
> > >> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcc
> > >>essorImp
> > >>
> > >> >l.java:25) at java.lang.reflect.Method.invoke(Method.java:585)
> > >> > at
> > >>
> > >>
> org.picocontainer.defaults.LifecycleVisitor.traverse(LifecycleVisitor.java:
> > >> >75) ... 29 more
> > >> >
> > >> > Regards,
> > >> > Alexey.
> > >>
> > >> --
> > >> Daniel Kulp
> > >> [EMAIL PROTECTED]
> > >> http://www.dankulp.com/blog
>
>
>
> --
> J. Daniel Kulp
> Principal Engineer, IONA
> [EMAIL PROTECTED]
> http://www.dankulp.com/blog
>