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