You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by Brice <br...@gmail.com> on 2008/06/30 00:32:30 UTC

Problems / Solution / Questions about setting up a CXF 2.1(.1) service

Hi folks,

I wanted to give a try to the JSR311 implementation of CXF, and I'm having
several issues to get it done properly.

I'm using it in a maven project, right now I want to try it in a standalone
application using J2SE 6. I was following the wiki pages there  ->
http://cwiki.apache.org/CXF20DOC/jax-rs-jsr-311.html <-

I have set this dependencies in the pom.xml
============================================
        <dependency>
            <groupId>org.apache.cxf</groupId>
            <artifactId>cxf-rt-frontend-jaxrs</artifactId>
            <version>2.1.1</version>
        </dependency>
        <dependency>
            <groupId>org.apache.cxf</groupId>
            <artifactId>cxf-rt-transports-http</artifactId>
            <version>2.1.1</version>
        </dependency>
        <dependency>
            <groupId>org.apache.cxf</groupId>
            <artifactId>cxf-rt-bindings-http</artifactId>
            <version>2.1.1</version>
        </dependency>
        <!-- Jetty is needed if you're are not using the CXFServlet -->
        <dependency>
            <groupId>org.apache.cxf</groupId>
            <artifactId>cxf-rt-transports-http-jetty</artifactId>
            <version>2.1.1</version>
        </dependency>
============================================

My server is set up the created with the following lines
============================================
        final JAXRSServerFactoryBean sf = new JAXRSServerFactoryBean();
        sf.setResourceClasses(RestService.class);
        sf.setResourceProvider(RestServer.class, new
SingletonResourceProvider(new RestServer()));
        sf.setAddress("http://localhost:9000/");
        final Server s = sf.create();
============================================

Then "s" is given to a thread, in order to keep alive the reference. May
server is run with the classic main call.

The server seems to load fine.
============================================
29 juin 2008 23:51:06
org.springframework.context.support.AbstractApplicationContext
prepareRefresh
INFO: Refreshing org.apache.cxf.bus.spring.BusApplicationContext@1729854:
display name [org.apache.cxf.bus.spring.BusApplicationContext@1729854];
startup date [Sun Jun 29 23:51:06 CEST 2008]; root of context hierarchy
29 juin 2008 23:51:06 org.apache.cxf.bus.spring.BusApplicationContext
getConfigResources
INFO: No cxf.xml configuration file detected, relying on defaults.
29 juin 2008 23:51:06
org.springframework.beans.factory.xml.XmlBeanDefinitionReader
loadBeanDefinitions
INFO: Loading XML bean definitions from class path resource
[META-INF/cxf/cxf.xml]
29 juin 2008 23:51:06
org.springframework.beans.factory.xml.XmlBeanDefinitionReader
loadBeanDefinitions
INFO: Loading XML bean definitions from class path resource
[META-INF/cxf/cxf-extension-jaxrs-binding.xml]
29 juin 2008 23:51:06
org.springframework.beans.factory.xml.XmlBeanDefinitionReader
loadBeanDefinitions
INFO: Loading XML bean definitions from class path resource
[META-INF/cxf/cxf-extension-xml.xml]
29 juin 2008 23:51:06
org.springframework.beans.factory.xml.XmlBeanDefinitionReader
loadBeanDefinitions
INFO: Loading XML bean definitions from class path resource
[META-INF/cxf/cxf-extension-addr.xml]
29 juin 2008 23:51:06
org.springframework.beans.factory.xml.XmlBeanDefinitionReader
loadBeanDefinitions
INFO: Loading XML bean definitions from class path resource
[META-INF/cxf/cxf-extension-http-binding.xml]
29 juin 2008 23:51:06
org.springframework.beans.factory.xml.XmlBeanDefinitionReader
loadBeanDefinitions
INFO: Loading XML bean definitions from class path resource
[META-INF/cxf/cxf-extension-http.xml]
29 juin 2008 23:51:06
org.springframework.beans.factory.xml.XmlBeanDefinitionReader
loadBeanDefinitions
INFO: Loading XML bean definitions from class path resource
[META-INF/cxf/cxf-extension-soap.xml]
29 juin 2008 23:51:06
org.springframework.beans.factory.xml.XmlBeanDefinitionReader
loadBeanDefinitions
INFO: Loading XML bean definitions from class path resource
[META-INF/cxf/cxf-extension-http-jetty.xml]
29 juin 2008 23:51:06
org.springframework.beans.factory.xml.XmlBeanDefinitionReader
loadBeanDefinitions
INFO: Loading XML bean definitions from class path resource
[META-INF/cxf/cxf-extension-http.xml]
29 juin 2008 23:51:06
org.springframework.beans.factory.support.DefaultListableBeanFactory
registerBeanDefinition
INFO: Overriding bean definition for bean
'org.apache.cxf.transport.http.policy.HTTPClientAssertionBuilder': replacing
[Generic bean: class
[org.apache.cxf.transport.http.policy.HTTPClientAssertionBuilder];
scope=singleton; abstract=false; lazyInit=false; autowireMode=0;
dependencyCheck=0; autowireCandidate=true; primary=false;
factoryBeanName=null; factoryMethodName=null; initMethodName=null;
destroyMethodName=null; defined in class path resource
[META-INF/cxf/cxf-extension-http.xml]] with [Generic bean: class
[org.apache.cxf.transport.http.policy.HTTPClientAssertionBuilder];
scope=singleton; abstract=false; lazyInit=false; autowireMode=0;
dependencyCheck=0; autowireCandidate=true; primary=false;
factoryBeanName=null; factoryMethodName=null; initMethodName=null;
destroyMethodName=null; defined in class path resource
[META-INF/cxf/cxf-extension-http.xml]]
29 juin 2008 23:51:06
org.springframework.beans.factory.support.DefaultListableBeanFactory
registerBeanDefinition
INFO: Overriding bean definition for bean
'org.apache.cxf.transport.http.policy.HTTPServerAssertionBuilder': replacing
[Generic bean: class
[org.apache.cxf.transport.http.policy.HTTPServerAssertionBuilder];
scope=singleton; abstract=false; lazyInit=false; autowireMode=0;
dependencyCheck=0; autowireCandidate=true; primary=false;
factoryBeanName=null; factoryMethodName=null; initMethodName=null;
destroyMethodName=null; defined in class path resource
[META-INF/cxf/cxf-extension-http.xml]] with [Generic bean: class
[org.apache.cxf.transport.http.policy.HTTPServerAssertionBuilder];
scope=singleton; abstract=false; lazyInit=false; autowireMode=0;
dependencyCheck=0; autowireCandidate=true; primary=false;
factoryBeanName=null; factoryMethodName=null; initMethodName=null;
destroyMethodName=null; defined in class path resource
[META-INF/cxf/cxf-extension-http.xml]]
29 juin 2008 23:51:06
org.springframework.beans.factory.support.DefaultListableBeanFactory
registerBeanDefinition
INFO: Overriding bean definition for bean
'org.apache.cxf.transport.http.policy.NoOpPolicyInterceptorProvider':
replacing [Generic bean: class
[org.apache.cxf.transport.http.policy.NoOpPolicyInterceptorProvider];
scope=singleton; abstract=false; lazyInit=false; autowireMode=0;
dependencyCheck=0; autowireCandidate=true; primary=false;
factoryBeanName=null; factoryMethodName=null; initMethodName=null;
destroyMethodName=null; defined in class path resource
[META-INF/cxf/cxf-extension-http.xml]] with [Generic bean: class
[org.apache.cxf.transport.http.policy.NoOpPolicyInterceptorProvider];
scope=singleton; abstract=false; lazyInit=false; autowireMode=0;
dependencyCheck=0; autowireCandidate=true; primary=false;
factoryBeanName=null; factoryMethodName=null; initMethodName=null;
destroyMethodName=null; defined in class path resource
[META-INF/cxf/cxf-extension-http.xml]]
29 juin 2008 23:51:06
org.springframework.beans.factory.support.DefaultListableBeanFactory
registerBeanDefinition
INFO: Overriding bean definition for bean
'org.apache.cxf.transport.http.ClientOnlyHTTPTransportFactory': replacing
[Generic bean: class
[org.apache.cxf.transport.http.ClientOnlyHTTPTransportFactory];
scope=singleton; abstract=false; lazyInit=true; autowireMode=0;
dependencyCheck=0; autowireCandidate=true; primary=false;
factoryBeanName=null; factoryMethodName=null; initMethodName=null;
destroyMethodName=null; defined in class path resource
[META-INF/cxf/cxf-extension-http.xml]] with [Generic bean: class
[org.apache.cxf.transport.http.ClientOnlyHTTPTransportFactory];
scope=singleton; abstract=false; lazyInit=true; autowireMode=0;
dependencyCheck=0; autowireCandidate=true; primary=false;
factoryBeanName=null; factoryMethodName=null; initMethodName=null;
destroyMethodName=null; defined in class path resource
[META-INF/cxf/cxf-extension-http.xml]]
29 juin 2008 23:51:06
org.springframework.beans.factory.xml.XmlBeanDefinitionReader
loadBeanDefinitions
INFO: Loading XML bean definitions from class path resource
[META-INF/cxf/cxf-extension-jaxws.xml]
29 juin 2008 23:51:06
org.springframework.context.support.AbstractApplicationContext
obtainFreshBeanFactory
INFO: Bean factory for application context
[org.apache.cxf.bus.spring.BusApplicationContext@1729854]:
org.springframework.beans.factory.support.DefaultListableBeanFactory@f0c0d3
29 juin 2008 23:51:06
org.springframework.context.support.AbstractApplicationContext$BeanPostProcessorChecker
postProcessAfterInitialization
INFO: Bean 'org.apache.cxf.bus.spring.Jsr250BeanPostProcessor' is not
eligible for getting processed by all BeanPostProcessors (for example: not
eligible for auto-proxying)
29 juin 2008 23:51:06
org.springframework.context.support.AbstractApplicationContext$BeanPostProcessorChecker
postProcessAfterInitialization
INFO: Bean 'org.apache.cxf.bus.spring.BusExtensionPostProcessor' is not
eligible for getting processed by all BeanPostProcessors (for example: not
eligible for auto-proxying)
29 juin 2008 23:51:06
org.springframework.beans.factory.support.DefaultListableBeanFactory
preInstantiateSingletons
INFO: Pre-instantiating singletons in
org.springframework.beans.factory.support.DefaultListableBeanFactory@f0c0d3:
defining beans
[cxf,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.ws.addressing.policy.AddressingAssertionBuilder,org.apache.cxf.ws.addressing.policy.AddressingPolicyInterceptorProvider,org.apache.cxf.ws.addressing.policy.UsingAddressingAssertionBuilder,org.apache.cxf.binding.http.HttpBindingFactory,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,org.apache.cxf.binding.soap.SoapBindingFactory,org.apache.cxf.binding.soap.SoapTransportFactory,org.apache.cxf.binding.soap.customEditorConfigurer,org.apache.cxf.transport.http_jetty.JettyHTTPTransportFactory,org.apache.cxf.jaxws.context.WebServiceContextResourceResolver,org.apache.cxf.jaxws.context.WebServiceContextImpl];
root of factory hierarchy
29 juin 2008 23:51:07 org.apache.cxf.endpoint.ServerImpl initDestination
INFO: Setting the server's publish address to be http://localhost:9000/
29 juin 2008 23:51:07 sun.reflect.NativeMethodAccessorImpl invoke0
INFO: Logging to org.slf4j.impl.JDK14LoggerAdapter(org.mortbay.log) via
org.mortbay.log.Slf4jLog
29 juin 2008 23:51:07 sun.reflect.NativeMethodAccessorImpl invoke0
INFO: jetty-6.1.9
29 juin 2008 23:51:07 sun.reflect.NativeMethodAccessorImpl invoke0
INFO: Started SelectChannelConnector@0.0.0.0:9000
============================================


Then on the first invocation :
http://localhost:9000/customerrestservice?name=bob

============================================
29 juin 2008 23:13:13 sun.reflect.NativeMethodAccessorImpl invoke0
GRAVE: EXCEPTION
java.lang.NoClassDefFoundError:
org/apache/axiom/om/impl/llom/factory/OMLinkedListImplFactory
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClass(Unknown Source)
    at java.security.SecureClassLoader.defineClass(Unknown Source)
    at java.net.URLClassLoader.defineClass(Unknown Source)
    at java.net.URLClassLoader.access$000(Unknown Source)
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at
org.apache.abdera.util.ServiceUtil.locateInstance(ServiceUtil.java:228)
    at
org.apache.abdera.util.ServiceUtil.locateInstance(ServiceUtil.java:222)
    at org.apache.abdera.util.ServiceUtil.locate(ServiceUtil.java:144)
    at org.apache.abdera.util.ServiceUtil.newInstance(ServiceUtil.java:58)
    at
org.apache.abdera.util.ServiceUtil.newFactoryInstance(ServiceUtil.java:97)
    at
org.apache.abdera.util.AbderaConfiguration.newFactoryInstance(AbderaConfiguration.java:273)
    at org.apache.abdera.Abdera.newFactory(Abdera.java:210)
    at org.apache.abdera.Abdera.<init>(Abdera.java:90)
    at org.apache.abdera.Abdera.<init>(Abdera.java:81)
    at
org.apache.cxf.jaxrs.provider.AtomFeedProvider.<clinit>(AtomFeedProvider.java:46)
    at
org.apache.cxf.jaxrs.provider.ProviderFactory.<init>(ProviderFactory.java:49)
    at
org.apache.cxf.jaxrs.provider.ProviderFactory.<clinit>(ProviderFactory.java:38)
    at
org.apache.cxf.jaxrs.interceptor.JAXRSInInterceptor.handleMessage(JAXRSInInterceptor.java:86)
    at
org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:221)
    at
org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:78)
    at
org.apache.cxf.transport.http_jetty.JettyHTTPDestination.serviceRequest(JettyHTTPDestination.java:278)
    at
org.apache.cxf.transport.http_jetty.JettyHTTPDestination.doService(JettyHTTPDestination.java:252)
    at
org.apache.cxf.transport.http_jetty.JettyHTTPHandler.handle(JettyHTTPHandler.java:70)
    at
org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:726)
    at
org.mortbay.jetty.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:206)
    at
org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
    at org.mortbay.jetty.Server.handle(Server.java:324)
    at
org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:505)
    at
org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:828)
    at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:514)
    at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:211)
    at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:380)
    at
org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:395)
    at
org.mortbay.thread.BoundedThreadPool$PoolThread.run(BoundedThreadPool.java:450)
Caused by: java.lang.ClassNotFoundException:
org.apache.axiom.om.impl.llom.factory.OMLinkedListImplFactory
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClassInternal(Unknown Source)
    ... 40 more
============================================

OK, big problem here, not every dependencies are here.

While searching I found this topic  ->
http://www.nabble.com/REST-problems-td17380359.html  <- , the guy Mathew
said he resolved the problem by adding those dependencies :
============================================
        <!-- Missing dependencies Fix -->
        <dependency>
            <groupId>ws-commons</groupId>
            <artifactId>axiom</artifactId>
            <version>1.1.1</version>
        </dependency>

        <dependency>
            <groupId>org.apache.abdera</groupId>
            <artifactId>abdera-client</artifactId>
            <version>0.4.0-incubating</version>
        </dependency>
        <dependency>
            <groupId>org.apache.abdera</groupId>
            <artifactId>abdera-server</artifactId>
            <version>0.4.0-incubating</version>
        </dependency>
        <dependency>
            <groupId>org.apache.abdera</groupId>
            <artifactId>abdera-spring</artifactId>
            <version>0.4.0-incubating</version>
        </dependency>
============================================
Unfortunately abdera dependencies are not on the main maven repository :  ->
http://repo1.maven.org/maven2/org/apache/ <-

I overcame the problem by adding this repository to my main POM:
============================================
    <repositories>
        <repository>
            <id>apache-incubating</id>
            <name>Apache Incubating Repository</name>
            <url>http://people.apache.org/repo/m2-incubating-repository/
</url>
        </repository>
    </repositories>
============================================



Isn't it problematic for a project which is not anymore in an incubating
state to rely on incubating dependencies, and not even on the main
repository. I think it should avoided, or at least it should be mentioned in
the wiki!


-- 
Brice Dutheil