I only copied the source from the demo, I put it into my own project and added the maven assembly plugin so all my dependencies were bundled into a single jar.
On Mon, Jun 30, 2014 at 6:14 AM, Sergey Beryozkin <[email protected]> wrote: > Hi > > On 30/06/14 11:08, Chris Bud wrote: > >> Thanks Sergey, I was able to start the server with both transports-http >> and >> transports-http-jetty on the classpath.. What I don't understand is why >> this works but with those bundled into a single jar it does not. >> >> The demo build produces a jar with the demo classes only. > > Cheers, Sergey > >> >> On Mon, Jun 30, 2014 at 5:56 AM, Sergey Beryozkin <[email protected]> >> wrote: >> >> Sorry, I was wrong, it is a jar after all. The demo is not meant to be >>> deployed into the container, and a such having a CXF http-jetty transport >>> Maven dependency is sufficient. >>> You can't have it run from java directly, actually you probably can if >>> you >>> update a classpath to reference a cxf-rt-transport-http-jetty jar shipped >>> in the distribution. >>> >>> Cheers, Sergey >>> >>> >>> >>> On 30/06/14 10:49, Chris Bud wrote: >>> >>> Hi Sergey, >>>> >>>> Thanks for the link I tried to implement but still produces the same >>>> error. >>>> >>>> >>>> java -cp target/sample-service-1.0-jar-with-dependencies.jar >>>> com.crush.tests.service.Test >>>> Exception in thread "main" >>>> org.apache.cxf.service.factory.ServiceConstructionException >>>> at >>>> org.apache.cxf.jaxrs.JAXRSServerFactoryBean.create( >>>> JAXRSServerFactoryBean.java:205) >>>> at com.crush.tests.service.Test.<init>(Test.java:27) >>>> at com.crush.tests.service.Test.main(Test.java:32) >>>> Caused by: org.apache.cxf.BusException: No DestinationFactory was found >>>> for >>>> the namespace http://cxf.apache.org/transports/http. >>>> at >>>> org.apache.cxf.bus.managers.DestinationFactoryManagerImpl. >>>> getDestinationFactory(DestinationFactoryManagerImpl.java:130) >>>> at org.apache.cxf.endpoint.ServerImpl.initDestination( >>>> ServerImpl.java:78) >>>> at org.apache.cxf.endpoint.ServerImpl.<init>(ServerImpl.java:62) >>>> at >>>> org.apache.cxf.jaxrs.JAXRSServerFactoryBean.create( >>>> JAXRSServerFactoryBean.java:159) >>>> ... 2 more >>>> >>>> My Test source >>>> public class Test >>>> { >>>> >>>> protected Test() throws Exception >>>> { >>>> JAXRSServerFactoryBean sf = new JAXRSServerFactoryBean(); >>>> sf.setResourceClasses(SampleServiceImpl.class); >>>> sf.setResourceProvider(SampleServiceImpl.class, >>>> new SingletonResourceProvider(new SampleServiceImpl())); >>>> sf.setAddress("http://localhost:9000/"); >>>> >>>> BindingFactoryManager manager = >>>> sf.getBus().getExtension(BindingFactoryManager.class); >>>> JAXRSBindingFactory factory = new JAXRSBindingFactory(); >>>> factory.setBus(sf.getBus()); >>>> manager.registerBindingFactory(JAXRSBindingFactory.JAXRS_BINDING_ID, >>>> factory); >>>> >>>> >>>> sf.create(); >>>> } >>>> >>>> public static void main(String[] args) throws Exception >>>> { >>>> new Test(); >>>> System.out.println("Server ready..."); >>>> Thread.sleep(5 * 6000 * 1000); >>>> System.out.println("Server exiting"); >>>> System.exit(0); >>>> >>>> } >>>> } >>>> >>>> Any other thoughts? >>>> >>>> >>>> On Fri, Jun 27, 2014 at 5:07 PM, Sergey Beryozkin <[email protected] >>>> > >>>> wrote: >>>> >>>> Hi >>>> >>>>> >>>>> On 27/06/14 17:51, Chris Bud wrote: >>>>> >>>>> Hi All, >>>>> >>>>>> >>>>>> I'm trying to build a basic jax-rs example using version 2.7.11. >>>>>> Using >>>>>> the >>>>>> server and service code from the example code >>>>>> <http://svn.apache.org/viewvc/cxf/trunk/distribution/src/ >>>>>> main/release/samples/jax_rs/basic/>, >>>>>> >>>>>> I can build and run it just like the readme instructions say (mvn >>>>>> -Pserver) >>>>>> but if I produce a jar bundled with the dependencies and run from the >>>>>> command line I cannot get the server to start. I get the following >>>>>> exception >>>>>> >>>>>> test-service/target$ java -cp test-service-1.0-jar-with- >>>>>> dependencies.jar >>>>>> com.test.Server >>>>>> Exception in thread "main" >>>>>> org.apache.cxf.service.factory.ServiceConstructionException >>>>>> at >>>>>> org.apache.cxf.jaxrs.JAXRSServerFactoryBean.create( >>>>>> JAXRSServerFactoryBean.java:190) >>>>>> at com.test.Server.<init>(Server.java:24) >>>>>> at com.test.Server.main(Server.java:29) >>>>>> Caused by: org.apache.cxf.BusException: No DestinationFactory was >>>>>> found >>>>>> for >>>>>> the namespace http://cxf.apache.org/transports/http. >>>>>> at >>>>>> org.apache.cxf.bus.managers.DestinationFactoryManagerImpl. >>>>>> getDestinationFactory(DestinationFactoryManagerImpl.java:130) >>>>>> at org.apache.cxf.endpoint.ServerImpl.initDestination( >>>>>> ServerImpl.java:78) >>>>>> at org.apache.cxf.endpoint.ServerImpl.<init>(ServerImpl.java:62) >>>>>> at >>>>>> org.apache.cxf.jaxrs.JAXRSServerFactoryBean.create( >>>>>> JAXRSServerFactoryBean.java:151) >>>>>> ... 2 more >>>>>> >>>>>> Can anyone point me in the right direction? >>>>>> >>>>>> It appears that when running a packaged Jetty based demo the >>>>>> following >>>>>> >>>>>> has to be done: >>>>> >>>>> http://cxf.apache.org/docs/jaxrs-services-configuration.html# >>>>> JAXRSServicesConfiguration-ConfiguringJAX- >>>>> RSendpointsprogrammaticallywit >>>>> houtSpring >>>>> >>>>> Please see the lines related to registering binding id/factory >>>>> >>>>> Can you please update Server accordingly, recompile and retry ? >>>>> >>>>> Cheers, Sergey >>>>> >>>>> Thanks, >>>>> >>>>> Chris >>>>>> >>>>>> >>>>>> >>>>>> -- >>>>> Sergey Beryozkin >>>>> >>>>> Talend Community Coders >>>>> http://coders.talend.com/ >>>>> >>>>> Blog: http://sberyozkin.blogspot.com >>>>> >>>>> >>>>> >>>> >>> -- >>> Sergey Beryozkin >>> >>> Talend Community Coders >>> http://coders.talend.com/ >>> >>> Blog: http://sberyozkin.blogspot.com >>> >>> >> > > -- > Sergey Beryozkin > > Talend Community Coders > http://coders.talend.com/ > > Blog: http://sberyozkin.blogspot.com >
