[英]Java 7 Class Not Found Exception when calling https
We've got some code that works fine in Java 6: 我们有一些在Java 6中运行良好的代码:
String g = "https://graph.facebook.com/oauth/access_token?client_id=xxxxx&redirect_uri="
+ URLEncoder.encode("http://www.bestcricketgame.com/facebook-login/", "UTF-8")
+ "&client_secret=xxxxxxx"
+ "&code=" + code;
URL u = new URL(g);
URLConnection c = u.openConnection();
BufferedReader in = new BufferedReader(new InputStreamReader(c.getInputStream()));
However, after installing java 7 and running the same code we get this: 但是,在安装Java 7并运行相同的代码后,我们得到以下信息:
java.lang.NoClassDefFoundError: sun.net.www.protocol.http.HttpURLConnection java.lang.NoClassDefFoundError:sun.net.www.protocol.http.HttpURLConnection
java.lang.NoClassDefFoundError: sun.net.www.protocol.http.HttpURLConnection
at sun.net.www.protocol.https.HttpsURLConnectionImpl.<init>(HttpsURLConnectionImpl.java:86)
at sun.net.www.protocol.https.Handler.openConnection(Handler.java:62)
at sun.net.www.protocol.https.Handler.openConnection(Handler.java:57)
at java.net.URL.openConnection(URL.java:971)
at tipping.FacebookLogin.processFacebookLogin(FacebookLogin.java:39)
at tipping.FacebookLoginCallbackServlet.service(FacebookLoginCallbackServlet.java:60)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:91)
..... .....
Line 39 is : URLConnection c = u.openConnection(); 第39行是:URLConnection c = u.openConnection();
The obvious thought is that maybe we should be using HttpsURLConnection, but on the other hand, it doesn't really make sense that we'd get a ClassNotFoundException for not using it, and also a major change like this would surely be documented. 一个明显的想法是,也许我们应该使用HttpsURLConnection,但是,另一方面,如果不使用ClassNotFoundException就没有真正意义,并且肯定会记录这样的重大更改。 I've searched google and haven't been able to find anything related to this matter.
我已经搜索过Google,但找不到与此事件相关的任何信息。
Thanks for your help! 谢谢你的帮助!
尝试使用java.net.URLConnection作为导入。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.