【发布时间】:2012-06-30 06:57:44
【问题描述】:
我需要获取 jar 文件中资源的 URL。我将此 URL 用作我的服务调用的参数。我的以下代码因“没有这样的文件或目录”错误而失败。
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 );
以下是执行此操作时看到的错误 -
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).
我非常感谢任何处理此问题的建议!
【问题讨论】:
-
Jar 中的文件不再是独立文件
-
right.. 但我正在尝试 jar 文件的相对路径,如感叹号所示。 jar -xvf 在 jar 文件的根路径显示我的 wsdl 文件
-
这可能会有所帮助 - stackoverflow.com/questions/5193786/…