2

I created a web client that invokes a service in OSB exposed through CXF (wsdl2java). I created a maven project and have imported sources. In addition, I added CXF libraries to the project. I use IDE is Eclipse, and running the class containing the main method invokes the service perfectly and it responds.

Then I exported the project as runnable jar and when I run the command: java -jar myJar.jar the following exception occurs:

ago 25, 2016 9:39:35 AM org.apache.cxf.common.injection.ResourceInjector invokeS
etter
GRAVE: exception raied when invoking setter public final void org.apache.cxf.wsd
l11.WSDLManagerImpl.setBus(org.apache.cxf.Bus)
java.lang.reflect.InvocationTargetException
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:57)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:606)
        at org.apache.cxf.common.injection.ResourceInjector.invokeSetter(Resourc
eInjector.java:287)
        at org.apache.cxf.common.injection.ResourceInjector.visitMethod(Resource
Injector.java:232)
        at org.apache.cxf.common.annotation.AnnotationProcessor.processMethods(A
nnotationProcessor.java:89)
        at org.apache.cxf.common.annotation.AnnotationProcessor.accept(Annotatio
nProcessor.java:72)
        at org.apache.cxf.common.injection.ResourceInjector.inject(ResourceInjec
tor.java:118)
        at org.apache.cxf.common.injection.ResourceInjector.inject(ResourceInjec
tor.java:112)
        at org.apache.cxf.bus.extension.ExtensionManagerImpl.loadAndRegister(Ext
ensionManagerImpl.java:215)
        at org.apache.cxf.bus.extension.ExtensionManagerImpl.getBeansOfType(Exte
nsionManagerImpl.java:290)
        at org.apache.cxf.bus.CXFBusImpl.getExtension(CXFBusImpl.java:99)
        at org.apache.cxf.jaxws.ServiceImpl.initializePorts(ServiceImpl.java:170
)
        at org.apache.cxf.jaxws.ServiceImpl.initialize(ServiceImpl.java:161)
        at org.apache.cxf.jaxws.ServiceImpl.<init>(ServiceImpl.java:129)
        at org.apache.cxf.jaxws.spi.ProviderImpl.createServiceDelegate(ProviderI
mpl.java:82)

I have reviewed the MANIFEST, and I see that the variable 'Class-Path:' contains all necessary libraries and other variable 'Main-Class:' indicates the main class containing the main method.

However, if I run the command (on the root of the project) mvn clean install (which creates a jar) and run the following command: java -cp myJar.jar myPackage.MainClass, the execution is successful.

I know there's some question about 'java -jar java -cp myJar.jar VS myJar.jar myPackage.MainClass' but honestly do not understand why the first option causes the exception I mentioned, can anyone tell me what is?

Thank you very much.

0 Answers0