java 获取 PrivilegedActionException:com.sun.xml.internal.messaging.saaj.SOAPExceptionImpl:消息发送失败。同时调用 Web 服务
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/6646455/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Getting PrivilegedActionException: com.sun.xml.internal.messaging.saaj.SOAPExceptionImpl: Message send failed.while invoking web service
提问by samash
I am having https service url. I wrote java client using SAAJ. but i am getting the below exception:--
我有 https 服务网址。我使用 SAAJ 编写了 java 客户端。但我收到以下异常:--
java.security.PrivilegedActionException: com.sun.xml.internal.messaging.saaj.SOAPExceptionImpl: Message send failed sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
java.security.PrivilegedActionException:com.sun.xml.internal.messaging.saaj.SOAPExceptionImpl:消息发送失败 sun.security.validator.ValidatorException:PKIX 路径构建失败:sun.security.provider.certpath.SunCertPathBuilderException:无法找到有效的到请求目标的认证路径
I exported the certificate from service URL (using browser.) and saved as jssecacerts Then imporetd this by using the following command--> keytool -import -file jssecacerts -keystore cacerts
我从服务 URL 导出证书(使用浏览器。)并保存为 jssecacerts 然后使用以下命令导入它--> keytool -import -file jssecacerts -keystore cacerts
Now I wrote the java client using SAAJ as below:-
现在我使用 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);
I dont know where I am wrong...Please help...me....I am in seriously in trouble.. Thanks in Advance..
我不知道我错在哪里......请帮助......我......我遇到了严重的麻烦......提前致谢......
采纳答案by jtahlborn
you don't need to set those system properties. if you successfully imported the certs into the jre's cacerts file, then they should be good to go. i'm assuming you are using the "java" from "C:/Program Files/Java/jre6/bin/java.exe" to actually run your program.
您不需要设置这些系统属性。如果您成功地将证书导入到 jre 的 cacerts 文件中,那么它们应该很好。我假设您正在使用“C:/Program Files/Java/jre6/bin/java.exe”中的“java”来实际运行您的程序。
btw, why are you getting a PrivilegedActionException? that implies that you are running with some sort of SecurityManager or within a PrivilegedAction call?
顺便说一句,你为什么会得到一个 PrivilegedActionException?这意味着您正在使用某种 SecurityManager 或在 PrivilegedAction 调用中运行?