[SAE] Java. security. InvalidAlgorithmParameterException

Source: Internet
Author: User

 

Preface

Java with SAES has been running smoothly and there is no problem in local Tomcat testing. After uploading to SAES, this error is reported. I searched for the error, which generally refers to environment problems. Here I will share it with you.

 

Statement
You are welcome to repost, but please keep the original source of the article :)
Blog: http://www.cnblogs.com

Farmer's uncle: http://www.cnblogs.com/over140/

 

Body

Access address:

Https://api.weibo.com/2/users/show.json

Error message:

Java. security. InvalidAlgorithmParameterException: the trustAnchors parameter must be non-empty on Linux, or why is the default truststore empty

Code:

Protected String getJsonString (String urlPath) throws Exception {
URL url = new URL (urlPath );
HttpURLConnection connection = (HttpURLConnection) url. openConnection ();
Connection. setRequestMethod ("GET ");
Connection. connect ();
InputStream inputStream = connection. getInputStream ();
// Character encoding conversion
Reader reader = new InputStreamReader (inputStream, "UTF-8 ");
BufferedReader bufferedReader = new BufferedReader (reader );
String str = null;
StringBuffer sb = new StringBuffer ();
While (str = bufferedReader. readLine ())! = Null ){
Sb. append (str );
}
Reader. close ();
Connection. disconnect ();
Return sb. toString ();
}

Solution:

New SaeFetchurl (). fetch (url)

Code Description: Use the SaeFetchurl service provided by SAE to replace your own code.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.