3

I want to create an uber JAR for a CXF-based application server. I want to run the server from the commandline with java -jar. In the IDE, I can run the main class com.connexta.desertcodecamp.Server, but I am not correctly creating the uber jar.

When I run the command java -jar server-1.0-SNAPSHOT.jar, I get

org.apache.cxf.service.factory.ServiceConstructionException
        at org.apache.cxf.jaxrs.JAXRSServerFactoryBean.create(JAXRSServerFactoryBean.java:215)
        at com.connexta.desertcodecamp.Server.<init>(Server.java:19)
        at com.connexta.desertcodecamp.Server.main(Server.java:33)
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:170)

Here is a link to the POM file (and GitHub repo): https://github.com/ahoffer/desert-code-camp/blob/master/server/pom.xml

Other posts reference a missing dependency, cxf-rt-transports-http, but I have that as a dependency in the POM.xml.

ahoffer
  • 6,347
  • 4
  • 39
  • 68
  • are you sure you have it in the combined jar? _How_ did you combine the jars? – bmargulies Aug 29 '16 at 00:14
  • @bmargulies I don't know enough to answer the question. I don't know what combining means in this case. I included cxf-rt-transports-http as a maven dependency. I assumed all dependencies would make their way into the shaded JAR. – ahoffer Aug 29 '16 at 00:22

1 Answers1

2

Solution was here: apache camel - packaging an executable jar and here: Missing cxf.xml? Fails in maven, works in Eclipse.

Adding this transformer and magic resource to the configuration section of the maven shade plugin fixes it:

<transformer org.apache.maven.plugins.shade.resource.AppendingTransformer">
    <resource>META-INF/cxf/bus-extensions.txt</resource>
</transformer>

The resource is generated by the plugin; it is not necessary to create it

Community
  • 1
  • 1
ahoffer
  • 6,347
  • 4
  • 39
  • 68