... ah, I think

META-INF/cxf/bus-extensions.txt

... is missing... will try this and post the results here. I think I have to add some additional include rules in Maven Shade...

As for the reason why I do this: just to have an easy to distribute single purpose service (there'll be more of those)... previously I had a WAR file packaged with Jetty Distribution as .tar.gz, then I created a Jetty Standalone service (similar to this approach) and finally I just wanted to do the same with Undertow.io (the benchmarks look promising). Either way, all three approaches are fine, just have a preference for the single JAR as they are included in a Docker configuration... and this way it only takes a line in the Dockerfile ;-)

If you are asking why Maven Shade is used: it just does the Job very nicely... especially merging all the Spring schema and handler files.

Thanks again for the hint.

Cheers,

Aleks

On 04.05.2014 09:26, Andrei Shakirin wrote:
Hi,

Normally this stack trace is caused by missing cxf-rt-transports-http-xxx.jar 
on the classpath.
Either the class HTTPTransportFactory.class or META-INF/cxf/bus-extensions.txt 
is not in your jar.

Out of curiosity: what is the reason to compose CXF and Spring in single jar 
using Maven Shade?

Regards,
Andrei.

-----Original Message-----
From: Aleksandar Vidakovic [mailto:[email protected]]
Sent: Sonntag, 4. Mai 2014 01:04
To: [email protected]
Subject: Undertow + CXF + Spring single JAR

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 way 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$SpringJA
XRSServerFactoryBean---72839183':
Invocation of init method failed; nested exception is
org.apache.cxf.service.factory.ServiceConstructionException
       at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFact
ory.initializeBean(AbstractAutowireCapableBeanFactory.java:1553)
       at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFact
ory.doCreateBean(AbstractAutowireCapableBeanFactory.java:539)
       at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFact
ory.createBean(AbstractAutowireCapableBeanFactory.java:475)
       at
org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(
AbstractBeanFactory.java:304)
       at
org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSi
ngleton(DefaultSingletonBeanRegistry.java:228)
       at
org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(A
bstractBeanFactory.java:300)
       at
org.springframework.beans.factory.support.AbstractBeanFactory.getBean(Abstr
actBeanFactory.java:195)
       at
org.springframework.beans.factory.support.DefaultListableBeanFactory.preInst
antiateSingletons(DefaultListableBeanFactory.java:703)
       at
org.springframework.context.support.AbstractApplicationContext.finishBeanFac
toryInitialization(AbstractApplicationContext.java:760)
       at
org.springframework.context.support.AbstractApplicationContext.refresh(Abstr
actApplicationContext.java:482)
       at
org.apache.cxf.transport.servlet.CXFServlet.createSpringContext(CXFServlet.jav
a: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(Manag
edServlet.java:214)
       at
io.undertow.servlet.core.ManagedServlet.createServlet(ManagedServlet.java:1
19)
       at
io.undertow.servlet.core.DeploymentManagerImpl.start(DeploymentManagerI
mpl.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.j
ava:205)
       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
       at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:
62)
       at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorI
mpl.java:43)
       at java.lang.reflect.Method.invoke(Method.java:483)
       at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFact
ory.invokeCustomInitMethod(AbstractAutowireCapableBeanFactory.java:1681)
       at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFact
ory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1620)
       at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFact
ory.initializeBean(AbstractAutowireCapableBeanFactory.java:1549)
       ... 16 more
Caused by: org.apache.cxf.BusException: No DestinationFactory was found for
the namespacehttp://cxf.apache.org/transports/http.
       at
org.apache.cxf.bus.managers.DestinationFactoryManagerImpl.getDestinationF
actory(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.j
ava: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]

Did anyone try this setup already?

Any help with this would be much appreciated.

Thanks in advance and cheers,

Aleks

Reply via email to