My application is deployed on Weblogic
server and the following code
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,
开发者_如何学GoAttributes 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
which gives exception as:
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)
any idea how can i resolve it?
It looks like your URL is using HTTPS and the problem could be that https is not supported for the host+URI you are using. Try using HTTP instead.
Configure in setDomainENV.cmd
which is under theWL_home/user_projects/domain/bin/
in this file place the following the command at the end of the file
set 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=YOU ARE USING IP ADDRESS -Dhttps.proxyPort=YOU ARE USING PORT
Then restart the server then it will work
But it is bad practices in production.
I had the exact same issue. The code runs fine from my IDE but not when deployed to WebLogic.
In my case the issue was that the end server redirects to an "https" url. Java URLConnection follows the redirect silently. To fix the issue I just set redirect to false and do the url follow manually
HttpURLConnection con = getUrlConnection(urlStr);
con.setInstanceFollowRedirects(false);
The thread below really helps.
Is it possible for a site having URL starting with "http://" using HTTPS protocol
精彩评论