无法从部署在wls上的应用程序中读取网址

时间:2011-05-20 02:34:39

标签: weblogic weblogic-10.x

我的应用程序部署在Weblogic服务器和以下代码

    private boolean validateParse() {
    URLConnection yc = null;
    try {
        System.out.println("Processing source:" + source);
        SAXParserFactory factory = SAXParserFactory.newInstance();
        SAXParser saxParser = factory.newSAXParser();
        DefaultHandler handler = new DefaultHandler() {

            boolean aFlag = false;
            boolean tFlag = false;
            boolean lFlag = false;
            boolean pFlag = false;
            Map<String, String> rec = null;
            List<Map<String, String>> dataSet =
                new ArrayList<Map<String, String>>();

            public void startElement(String uri, String localName,
                                     String qName,
                                     Attributes attributes) throws SAXException {
                if (qName.equalsIgnoreCase("author"))
                    aFlag = true;
                if (qName.equalsIgnoreCase("title"))
                    tFlag = true;
                if (qName.equalsIgnoreCase("link"))
                    lFlag = true;
                if (qName.equalsIgnoreCase("pubDate"))
                    pFlag = true;
            }

            public void endElement(String uri, String localName,
                                   String qName) throws SAXException {
                if (rec.containsKey("pubDate") &&
                    rec.containsKey("author") &&
                    rec.containsKey("title") && rec.containsKey("link")) {
                    rec.clear();
                }
            }

            public void characters(char[] ch, int start,
                                   int length) throws SAXException {

                if (tFlag) {
                    System.out.println(new String(ch, start, length));
                    rec = new HashMap<String, String>();
                    rec.put("title", new String(ch, start, length));
                    tFlag = false;
                }

                if (lFlag) {
                    System.out.println(new String(ch, start, length));
                    rec.put("link", new String(ch, start, length));
                    lFlag = false;
                }

                if (aFlag) {
                    System.out.println(new String(ch, start, length));
                    rec.put("author", new String(ch, start, length));
                    aFlag = false;
                }

                if (pFlag) {
                    System.out.println(new String(ch, start, length));
                    rec.put("pubDate", new String(ch, start, length));
                    dataSet.add(rec);
                    pFlag = false;
                }
            }

            public void endDocument() {
            }
        };

        URL google = new URL(source);
        yc = google.openConnection();
        saxParser.parse(yc.getInputStream(), handler);

    } catch (Exception e) {
        e.printStackTrace();
        return false;
    } finally {
        try {
            yc.getInputStream().close();
        } catch (Exception e1) {
            e1.printStackTrace();
            return false;
        }
    }
    return true;
} //end startParsing

将异常视为:

java.net.ProtocolException: Unsupported protocol: https'
at weblogic.net.http.HttpClient.openServer(HttpClient.java:384)
at weblogic.net.http.HttpClient.New(HttpClient.java:252)
at weblogic.net.http.HttpURLConnection.connect(HttpURLConnection.java:189)
at weblogic.net.http.HttpURLConnection.followRedirect(HttpURLConnection.java:661)
at weblogic.net.http.HttpURLConnection.getInputStream(HttpURLConnection.java:440)
at weblogic.net.http.SOAPHttpURLConnection.getInputStream(SOAPHttpURLConnection.java:37)
at vik.tools.changeNotifier.ui.bean.AdminBean.validateParse(AdminBean.java:125)
at vik.tools.changeNotifier.ui.bean.AdminBean.addSource(AdminBean.java:39)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.sun.el.parser.AstValue.invoke(Unknown Source)
at com.sun.el.MethodExpressionImpl.invoke(Unknown Source)
at org.apache.myfaces.trinidadinternal.taglib.util.MethodExpressionMethodBinding.invoke(MethodExpressionMethodBinding.java:53)
at org.apache.myfaces.trinidad.component.UIXComponentBase.broadcastToMethodBinding(UIXComponentBase.java:1256)
at org.apache.myfaces.trinidad.component.UIXCommand.broadcast(UIXCommand.java:183)
at oracle.adf.view.rich.component.fragment.ContextSwitchingComponent$1.run(ContextSwitchingComponent.java:92)
at oracle.adf.view.rich.component.fragment.ContextSwitchingComponent._processPhase(ContextSwitchingComponent.java:361)
at oracle.adf.view.rich.component.fragment.ContextSwitchingComponent.broadcast(ContextSwitchingComponent.java:96)
at oracle.adf.view.rich.component.fragment.UIXInclude.broadcast(UIXInclude.java:102)
at oracle.adf.view.rich.component.fragment.ContextSwitchingComponent$1.run(ContextSwitchingComponent.java:92)
at oracle.adf.view.rich.component.fragment.ContextSwitchingComponent._processPhase(ContextSwitchingComponent.java:361)
at oracle.adf.view.rich.component.fragment.ContextSwitchingComponent.broadcast(ContextSwitchingComponent.java:96)
at oracle.adf.view.rich.component.fragment.UIXInclude.broadcast(UIXInclude.java:96)
at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:475)
at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:756)
at oracle.adfinternal.view.faces.lifecycle.LifecycleImpl._invokeApplication(LifecycleImpl.java:788)
at oracle.adfinternal.view.faces.lifecycle.LifecycleImpl._executePhase(LifecycleImpl.java:306)
at oracle.adfinternal.view.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:186)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:265)
at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227)
at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125)
at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:300)
at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:26)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
at oracle.adf.model.servlet.ADFBindingFilter.doFilter(ADFBindingFilter.java:205)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
at oracle.adfinternal.view.faces.webapp.rich.RegistrationFilter.doFilter(RegistrationFilter.java:106)
at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl$FilterListChain.doFilter(TrinidadFilterImpl.java:446)
at oracle.adfinternal.view.faces.activedata.AdsFilter.doFilter(AdsFilter.java:60)
at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl$FilterListChain.doFilter(TrinidadFilterImpl.java:446)
at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl._doFilterImpl(TrinidadFilterImpl.java:271)
at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl.doFilter(TrinidadFilterImpl.java:177)
at org.apache.myfaces.trinidad.webapp.TrinidadFilter.doFilter(TrinidadFilter.java:92)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
at oracle.adf.library.webapp.LibraryFilter.doFilter(LibraryFilter.java:175)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
at oracle.security.jps.ee.http.JpsAbsFilter$1.run(JpsAbsFilter.java:111)
at java.security.AccessController.doPrivileged(Native Method)
at oracle.security.jps.util.JpsSubject.doAsPrivileged(JpsSubject.java:313)
at oracle.security.jps.ee.util.JpsPlatformUtil.runJaasMode(JpsPlatformUtil.java:413)
at oracle.security.jps.ee.http.JpsAbsFilter.runJaasMode(JpsAbsFilter.java:94)
at oracle.security.jps.ee.http.JpsAbsFilter.doFilter(JpsAbsFilter.java:161)
at oracle.security.jps.ee.http.JpsFilter.doFilter(JpsFilter.java:71)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
at oracle.dms.servlet.DMSServletFilter.doFilter(DMSServletFilter.java:136)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
at weblogic.servlet.internal.RequestEventsFilter.doFilter(RequestEventsFilter.java:27)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.wrapRun(WebAppServletContext.java:3715)
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3681)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:120)
at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2277)
at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2183)
at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1454)
at weblogic.work.ExecuteThread.execute(ExecuteThread.java:209)
at weblogic.work.ExecuteThread.run(ExecuteThread.java:178)

任何想法如何解决它?

3 个答案:

答案 0 :(得分:0)

您的网址似乎正在使用HTTPS,问题可能是您正在使用的主机+ URI不支持https。请尝试使用HTTP。

答案 1 :(得分:0)

setDomainENV.cmd下配置WL_home/user_projects/domain/bin/ 在此文件中,将以下命令放在文件末尾

  
    

设置JAVA_OPTIONS =%JAVA_OPTIONS %% JAVA_PROPERTIES%-Dwlw.iterativeDev =%iterativeDevFlag%-Dwlw.testConsole =%testConsoleFlag%-Dwlw.logErrorsToConsole =%logErrorsToConsoleFlag%-Dweblogic.security.allowCryptoJDefaultPRNG = true -Dweblogic.security.SSL .ignoreHostnameVerification = true -Dhttps.proxySet = true -Dhttps.proxyHost =您正在使用IP地址-Dhttps.proxyPort =您正在使用港口

  

然后重新启动服务器然后它将起作用

但这是生产中的不良做法。

答案 2 :(得分:0)

我有完全相同的问题。代码在我的IDE中运行良好,但在部署到WebLogic时则没有。

在我的情况下,问题是终端服务器重定向到“https”网址。 Java URLConnection以静默方式跟随重定向。要解决此问题,我只需将重定向设置为false,然后手动执行网址

    HttpURLConnection con = getUrlConnection(urlStr);
    con.setInstanceFollowRedirects(false);

下面的帖子确实有帮助。

Is it possible for a site having URL starting with "http://" using HTTPS protocol