Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

https problem

 
Faxin Zhao
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I want to get the XML output from a URL and transfer to a HTML page.
When I tyied my http web app, is OK.
But, when I tried my https web app, no rusult, only the message showed in the log file:
###########################
Error occurs here:
https://myTestSvr/myApp/servlet/myDocList?myAccountNo=321456&myTeamNo=2&myAccessCode=A
Any ideas?
Thanks in advance.

Here are some lines from my servlet:
//********** Step 1: set property ***********************//
try
{
// set the default security protocol (shipped with JSSE1.0.2)
System.setProperty("java.protocol.handler.pkgs", "com.sun.net.ssl.internal.www.protocol");
// add the default security provider (again, in JSSE1.0.2)
java.security.Security.addProvider(new com.sun.net.ssl.internal.ssl.Provider());
}
catch (Exception e)
{
return;
}
//********** Step 3: do transform ***********************//
try
{
TransformerFactory tFactory = TransformerFactory.newInstance();

String url = "https://myTestSvr/myApp/servlet/myDocList?" +
"myAccountNo=" + myAccountNo +
"&myTeamNo=" + myTeamNo +
"&myAccessCode=" + myAccessCode ;
Source xmlSource = new StreamSource(new URL(url).openStream());
Source xslSource = new StreamSource (new FileInputStream ("D:\\myDoc.xsl"));
Transformer transformer = tFactory.newTransformer(xslSource);
transformer.transform(xmlSource, new StreamResult(out));
}
catch (Exception e)
{
System.out.println("###########################");
System.out.println("Error occurs here:");
System.out.println(e.getMessage());
return;
}
 
jason adam
Chicken Farmer ()
Ranch Hand
Posts: 1932
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You have 4 possible locations for throwing an exception, do you know where it is happening? Perhaps a couple of debug print statements could narrow this down.
So something like:
That will help determine the actual cause of the error.
 
Faxin Zhao
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Jason,
Thanks for your reply.
I knew the problem was caught by this line:
Source xmlSource = new StreamSource(new URL(url).openStream());
That means I couldn't get the input stream from url.openStream
And I got more error messages as following:
java.io.FileNotFoundException: https://myTestSvr/myApp/servlet/myDocList?myAccountNo=321456&myTeamNo=2&myAccessCode=A
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)
at com.sun.net.ssl.internal.www.protocol.https.HttpsURLConnectionOldImpl.getInputStream(Unknown Source)
at java.net.URL.openStream(Unknown Source)
at myDocList.doPost(myDocList.java:143)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:749)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:842)
at com.gefionsoftware.server.ServletContextImpl$ServletHandler.call(ServletContextImpl.java)
at com.gefionsoftware.server.ServletContextImpl.executeServlet(ServletContextImpl.java)
at com.gefionsoftware.server.NamedDispatcherImpl.forward(NamedDispatcherImpl.java)
at com.gefionsoftware.server.servlets.InvokerServlet.service(InvokerServlet.java)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:842)
at com.gefionsoftware.server.ServletContextImpl$ServletHandler.call(ServletContextImpl.java)
at com.gefionsoftware.server.ServletContextImpl.executeServlet(ServletContextImpl.java)
at com.gefionsoftware.server.ServletContextImpl.execute(ServletContextImpl.java)
at com.gefionsoftware.server.GenericServer.execute(GenericServer.java)
at com.gefionsoftware.server.lws.LiteWebServer$RequestHandler.run(LiteWebServer.java)
at se.pureit.util.ThreadPool$WorkThread.startRunnable(ThreadPool.java)
at se.pureit.util.ThreadPool$WorkThread.run(ThreadPool.java)

Some advices?
 
jason adam
Chicken Farmer ()
Ranch Hand
Posts: 1932
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, the reason I asked was that my initial response is that this doesn't seem to be an XML related question, and seeing the error that pretty much defines it.
Going to find out if it would best be answered in the I/O and Streams forum, or the one for Servlets. There might be people in either one of those that have experienced something similar.
 
Pankaj Kr
Author
Ranch Hand
Posts: 80
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As the previous post stated -- the problem doesn't seem to be XML related.
Most likely, it is SSL related. So, you need to verify a number of things:
1. Does server support HTTPS?
2. If yes, then does the client has environment variables for truststore setup?
3. Do both client and server support common cipher-suite?
....
 
Faxin Zhao
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Jason & Pankaj,
Thanks for your suggestion, I'll post my question to IO/Stream.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic