[undertow-dev] Undertow + CXF + Spring single JAR

Stuart Douglas sdouglas at redhat.com
Tue May 6 22:15:55 EDT 2014


Can you post the code that you are using? Ideally as a github project I 
can try out?

Off the top of my head the only thing I can think of is that maybe it is 
something to do with the ResourceManager setup. ResourceManager is used 
to resolve files in a war, so if a ResourceManager is not set CXF may 
not be able to find a config file it is after.

Stuart

Aleksandar Vidakovic wrote:
> Hi,
>
> ... I tried to package a CXF project with fairly standard WAR setup
> (CXFServlet in web.xml configured) and some additional Spring
> configuration (nothing fancy) in a single JAR (with Maven Shade plugin).
>
> 99% is working (Undertow is starting, Spring context gets initialized),
> but CXF has a problem picking up a transport. I thought that it would
> just behave the same like in a servlet container environment, but
> apparently something is missing.
>
> This is the exception that I get:
>
> [console]
>
> Exception in thread "main"
> org.springframework.beans.factory.BeanCreationException: Error creating
> bean with name
> 'org.apache.cxf.jaxrs.spring.JAXRSServerFactoryBeanDefinitionParser$SpringJAXRSServerFactoryBean---72839183':
> Invocation of init method failed; nested exception is
> org.apache.cxf.service.factory.ServiceConstructionException
>       at
> org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1553)
>       at
> org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:539)
>       at
> org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:475)
>       at
> org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:304)
>       at
> org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:228)
>       at
> org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:300)
>       at
> org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:195)
>       at
> org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:703)
>       at
> org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:760)
>       at
> org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:482)
>       at
> org.apache.cxf.transport.servlet.CXFServlet.createSpringContext(CXFServlet.java:151)
>       at
> org.apache.cxf.transport.servlet.CXFServlet.loadBus(CXFServlet.java:74)
>       at
> org.apache.cxf.transport.servlet.CXFNonSpringServlet.init(CXFNonSpringServlet.java:76)
>       at
> io.undertow.servlet.core.ManagedServlet$DefaultInstanceStrategy.start(ManagedServlet.java:214)
>       at
> io.undertow.servlet.core.ManagedServlet.createServlet(ManagedServlet.java:119)
>       at
> io.undertow.servlet.core.DeploymentManagerImpl.start(DeploymentManagerImpl.java:501)
>       at com.hotlabuyo.rest.server.Main.main(Main.java:51)
> Caused by: org.apache.cxf.service.factory.ServiceConstructionException
>       at
> org.apache.cxf.jaxrs.JAXRSServerFactoryBean.create(JAXRSServerFactoryBean.java:205)
>       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>       at
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
>       at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
>       at java.lang.reflect.Method.invoke(Method.java:483)
>       at
> org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeCustomInitMethod(AbstractAutowireCapableBeanFactory.java:1681)
>       at
> org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1620)
>       at
> org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1549)
>       ... 16 more
> 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:122)
>       at
> org.apache.cxf.endpoint.ServerImpl.initDestination(ServerImpl.java:79)
>       at org.apache.cxf.endpoint.ServerImpl.<init>(ServerImpl.java:63)
>       at
> org.apache.cxf.jaxrs.JAXRSServerFactoryBean.create(JAXRSServerFactoryBean.java:160)
>       ... 23 more
>
> [/console]
>
> ... and the relevant piece of configuration for CXF looks like this:
>
> [config]
>
> ...
>
>       <import resource="classpath:META-INF/cxf/cxf.xml" />
>       <import resource="classpath:META-INF/cxf/cxf-servlet.xml" />
>       <import resource="classpath:META-INF/cxf/cxf-extension-*.xml" />
>
> ...
>
> [/config]
>
> Any help with this would be much appreciated.
>
> Thanks in advance and cheers,
>
> Aleks
> _______________________________________________
> undertow-dev mailing list
> undertow-dev at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/undertow-dev


More information about the undertow-dev mailing list