我想为基于CXF的应用服务器创建一个超级JAR。我希望使用java -jar
从命令行访问服务器。在IDE中,我可以运行主类com.connexta.desertcodecamp.Server
,但我没有正确创建超级jar。
当我运行命令java -jar server-1.0-SNAPSHOT.jar
时,我得到了
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)
这是POM文件(和GitHub repo)的链接: https://github.com/ahoffer/desert-code-camp/blob/master/server/pom.xml
其他帖子引用了缺少的依赖项cxf-rt-transports-http
,但我将其作为POM.xml中的依赖项。
答案 0 :(得分:2)
解决方案在这里:apache camel - packaging an executable jar 在这里:Missing cxf.xml? Fails in maven, works in Eclipse。
将此变换器和魔术资源添加到maven shade插件的配置部分可以修复它:
<transformer org.apache.maven.plugins.shade.resource.AppendingTransformer">
<resource>META-INF/cxf/bus-extensions.txt</resource>
</transformer>
资源由插件生成;没有必要创建它