【问题标题】:Getting PrivilegedActionException: com.sun.xml.internal.messaging.saaj.SOAPExceptionImpl: Message send failed.while invoking web service获取 PrivilegedActionException:com.sun.xml.internal.messaging.saaj.SOAPExceptionImpl:消息发送失败。同时调用 Web 服务
【发布时间】:2011-07-11 06:23:55
【问题描述】:

我有 https 服务网址。我使用 SAAJ 编写了 java 客户端。但我得到以下异常:--

java.security.PrivilegedActionException:com.sun.xml.internal.messaging.saaj.SOAPExceptionImpl:消息发送失败 sun.security.validator.ValidatorException:PKIX 路径构建失败:sun.security.provider.certpath.SunCertPathBuilderException:无法找到请求目标的有效证书路径

我从服务 URL 导出证书(使用浏览器)并保存为 jssecacerts 然后使用以下命令导入它--> keytool -import -file jssecacerts -keystore cacerts

现在我使用 SAAJ 编写了 java 客户端,如下所示:-

System.setProperty("javax.net.ssl.keyStore", "C:/Program  Files/Java/jre6/lib/security/cacerts"); 
System.setProperty("javax.net.ssl.keyStorePassword", "changeit"); 
URL url = new URL("https://whatever.com/service"); 
SOAPConnectionFactory scf = SOAPConnectionFactory.newInstance(); 
connection = scf.createConnection(); 
response = connection.call(message, url); 

我不知道我错在哪里......请帮助......我......我遇到了严重的麻烦...... 在此先感谢..

【问题讨论】:

  • 你能找到解决方法吗?

标签: java web-services


【解决方案1】:

您不需要设置这些系统属性。如果您成功地将证书导入到 jre 的 cacerts 文件中,那么它们应该很好用。我假设您正在使用“C:/Program Files/Java/jre6/bin/java.exe”中的“java”来实际运行您的程序。

顺便说一句,您为什么会收到 PrivilegedActionException?这意味着您正在使用某种 SecurityManager 或在 PrivilegedAction 调用中运行?

【讨论】:

  • 只为将来的问题/答案。如果您有时间并发布一个新问题,寻求帮助并期待答案,那么请 - 在问题得到修复/解决后提供解决方案,而不仅仅是“我通过 tnx 修复了它”。
猜你喜欢
  • 1970-01-01
  • 2015-04-21
  • 2019-05-02
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多