Гость
Целевая тема:
Создать новую тему:
Автор:
Форумы / Java [игнор отключен] [закрыт для гостей] / java.net.URL openConnection() на weblogic / 4 сообщений из 4, страница 1 из 1
19.04.2013, 16:44:45
    #38233094
Worst_Admin
Участник
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
java.net.URL openConnection() на weblogic
Доброго времени суток.
Данный метод прекрасно работает на Oracle AS. На Weblogic 12 отказывается работать. Вылетает на выделенном строке:
urlConn = (HttpsURLConnection)serverURL.openConnection();
Ребята, помогите пожалуйста...
Код: java
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.
30.
31.
32.
33.
34.
35.
36.
37.
38.
39.
40.
41.
42.
43.
44.
45.
46.
47.
48.
49.
50.
51.
52.
53.
54.
55.
56.
57.
58.
59.
60.
61.
62.
63.
64.
65.
66.
67.
68.
69.
70.
71.
72.
73.
74.
75.
76.
77.
78.
79.
80.
81.
82.
83.
84.
85.
            private InputStream getResponseHTTPS(String url, String params) {
                TrustManager[] trustAllCerts = 
                    new TrustManager[] { new X509TrustManager() {
                            public java.security.cert.X509Certificate[] getAcceptedIssuers() {
                                return null;
                            }

                            public void checkClientTrusted(java.security.cert.X509Certificate[] certs, 
                                                           String authType) {
                            }

                            public void checkServerTrusted(java.security.cert.X509Certificate[] certs, 
                                                           String authType) {
                            }

                            public boolean isClientTrusted(java.security.cert.X509Certificate[] certs) {
                                return true;
                            }

                            public boolean isServerTrusted(java.security.cert.X509Certificate[] certs) {
                                return true;
                            }
                        } };
                HostnameVerifier verifier = new HostnameVerifier() {
                        public boolean verify(String string, SSLSession sSLSession) {
                            return true;
                        }

                        public boolean verify(String string, String string2) {
                            return true;
                        }
                    };
                try {
                    SSLContext sc = SSLContext.getInstance("SSL");
                    sc.init(null, trustAllCerts, new java.security.SecureRandom());
                    HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory());
                    HttpsURLConnection.setDefaultHostnameVerifier(verifier);
                } catch (Exception e) {
                    System.err.println("CPG: Exception: " + e.getMessage());
                }
                HttpsURLConnection.setDefaultHostnameVerifier(verifier);
                URL serverURL = null;
                try {
                    serverURL = new URL(url);
                } catch (MalformedURLException mue) {
                    System.err.println("CPG: MalformedURLException: " + 
                                       mue.getMessage());
                    mue.printStackTrace();
                } catch (ClassCastException cce) {
                    System.err.println("CPG: serverURL ClassCastException: " + 
                                       cce.getMessage());
                    cce.printStackTrace();
                }
                HttpsURLConnection urlConn = null;
                try {
                    urlConn = (HttpsURLConnection)serverURL.openConnection();
                    urlConn.setRequestMethod("POST");
                } catch (IOException ioe) {
                    System.err.println("CPG: IOException: " + ioe.getMessage());
                    ioe.printStackTrace();
                } catch (ClassCastException cce) {
                    System.err.println("CPG: urlConn ClassCastException: " + 
                                       cce.getMessage());
                    cce.printStackTrace();
                }
                InputStream res = null;
                urlConn.setDoOutput(true);
                urlConn.setUseCaches(false);
                urlConn.setAllowUserInteraction(true);
                urlConn.setRequestProperty("Pragma", "no-cache");
                urlConn.setRequestProperty("Content-type", 
                                           "application/x-www-form-urlencoded");
                urlConn.setRequestProperty("Content-length", 
                                           Integer.toString(params.length()));
                try {
                    PrintStream out = new PrintStream(urlConn.getOutputStream());
                    out.print(params);
                    out.flush();
                    out.close();
                    res = urlConn.getInputStream();
                } catch (IOException iox) {
                    iox.printStackTrace();
                }
                return res;
            }



Лог:
Код: java
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
CPG: urlConn ClassCastException: weblogic.net.http.SOAPHttpsURLConnection cannot be cast to javax.net.ssl.HttpsURLConnection
java.lang.ClassCastException: weblogic.net.http.SOAPHttpsURLConnection cannot be cast to javax.net.ssl.HttpsURLConnection
        at api.Common.getResponseHTTPS(Common.java:156)
        at api.Common.getResponse(Common.java:68)
        at api.Transfer.sendRequestAndGetParams(Transfer.java:236)
        at api.Transfer.operation(Transfer.java:208)
        at jsp_servlet.__payments._jspService(__payments.java:223)
        at weblogic.servlet.jsp.JspBase.service(JspBase.java:34)
        at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:242)
        at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:216)
        at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:132)
        at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:338)
        at weblogic.servlet.internal.ServletStubImpl.onAddToMapException(ServletStubImpl.java:453)
        at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:364)
        at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:221)
        at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.wrapRun(WebAppServletContext.java:3284)
        at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3254)
        at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
        at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:120)
        at weblogic.servlet.provider.WlsSubjectHandle.run(WlsSubjectHandle.java:57)
        at weblogic.servlet.internal.WebAppServletContext.doSecuredExecute(WebAppServletContext.java:2163)
        at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2089)
        at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2074)
        at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1513)
        at weblogic.servlet.provider.ContainerSupportProviderImpl$WlsRequestExecutor.run(ContainerSupportProviderImpl.java:254)
        at weblogic.work.ExecuteThread.execute(ExecuteThread.java:256)
        at weblogic.work.ExecuteThread.run(ExecuteThread.java:221)
...
Рейтинг: 0 / 0
19.04.2013, 17:14:26
    #38233183
Blazkowicz
Участник
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
java.net.URL openConnection() на weblogic
Замените
(HttpsURLConnection)serverURL.openConnection();
на
(HttpURLConnection)serverURL.openConnection();

В документации же видно
http://docs.oracle.com/cd/E11035_01/wls100/javadocs/weblogic/net/http/SOAPHttpsURLConnection.html
HttpsURLConnection в иерархии отсутствует.
...
Рейтинг: 0 / 0
19.04.2013, 23:39:26
    #38233579
Worst_Admin
Участник
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
java.net.URL openConnection() на weblogic
BlazkowiczЗамените
(HttpsURLConnection)serverURL.openConnection();
на
(HttpURLConnection)serverURL.openConnection();

В документации же видно
http://docs.oracle.com/cd/E11035_01/wls100/javadocs/weblogic/net/http/SOAPHttpsURLConnection.html
HttpsURLConnection в иерархии отсутствует.
В таком случае ругается на инвалид сертификат. При использование HttpsURLConnection он принимал любой сертификат (смысл ТрастМенеджера именно в этом). Ребята, кто нибудь сталкивался с таким?
...
Рейтинг: 0 / 0
22.04.2013, 22:19:43
    #38235749
Worst_Admin
Участник
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
java.net.URL openConnection() на weblogic
Проблема решена. Всем спасибо за участие.
...
Рейтинг: 0 / 0
Форумы / Java [игнор отключен] [закрыт для гостей] / java.net.URL openConnection() на weblogic / 4 сообщений из 4, страница 1 из 1
Найденые пользователи ...
Разблокировать пользователей ...
Читали форум (0):
Пользователи онлайн (0):
x
x
Закрыть


Просмотр
0 / 0
Close
Debug Console [Select Text]