0

I need to get URL to a resource within a jar file. I use this URL as an argument to my service call. My below code fails with "No such File or Directory" error.

File file = new File(classLoader.getResource("AXLAPI.wsdl").getFile());
final URL wsdlURL = new URL(this.getClass().getResource(this.getClass().getSimpleName() +".class"),file.toString());
String endpoint = "https://<machine>:8443/axl/";
AXLAPIService ss = new AXLAPIService( wsdlURL );

Below is the error am seeing on executing this -

Failed to access the WSDL at: file:/blah/blah/blah.jar!/AXLAPI.wsdl. It failed with: 
/blah/blah/blah.jar!/AXLAPI.wsdl (No such file or directory).

I would really appreciate any suggestions to handle this !

wattostudios
  • 8,666
  • 13
  • 43
  • 57
Chandan
  • 1
  • 1
  • 3
  • File from Jar is no longer an independent File – jmj Jun 28 '12 at 17:38
  • right.. But I am trying relative path to the jar file as the exclamation indicates. Jar -xvf shows my wsdl file at the root path of the jar file – Chandan Jun 28 '12 at 17:43
  • This may be helpful - http://stackoverflow.com/questions/5193786/how-to-use-classloader-getresources-correctly – ChadNC Jun 28 '12 at 17:51

1 Answers1

2

I believe the correct url should be

jar:file:/blah/blah/blah.jar!/AXLAPI.wsdl

Stephen
  • 19,488
  • 10
  • 62
  • 83