In the second case, you would need to add the cxf-rt-transport-http-jetty jar to the classpath. If you aren't using a servlet, you need some sort of http server which the jetty implementation provides.
In the first case, I think the URL is probably wrong, but not really sure. What is the BASE_URI.getPath()? I think it would be: http://localhost:9998/(BASE_URI.getPath())/themes Dan On Wed June 3 2009 6:21:16 pm Neale Upstone wrote: > Hi, > > Progress sounds really great on the blog, but I'm struggling with > getting the basics up and running with CXF 2.2.2. > > I have a service which happily runs with Jersey, but I'm struggling with > getting it up and running under CXF. > > I'm baffled as to what I'm doing wrong... > > > > The service starts as follows: > > @Path("/themes") > public class Service { > ... > > > and I've tried two CXF approaches to publishing it: > > 1) > > final ServletAdapter adapter = new ServletAdapter(); > adapter.addInitParameter( "config-location", "cxf-beans.xml" ); > > adapter.setServletInstance( new CXFServlet() ); > adapter.setContextPath( BASE_URI.getPath() ); > selector = GrizzlyServerFactory.create(BASE_URI, adapter); > > > Result shows that my config is being read: > > INFO: Pre-instantiating singletons in > org.springframework.beans.factory.support.defaultlistablebeanfact...@e06940 >: defining beans > [cxf,org.apache.cxf.bus.spring.BusApplicationListener,org.apache.cxf.bus.sp >ring.BusWiringBeanFactoryPostProcessor,org.apache.cxf.bus.spring.Jsr250BeanP >ostProcessor,org.apache.cxf.bus.spring.BusExtensionPostProcessor,org.apache. >cxf.resource.ResourceManager,org.apache.cxf.configuration.Configurer,org.apa >che.cxf.binding.BindingFactoryManager,org.apache.cxf.transport.DestinationFa >ctoryManager,org.apache.cxf.transport.ConduitInitiatorManager,org.apache.cxf >.wsdl.WSDLManager,org.apache.cxf.phase.PhaseManager,org.apache.cxf.workqueue >.WorkQueueManager,org.apache.cxf.buslifecycle.BusLifeCycleManager,org.apache >.cxf.endpoint.ServerRegistry,org.apache.cxf.endpoint.ServerLifeCycleManager, >org.apache.cxf.endpoint.ClientLifeCycleManager,org.apache.cxf.transports.htt >p.QueryHandlerRegistry,org.apache.cxf.endpoint.EndpointResolverRegistry,org. >apache.cxf.headers.HeaderManager,org.apache.cxf.catalog.OASISCatalogManager, >org.apache.cxf.endpoint.ServiceContractResolverRegistry,org.apache.cxf.jaxrs >.JAXRSBindingFactory,org.apache.cxf.binding.xml.XMLBindingFactory,org.apache >.cxf.transport.http.policy.HTTPClientAssertionBuilder,org.apache.cxf.transpo >rt.http.policy.HTTPServerAssertionBuilder,org.apache.cxf.transport.http.poli >cy.NoOpPolicyInterceptorProvider,org.apache.cxf.transport.http.ClientOnlyHTT >PTransportFactory]; root of factory hierarchy > INFO: Replaced the http destination factory with servlet transport factory > INFO: Build endpoints from config-location: cxf-beans.xml > > where cxf-beans.xml is as per the example: > > <beans ...> > <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-servlet.xml" /> > > <jaxrs:server id="server" address="/"> <!-- also tried /themes --> > <jaxrs:serviceBeans> > <ref bean="service" /> > </jaxrs:serviceBeans> > </jaxrs:server> > > <bean id="service" class="x.x.Service" /> > </beans> > > But attempts to read give the following log: > > INFO: Setting the server's publish address to be / > *WARNING: Can't find the request for http://localhost:9998/themes's > Observer > * > > > 2) I also tried the simpler: > > Service service = new Service(); > > JAXRSServerFactoryBean sf = new JAXRSServerFactoryBean(); > sf.setServiceBeans(service); // also tried: > sf.setResourceClasses(Service.class); > sf.setBindingId(JAXRSBindingFactory.JAXRS_BINDING_ID); > sf.setAddress(sf.setAddress("http://localhost:9998/"); > sf.create(); > > > The result here is that sf.create() fails with the following exception: > > org.apache.cxf.service.factory.ServiceConstructionException > at > org.apache.cxf.jaxrs.JAXRSServerFactoryBean.create(JAXRSServerFactoryBean.j >ava:108) at ucles.themes.rest.Server.startCXF(Server.java:86) > at ucles.themes.rest.Server.<init>(Server.java:29) > at ucles.themes.rest.ThemeTest.setUpServer(ThemeTest.java:52) > at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) > at > sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:3 >9) at > sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImp >l.java:25) at java.lang.reflect.Method.invoke(Method.java:585) > ... > Caused by: org.apache.cxf.BusException: No DestinationFactory was found > for the namespace http://schemas.xmlsoap.org/wsdl/soap/http. > at > org.apache.cxf.transport.DestinationFactoryManagerImpl.getDestinationFactor >y(DestinationFactoryManagerImpl.java:115) at > org.apache.cxf.endpoint.ServerImpl.initDestination(ServerImpl.java:85) > at org.apache.cxf.endpoint.ServerImpl.<init>(ServerImpl.java:69) > at > org.apache.cxf.jaxrs.JAXRSServerFactoryBean.create(JAXRSServerFactoryBean.j >ava:84) ... 19 more -- Daniel Kulp [email protected] http://www.dankulp.com/blog
