You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by Neale Upstone <ne...@nealeupstone.com> on 2009/06/04 00:21:16 UTC

Strugging getting JAX-RS annotations working with CXF

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.DefaultListableBeanFactory@e06940: 
defining beans 
[cxf,org.apache.cxf.bus.spring.BusApplicationListener,org.apache.cxf.bus.spring.BusWiringBeanFactoryPostProcessor,org.apache.cxf.bus.spring.Jsr250BeanPostProcessor,org.apache.cxf.bus.spring.BusExtensionPostProcessor,org.apache.cxf.resource.ResourceManager,org.apache.cxf.configuration.Configurer,org.apache.cxf.binding.BindingFactoryManager,org.apache.cxf.transport.DestinationFactoryManager,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.http.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.transport.http.policy.HTTPServerAssertionBuilder,org.apache.cxf.transport.http.policy.NoOpPolicyInterceptorProvider,org.apache.cxf.transport.http.ClientOnlyHTTPTransportFactory]; 
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.java: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:39)
     at 
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.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.getDestinationFactory(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.java:84)
     ... 19 more







Re: Strugging getting JAX-RS annotations working with CXF

Posted by Sergey Beryozkin <sb...@progress.com>.
Hi Neale,

Can you clarify few things for me please.

>>> 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);
>>>

what is the value of BASE_URI.getPath() ?
Can you post a complete main() sample code which creates a selector and runs it ? So that I can quickly create a test code ?

>>>
>>> Result shows that my config is being read:
>>>
<snip/>
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
>>> *

So is http://localhost:9998/themes URI ia what you type in say a browser? or is 'BASE_URI' part missing here, as Dan suggested 
earlier on ?

thanks, Sergey


Re: Strugging getting JAX-RS annotations working with CXF

Posted by Neale Upstone <ne...@nealeupstone.com>.
Thanks.

The http-jetty jar dependency certainly solved the second one.

I'll look further at the first when I get back to the office tomorrow.

Cheers,

Neale


On 04/06/2009 16:08, Daniel Kulp wrote:
> 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.DefaultListableBeanFactory@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
>>      
>    

RE: Strugging getting JAX-RS annotations working with CXF

Posted by Sergey Beryozkin <sb...@progress.com>.
Hi

> >          selector = GrizzlyServerFactory.create(BASE_URI, adapter);

I may need to try to deploy CXF JAX-RS endpoints on Grizzly, I think
I've seen this error before, 

INFO: Setting the server's publish address to be /
> *WARNING: Can't find the request for http://localhost:9998/themes's
> Observer
> *

The request is not even reaching the JAX-RS runtime for some reasons.
  
> http://localhost:9998/(BASE_URI.getPath())/themes

As Dan suggested this can be the reason but I'm not sure either, it
might be that for some reasons base uri is somehow 'lost', possibly
because some sort of info which is typically available on sat Tomcat is
not there at Grizzly - I reckon I've seen it before, but I'll try it
some tome next week once I get back from a break

Cheers, Sergey

-----Original Message-----
From: Daniel Kulp [mailto:dkulp@apache.org] 
Sent: 04 June 2009 16:09
To: users@cxf.apache.org
Cc: Neale Upstone
Subject: Re: Strugging getting JAX-RS annotations working with CXF


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.DefaultListableBeanFactory@e06
940
>: defining beans
>
[cxf,org.apache.cxf.bus.spring.BusApplicationListener,org.apache.cxf.bus
.sp
>ring.BusWiringBeanFactoryPostProcessor,org.apache.cxf.bus.spring.Jsr250
BeanP
>ostProcessor,org.apache.cxf.bus.spring.BusExtensionPostProcessor,org.ap
ache.
>cxf.resource.ResourceManager,org.apache.cxf.configuration.Configurer,or
g.apa
>che.cxf.binding.BindingFactoryManager,org.apache.cxf.transport.Destinat
ionFa
>ctoryManager,org.apache.cxf.transport.ConduitInitiatorManager,org.apach
e.cxf
>.wsdl.WSDLManager,org.apache.cxf.phase.PhaseManager,org.apache.cxf.work
queue
>.WorkQueueManager,org.apache.cxf.buslifecycle.BusLifeCycleManager,org.a
pache
>.cxf.endpoint.ServerRegistry,org.apache.cxf.endpoint.ServerLifeCycleMan
ager,
>org.apache.cxf.endpoint.ClientLifeCycleManager,org.apache.cxf.transport
s.htt
>p.QueryHandlerRegistry,org.apache.cxf.endpoint.EndpointResolverRegistry
,org.
>apache.cxf.headers.HeaderManager,org.apache.cxf.catalog.OASISCatalogMan
ager,
>org.apache.cxf.endpoint.ServiceContractResolverRegistry,org.apache.cxf.
jaxrs
>.JAXRSBindingFactory,org.apache.cxf.binding.xml.XMLBindingFactory,org.a
pache
>.cxf.transport.http.policy.HTTPClientAssertionBuilder,org.apache.cxf.tr
anspo
>rt.http.policy.HTTPServerAssertionBuilder,org.apache.cxf.transport.http
.poli
>cy.NoOpPolicyInterceptorProvider,org.apache.cxf.transport.http.ClientOn
lyHTT
>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(JAXRSServerFactoryBea
n.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.jav
a:3
>9) at
>
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessor
Imp
>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.getDestinationFac
tor
>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(JAXRSServerFactoryBea
n.j
>ava:84) ... 19 more

-- 
Daniel Kulp
dkulp@apache.org
http://www.dankulp.com/blog

Re: Strugging getting JAX-RS annotations working with CXF

Posted by Daniel Kulp <dk...@apache.org>.
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.DefaultListableBeanFactory@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
dkulp@apache.org
http://www.dankulp.com/blog

Re: Strugging getting JAX-RS annotations working with CXF

Posted by Gabo Manuel <km...@solegysystems.com>.
Hi Neale,

This might be similar to this case:

http://www.nabble.com/After-updating-to-2.1.4:-No-DestinationFactory-was-found-for-the-namespace-http:--schemas.xmlsoap.org-soap-http-td21952242.html

or this:

http://mail-archives.apache.org/mod_mbox/cxf-issues/200806.mbox/%3C1323583532.1213085265096.JavaMail.jira@brutus%3E

Both cases mention the need for including 
cxf-rt-transports-http-jetty.jar in the classpath

Hth.

Gabo

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.DefaultListableBeanFactory@e06940: 
> defining beans 
> [cxf,org.apache.cxf.bus.spring.BusApplicationListener,org.apache.cxf.bus.spring.BusWiringBeanFactoryPostProcessor,org.apache.cxf.bus.spring.Jsr250BeanPostProcessor,org.apache.cxf.bus.spring.BusExtensionPostProcessor,org.apache.cxf.resource.ResourceManager,org.apache.cxf.configuration.Configurer,org.apache.cxf.binding.BindingFactoryManager,org.apache.cxf.transport.DestinationFactoryManager,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.http.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.transport.http.policy.HTTPServerAssertionBuilder,org.apache.cxf.transport.http.policy.NoOpPolicyInterceptorProvider,org.apache.cxf.transport.http.ClientOnlyHTTPTransportFactory]; 
> 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.java: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:39) 
>
>     at 
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.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.getDestinationFactory(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.java:84) 
>
>     ... 19 more
>
>
>
>
>
>
>
> ------------------------------------------------------------------------
>
>
> No virus found in this incoming message.
> Checked by AVG - www.avg.com 
> Version: 8.5.339 / Virus Database: 270.12.52/2152 - Release Date: 06/03/09 05:53:00
>
>