关于weblogic下使用URL.openConnection获取连接返回javax.net.ssl.SSLKeyException错误
2015-10-10 15:14
501 查看
本文主要记录如果解决weblogic使用URL.openConnection出现
在解决问题之前查看了http://blog.csdn.net/arvinrong/article/details/7715334和http://winters1224.blog.51cto.com/3021203/1313111这两篇文章的建议(感谢两位作者),原因这两位分析的很清晰了,最终采用一种简单的方式(无须修改weblogic代理配置),如下:
URL url = new URL(null,urlStr,new sun.net.www.protocol.https.Handler());//重点在这里,需要使用带有URLStreamHandler参数的URL构造方法
HttpsURLConnection httpConnection = (HttpsURLConnection) url.openConnection();//由于我调用的是官方给微信API接口,所以采用HTTPS连接
int responseCode = httpConnection.getResponseCode();
if (responseCode == HttpURLConnection.HTTP_OK) {
InputStream urlStream = httpConnection.getInputStream();
BufferedReader bufferedReader = new BufferedReader(
new InputStreamReader(urlStream));
String lineStr = "";
while ((lineStr = bufferedReader.readLine()) != null) {
......
}
.....
}
javax.net.ssl.SSLKeyException: [Security:
090504
]。。。。。。。的异常,tomcat下一切正常。
在解决问题之前查看了http://blog.csdn.net/arvinrong/article/details/7715334和http://winters1224.blog.51cto.com/3021203/1313111这两篇文章的建议(感谢两位作者),原因这两位分析的很清晰了,最终采用一种简单的方式(无须修改weblogic代理配置),如下:
URL url = new URL(null,urlStr,new sun.net.www.protocol.https.Handler());//重点在这里,需要使用带有URLStreamHandler参数的URL构造方法
HttpsURLConnection httpConnection = (HttpsURLConnection) url.openConnection();//由于我调用的是官方给微信API接口,所以采用HTTPS连接
int responseCode = httpConnection.getResponseCode();
if (responseCode == HttpURLConnection.HTTP_OK) {
InputStream urlStream = httpConnection.getInputStream();
BufferedReader bufferedReader = new BufferedReader(
new InputStreamReader(urlStream));
String lineStr = "";
while ((lineStr = bufferedReader.readLine()) != null) {
......
}
.....
}
相关文章推荐
- windows7服务器上weblogic启动失败异常解决方法
- CentOS 6.3安装配置Weblogic-10方法
- (Weblogic Portal 9.2.3集群)Oracle数据库初始化报PF_MARKUP...
- Weblogic在Linux环境下配置Https
- jstack和线程dump分析
- weblogic92应用jar冲突初解决
- 【集群】WebLogic线程阻塞的问题(图)
- WebLogic 安装与配置指南
- Unable to obtain file lock but will retry
- Linux下的WebLogic安装部署
- hp-unix WebLogic 安装笔记
- weblogic 修改端口
- 在Redhat中 weblogic 设置域名绑定的问题
- weblogix中文文档
- eclipse集成weblogic开发环境的搭建
- weblogic集群介绍
- weblogic 中域,集群,管理服务器和被管服务器之间的关系
- weblogic启动配置
- eclipse 中配置weblogic8.x
- weblogic密码丢失的解决办法