【问题标题】:URL to a resource within JARJAR 中资源的 URL
【发布时间】: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/…

标签: java url wsdl


【解决方案1】:

我认为正确的网址应该是

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

【讨论】:

    猜你喜欢
    • 2023-03-24
    • 1970-01-01
    • 2020-01-31
    • 2012-11-28
    • 2011-06-21
    • 1970-01-01
    • 2012-12-04
    • 2016-12-29
    相关资源
    最近更新 更多