Java EE about WebLogic applications using url.openconnection to get connections return httpsurlconnection and soaphttpsurlconnection issues

Source: Internet
Author: User

Java EE about WebLogic applications using url.openconnection to get connections return httpsurlconnection and soaphttpsurlconnection issuesMarch 09, 2012 ⁄ general ⁄ a total of 1353 characters ⁄ font size small medium big ⁄ comments off

The integration work was done using the interface jar packages provided by the third-party company and deployed to WebLogic after the local tomcat test passed. Throws a weblogic.net.http.SOAPHttpsURLConnection cannot is cast to javax.net.ssl.HttpsURLConnection such errors. This is the exception that the code in the third-party company jar package throws. Communication learned that the third-party company jar package has code similar to the following:

Httpsurlconnection conn = (httpsurlconnection) url.openconnection ();

This code runs normally under Tomcat, but Url.openconnection () returns an object of type soaphttpsurlconnection under WebLogic, so there is an error in the conversion exception.

Note: Soaphttpsurlconnection and httpsurlconnection are java.net.HttpURLConnection subclasses.


For example, if WebLogic does not configure the SSL implementation class that is used, if the normal use of Java.net.URL without the URLStreamHandler parameter of the constructor method of the new URL object, Url.openconnection () defaults to returning the Soaphttpsurlconnection type Object if we use a constructor with the URLStreamHandler parameter, as follows:

URL url = new URL (null, "https://www.etrade.com", New Com.sun.net.ssl.internal.www.protocol.https.Handler ());// OpenConnection () returned the Httpsurlconnection type Object Httpsurlconnection conn = (httpsurlconnection) after handler was specified Url.openconnection ();

The above can resolve the specific type of the returned HttpURLConnection object in the program. However, the jar package is provided by a third party, we cannot change the code, so we can only solve the problem from the WebLogic configuration level.

For a stand-alone WebLogic configuration, you can increase-dusesunhttphandler=true in the startup script (such as startweblogic.sh) in java_options, for example

Set java_options=%java_options%%java_properties%-dusesunhttphandler=true-dwlw.iterativedev=%iterativedevflag%- dwlw.testconsole=%testconsoleflag%-dwlw.logerrorstoconsole=% logerrorstoconsoleflag%

If the cluster is configured, you do not have to add parameters to the startup script, which you can configure in the WebLogic console for a specific server

The purpose of this parameter is to tell WebLogic to use Sun's HttpHandler instead of using WebLogic's own. Using Url.openconnection () After this configuration will return the Httpsurlconnection type object.

Java EE about WebLogic applications using url.openconnection to get connections return httpsurlconnection and soaphttpsurlconnection issues

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.