• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

SOAP WS client fails from command line, works in Eclipse (shocking, right?)

 
Greenhorn
Posts: 9
2
  • Number of slices to send:
    Optional 'thank-you' note:
Hello, masters of Java!

I am developing a WS client that will need to use MTOM for some data transfer. However, I have a different problem and it's driving me nuts. It involves, of course, running the JAR file from the command line.

I used cxf-codegen-plugin to generate the classes from WSDL and built a simple client. I created a MockService in SoapUI with that same WSDL and tested the client against it. Needless to say, everything works perfectly from Eclipse. I used maven-assembly-plugin to create a single JAR and when I run it from the command line, I get an exception as follows:

Caught Exception - Cannot invoke "org.apache.cxf.wsdl.WSDLManager.getDefinition(String)" because the return value of "org.apache.cxf.Bus.getExtension(java.lang.Class)" is null
java.lang.NullPointerException: Cannot invoke "org.apache.cxf.wsdl.WSDLManager.getDefinition(String)" because the return value of "org.apache.cxf.Bus.getExtension(java.lang.Class)" is null
       at org.apache.cxf.wsdl11.WSDLServiceFactory.<init>(WSDLServiceFactory.java:85)
       at org.apache.cxf.jaxws.ServiceImpl.initializePorts(ServiceImpl.java:217)
       at org.apache.cxf.jaxws.ServiceImpl.initialize(ServiceImpl.java:160)
       at org.apache.cxf.jaxws.ServiceImpl.<init>(ServiceImpl.java:129)
       at org.apache.cxf.jaxws.spi.ProviderImpl.createServiceDelegate(ProviderImpl.java:82)
       at javax.xml.ws.Service.<init>(Service.java:112)
       at com.xxx.xmldefs.sup.enterpriseservices.documentmanagementservice.v1.DocumentManagementService.<init>(DocumentManagementService.java:43)
       at XXX.MTOMClient.MTOMClient.main(MTOMClient.java:53)

Obviously, something is missing in my dependencies, build path, libraries, whatnot, since from Eclipse, client connects, executes the call and gets the result back. I have Maven dependencies and Java system libraries checked in the "Order and Export" section of the project build path.

What am I missing? I admit not to be an expert, I develop things in Java occassionally so maybe this is something simple I just haven't come across yet.

Thank you all in advance for your help!

 
Sheriff
Posts: 22787
131
  • 1
  • Number of slices to send:
    Optional 'thank-you' note:

Davor Matijasevic wrote:I used maven-assembly-plugin to create a single JAR


Is that a so-called fat JAR, that contains the contents of your application and all of its dependencies all flattened into one JAR file?

Because if so, I had the same issue a while ago in Quarkus: https://github.com/quarkusio/quarkus/issues/15643. The problem is that some frameworks use a plugable system that allows separate JAR files to each provide implementations. These all use a file with the exact same path. In this case the file is META-INF/cxf/bus-extensions.txt. For a fat JAR to work, the contents of all these files need to combined into one file. What instead happens is that one file wins, and the contents of all others are discarded.

What you then need to do is to change the way your fat jar is created and merge files instead of overwriting / discarding them. I haven't ever created fat JARs with the assembly plugin, so you'll need to check how to do it yourself (or wait for someone else to help you out).
 
Davor Matijasevic
Greenhorn
Posts: 9
2
  • Number of slices to send:
    Optional 'thank-you' note:

Rob Spoor wrote:

Davor Matijasevic wrote:I used maven-assembly-plugin to create a single JAR


Is that a so-called fat JAR, that contains the contents of your application and all of its dependencies all flattened into one JAR file?



Thanks Rob! Yes, that's exactly what it is - I need the final product to be a single JAR. I will look into what can be done here, perhaps I could use another variant to create the JAR instead of this plugin. Maybe that will help. At least you pointed me in the direction that seems likely to be the right one.
 
Rob Spoor
Sheriff
Posts: 22787
131
  • Number of slices to send:
    Optional 'thank-you' note:
You're welcome.

I know that there is also the shade plugin that can create fat JARs. I know it supports transformers, but I haven't used these yet so I don't really know how they work.
 
Davor Matijasevic
Greenhorn
Posts: 9
2
  • Number of slices to send:
    Optional 'thank-you' note:

Rob Spoor wrote:You're welcome.

I know that there is also the shade plugin that can create fat JARs. I know it supports transformers, but I haven't used these yet so I don't really know how they work.



Yeah, I came across it but assembly plugin seemed simpler. I guess I'll have to learn Shade now Or, if you have any other recommendations, I'm open for anything!
 
Davor Matijasevic
Greenhorn
Posts: 9
2
  • Number of slices to send:
    Optional 'thank-you' note:
Hi Rob,

I sorry to bother you again but I am getting desperate. I tried using shade but I'm getting the same error. Could you elaborate a bit better what I should be looking at?

I can't believe a flat JAR can't be built for a 5-line web service client. I get that there's a bunch of classes in the background but these are all the dependencies I have in my POM:



I don't see what could be clashing with what? I get it that Maven pulls in a ton of other dependencies but if something there clashes, then what's the point?
 
Rob Spoor
Sheriff
Posts: 22787
131
  • 1
  • Number of slices to send:
    Optional 'thank-you' note:
The first three all have a file inside the JAR with path /META-INF/cxf/bus-extensions.txt. Without any custom configuration all of these are ignored except one. Like I said, you need to merge these. I found a link for the shade plugin that probably can help: https://maven.apache.org/plugins-archives/maven-shade-plugin-1.4/examples/resource-transformers.html
 
Davor Matijasevic
Greenhorn
Posts: 9
2
  • Number of slices to send:
    Optional 'thank-you' note:
Thank you Rob! This helped, finally. I understand now what you were referring to in your first post. If I had more experience with this, I probably would've figure it right away.

I got one step further now and am receiving a "java.lang.NoClassDefFoundError: javax/jws/WebService" error, but this seems to be related to some missing dependencies. I hope to fix this soon but if not, I know where to come asking for assistance!
 
Greenhorn
Posts: 1
  • Number of slices to send:
    Optional 'thank-you' note:
Davor, were you finally able to solve the problem? If so, can you share more details about that, please? I'm facing a similar issue.
 
Davor Matijasevic
Greenhorn
Posts: 9
2
  • 1
  • Number of slices to send:
    Optional 'thank-you' note:
Hi Jorge!

Yes, I did. I'm a bit swamped right now but I'll get back to you tomorrow at the latest.
 
Davor Matijasevic
Greenhorn
Posts: 9
2
  • 1
  • Number of slices to send:
    Optional 'thank-you' note:
Hi Jorge,

so, the trick is to use Shade to bind the JAR in such a way that all extensions are available. As Rob explained, if you don't do this, only one of them will be linked. I will post you the part of POM that solved it for me. The solution is between ---> and <---- - you need to use the appending transformer to "append" all the extensions of certain classes into the final products, so that the one used in your code will be executed during runtime.

I hope this helps.

 
Greenhorn
Posts: 1
  • Number of slices to send:
    Optional 'thank-you' note:
Thanks. You save my life !
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic
vceplus-200-125    | boson-200-125    | training-cissp    | actualtests-cissp    | techexams-cissp    | gratisexams-300-075    | pearsonitcertification-210-260    | examsboost-210-260    | examsforall-210-260    | dumps4free-210-260    | reddit-210-260    | cisexams-352-001    | itexamfox-352-001    | passguaranteed-352-001    | passeasily-352-001    | freeccnastudyguide-200-120    | gocertify-200-120    | passcerty-200-120    | certifyguide-70-980    | dumpscollection-70-980    | examcollection-70-534    | cbtnuggets-210-065    | examfiles-400-051    | passitdump-400-051    | pearsonitcertification-70-462    | anderseide-70-347    | thomas-70-533    | research-1V0-605    | topix-102-400    | certdepot-EX200    | pearsonit-640-916    | itproguru-70-533    | reddit-100-105    | channel9-70-346    | anderseide-70-346    | theiia-IIA-CIA-PART3    | certificationHP-hp0-s41    | pearsonitcertification-640-916    | anderMicrosoft-70-534    | cathMicrosoft-70-462    | examcollection-cca-500    | techexams-gcih    | mslearn-70-346    | measureup-70-486    | pass4sure-hp0-s41    | iiba-640-916    | itsecurity-sscp    | cbtnuggets-300-320    | blogged-70-486    | pass4sure-IIA-CIA-PART1    | cbtnuggets-100-101    | developerhandbook-70-486    | lpicisco-101    | mylearn-1V0-605    | tomsitpro-cism    | gnosis-101    | channel9Mic-70-534    | ipass-IIA-CIA-PART1    | forcerts-70-417    | tests-sy0-401    | ipasstheciaexam-IIA-CIA-PART3    | mostcisco-300-135    | buildazure-70-533    | cloudera-cca-500    | pdf4cert-2v0-621    | f5cisco-101    | gocertify-1z0-062    | quora-640-916    | micrcosoft-70-480    | brain2pass-70-417    | examcompass-sy0-401    | global-EX200    | iassc-ICGB    | vceplus-300-115    | quizlet-810-403    | cbtnuggets-70-697    | educationOracle-1Z0-434    | channel9-70-534    | officialcerts-400-051    | examsboost-IIA-CIA-PART1    | networktut-300-135    | teststarter-300-206    | pluralsight-70-486    | coding-70-486    | freeccna-100-101    | digitaltut-300-101    | iiba-CBAP    | virtuallymikebrown-640-916    | isaca-cism    | whizlabs-pmp    | techexams-70-980    | ciscopress-300-115    | techtarget-cism    | pearsonitcertification-300-070    | testking-2v0-621    | isacaNew-cism    | simplilearn-pmi-rmp    | simplilearn-pmp    | educationOracle-1z0-809    | education-1z0-809    | teachertube-1Z0-434    | villanovau-CBAP    | quora-300-206    | certifyguide-300-208    | cbtnuggets-100-105    | flydumps-70-417    | gratisexams-1V0-605    | ituonline-1z0-062    | techexams-cas-002    | simplilearn-70-534    | pluralsight-70-697    | theiia-IIA-CIA-PART1    | itexamtips-400-051    | pearsonitcertification-EX200    | pluralsight-70-480    | learn-hp0-s42    | giac-gpen    | mindhub-102-400    | coursesmsu-CBAP    | examsforall-2v0-621    | developerhandbook-70-487    | root-EX200    | coderanch-1z0-809    | getfreedumps-1z0-062    | comptia-cas-002    | quora-1z0-809    | boson-300-135    | killtest-2v0-621    | learncia-IIA-CIA-PART3    | computer-gcih    | universitycloudera-cca-500    | itexamrun-70-410    | certificationHPv2-hp0-s41    | certskills-100-105    | skipitnow-70-417    | gocertify-sy0-401    | prep4sure-70-417    | simplilearn-cisa    |
http://www.pmsas.pr.gov.br/wp-content/    | http://www.pmsas.pr.gov.br/wp-content/    |