JSTL xml is killing me... Tomcat 5.5 question - Connection refused: connec

I have the following code in my jsp file:
<%
String req_url="http://localhost/nolabook/books.xml";
//String req_url="http://www.SOMESERVER.com/books.xml";
%>
<c:import var="xml" url='<%= req_url %>' />
<c:import var="xslt" url="transform.xsl" />
<x:transform doc="${xml}" xslt="${xslt}" >
</x:transform>If I use 'req_url' with localhost then everything is ok and I see the result I want to. The xsl is perfect, the output is flawless.
If I try to load the same books.xml from a remote server I got the following exception:
...and the exception is: javax.servlet.jsp.JspException: Problem accessing the absolute URL "http://www.SOMESERVER.com/books.xml". java.net.ConnectException: Connection refused: connect
It drives me nuts and I cannot move on with my project because of this.
I use java 1.5 with Apache Tomcat 5.5.17
No firewalls, no port closures, no security systems nothing on my developer machine...
And of course, if I just place the URL(.../books.xml) into my browser it reads and shows the books.xml file.
I need help please because I'm drained...
Message was edited by:
ayrtonsf1

please see the following site for the solution:
http://www.cs.wcupa.edu/~rkline/Java/xml_examples.html
summary:
You will also need the jar files from the Xalan distribution whose web site is:
http://xml.apache.org/xalan-j/
The latest version is 2.7.0 and the binary distribution can be downloaded from the course server at
xalan-j_2_7_0-bin.zip
which contains the JAR file needed for XPath and Xerces compilation usages. Extracting the zip file yields the directory xalan-j_2_7_0. Within it look for the files (also downloadable from these links):
xalan.jar, xercesImpl.jar, serializer.jar
These JAR files will need to be made available to Eclipse. The easiest way, as before, is to install them directly into
apache-tomcat-5.5.17/common/lib
good luck,
-zak guler

Similar Messages

  • Working sample of JSTL:xml?

    Can someone send me a working sample war file using jstl:xml under JSTL 1.1/tomcat 5?
    I think my JSP is right, but I tried it on tomcat-5.5.4, 5.0.28 with JDK1.4.2, JDK1.5.0. All of them give me [#document: null] result. There must be something wrong in my configuration.
    If someone can send me a working war file, I would really appreciate.
    My email address: [email protected]
    Thanks!

    Okay, it is clear to me, you are thinking something that may be working is not, because you are testing incorrectly.
    Doing a c:out of the variable returned from <xml:parse> and getting [#document:  null] is not a sign that the xml document wasn't parsed. I am not sure exatly what the null part of the output means but...
    Look at this code:
    //Sidebar.xml
    <?xml version="1.0"?>
    <home_bar>
        <bar_width>250</bar_width>
        <button_height>30</button_height>
        <button_width>200</button_width>
        <button_img>images/norm_button.gif</button_img>
        <button_list>
          <button id="1">
            <link_url>./</link_url>
            <text>Home</text>
          </button>
          <button id="2">
            <link_url>/Calendar</link_url>
            <text>Calendar</text>
          </button>
          <button id="3">
            <link_url>/Calendar/howto.jsp</link_url>
            <text>How To Use the Calendar</text>
          </button>
          <button id="4">
            <link_url>/Webmail</link_url>
            <text>Webmail</text>
          </button>
          <button id="5">
            <link_url>/Webmail/howto.jsp</link_url>
            <text>Webmail HowTo</text>
          </button>
          <button id="6">
            <link_url>/Web/howto.jsp</link_url>
            <text>How To Make a Web Page</text>
          </button>
          <button id="7">
            <link_url>/HTML/howto.jsp</link_url>
            <text>Learn HTML</text>
          </button>
          <button id="8">
            <link_url>/JS/howto.jsp</link_url>
            <text>Learn JavaScript</text>
          </button>
        </button_list>
    </home_bar>
    //Sidebar.jsp
    <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
    <%@ taglib prefix="x" uri="http://java.sun.com/jsp/jstl/xml" %>
      <c:import var="sideBarXml" url="Sidebar.xml" />
      <x:parse doc="${sideBarXml}" var="sideBar" />
      <%-- Show that the side bar was read --%>
        <!-- Side Bar = <c:out value="${sideBar}"/> -->
      <%-- End of Test Output --%>
      <x:set var="theBar" select="$sideBar/home_bar"/>
      <style type="text/css">
        .sidebar
          width  : <x:out select="$theBar/bar_width"/>px;
          float  : left;
          clear  : left;
        .button
          background : transparent url(<x:out select="$theBar/button_img"/>) no-repeat scroll center;
          height     : <x:out select="$theBar/button_height"/>px;
          width      : <x:out select="$theBar/button_width"/>px;
          cursor     : pointer;
          float      : left;
          clear      : left;
          text-align : center;
          color      : white;
      </style>
      <div class="sidebar">
         <x:forEach select="$theBar/button_list/button" var="button" varStatus="status">
           <div class="button" onclick="document.location='<x:out select="$button/link_url"/>';">
             <x:out select="$button/text"/>
           </div>
         </x:forEach>
      </div>
    //index.jsp
    <html>
      <head>
        <title>Showing JSTL:XML tags</title>
        <style type="text/css">
          DIV.content
            disaplay: block;
            float   : left;
            clear   : right;
            width   : 500px;
            font-family: Serif;
        </style>
      </head>
      <body>
        <jsp:include page="Sidebar.jsp"/>
        <div class="content">
          Just some things to show for the content of the JSP...
        </div>
      </body>
    </html>
    //WEB-INF/web.xml
    <?xml version="1.0" encoding="ISO-8859-1"?>
    <web-app xmlns="http://java.sun.com/xml/ns/j2ee"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee web-app_2_4.xsd"
        version="2.4">
      <display-name>XML Display Application</display-name>
    </web-app>
    //HTML Output
    <html>
      <head>
        <title>Showing JSTL:XML tags</title>
        <style type="text/css">
          DIV.content
            disaplay: block;
            float   : left;
            clear   : right;
            width   : 500px;
            font-family: Serif;
        </style>
      </head>
      <body>
        <!-- Side Bar = [#document: null] -->
      <style type="text/css">
        .sidebar
          width  : 250px;
          float  : left;
          clear  : left;
        .button
          background : transparent url(images/norm_button.gif) no-repeat scroll center;
          height     : 30px;
          width      : 200px;
          cursor     : pointer;
          float      : left;
          clear      : left;
          text-align : center;
          color      : white;
      </style>
      <div class="sidebar">
         <div class="button" onclick="document.location='./';">
             Home</div>
         <div class="button" onclick="document.location='/Calendar';">
             Calendar</div>
         <div class="button" onclick="document.location='/Calendar/howto.jsp';">
             How To Use the Calendar</div>
         <div class="button" onclick="document.location='/Webmail';">
             Webmail</div>
         <div class="button" onclick="document.location='/Webmail/howto.jsp';">
             Webmail HowTo</div>
         <div class="button" onclick="document.location='/Web/howto.jsp';">
             How To Make a Web Page</div>
         <div class="button" onclick="document.location='/HTML/howto.jsp';">
             Learn HTML</div>
         <div class="button" onclick="document.location='/JS/howto.jsp';">
             Learn JavaScript</div>
         </div><div class="content">
          Just some things to show for the content of the JSP...
        </div>
      </body>
    </html>The WEB-INF/lib directory contains jstl.jar and standard.jar (JSTL 1.1.1 I think). Nothing but basic Tomcat 5.0.29 installed in the common directories. JDK1.4 installed.
    Anyway, from the output, you can see in the comment inside the HTML source that the c:out for the parsed XML file reads [#document: null]. However, the XML was correctly parsed and generated the proper sidebar.
    I know that if you do something like this:
    <x:set var="theBar" select="$sideBar/home_bar"/>
    <c:out value="${theBar}"/> you get [[home_bar: null]].
    Also, if you do:
    <x:out select="$sideBar"/> you will get all the data from the xml file (not the tags) printed out.

  • JSTL XML problem

    I use Tomcat 5.5.4, Jarkata JSTL 1.1.2, here is what I do:
    (1) copy JSTL jar (standard.jar, jstl.jar) to tomcat common/lib directory
    (2) create a jsp page like:
    <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
    <%@ taglib prefix="x" uri="http://java.sun.com/jsp/jstl/xml" %>
    <c:import var="data" url="sample.xml" />
    <x:parse var="res" doc="${data}" />
    if I print ${data}, it is correct XML file as I expected. But I always get [document:null] as XML parsing result.
    Besides, whatever JSTL XML function I try, seems all of them give me error or null result.
    Is there any special setting that I miss?
    Why JSTL:core works and JSTL:xml doesn't?
    Anyone have suggestion? Thanks!

    To answer your questions from the previous post: No, I don't have Xalan.jar anywhere, unless it is packaged inside of some other jar, like one of the commons jars.
    I am using Tomcat 5.0.29 or real close to it. Java 1.4.2.
    A further question:
    Do I really need copy c.tld and x.tld to WEB-INF/ and
    set them up in WEB-INF/web.xml?
    No. The tlds inside the JARs are all you need. I would get rid of these copies.
    My understanding is: since you specify that uri:
    http://java.sun.com/jsp/jstl/core, there is no need
    to copy and set-up tld.
    At least, if I remove them, JSTL:core works fine. As
    for JSTL:xml, it doesn't work either way.What version of the web descriptor are you using? Version 2.3 or 2.4? It should either be defined is a <?DOCTYPE... ?> tag (v 2.3) or in the <web-app ...> tag (v. 2.4). You should be using the vs. 2.4.
    I don't know if that would make a difference though...

  • Problem in using request parameters in jstl xml code

    hi,
    my need is to get a request parameter and use the variable in jstl(xml) select conditions.
    my code is ,
    <%String txname=request.getParameter("tname");%>
    <x:forEach var="fe" select="$doc/transaction/tx[@tname=${txname}]/field">
         <field>ss <x:out select="$fe/@fname"/> </field>
    </x:forEach>
    i'm using tomcat5.0. I deployed the jstl.jar, standard.jar, jaxen.jar and saxpath.jar in WEB-INF/lib directory.
    I able to run other jstl(xml) files which doesn't need any variables from out side.
    i used the scirpt for getparameter as i unable to get the code ${param.tname}
    help me.
    urs
    pavan.

    Looks like you haven't imported the taglib:
    JSTL1.0: <%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>
    JSTL1.1: <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
    You use JSTL1.0 in JSP1.2 containers (eg Tomcat 4)
    You use JSTL1.1 in JSP2.0 containers (eg Tomcat 5)
    also check this post if you have further troubles. It has basic troubleshooting for JSTL.

  • Problem using JSTL XML tags.

    My xml tag is giving problems. All other tags (core/sql and EL) are working fine. Even a very simple code like :
    <%@ taglib prefix="x" uri="http://java.sun.com/jsp/jstl/xml" %>
    <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
    <!-- parse an XML document -->
    <x:parse var="simple">
    <a>
    <b>
    <c>C </c>
    </b>
    <d>
    <e> E </e>
    </d>
    </a>
    </x:parse>
    <!-- display using XPath expressions -->
    <x:out select="$simple//e"/>
    gives error as :
    javax.servlet.ServletException: Cannot inherit from final class
         org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:867)
         org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:800)
         org.apache.jsp.jsp.xml.first_jsp._jspService(first_jsp.java:65)
         org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:133)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
         org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:311)
         org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:301)
         org.apache.jasper.servlet.JspServlet.service(JspServlet.java:248)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
    Pls. help!

    Works with no problems for me. (same exact code posted into a JSP)
    Running on Tomcat 5, Java1.4
    What server are you running, and version of java?
    Is there anything else on the page? Are you extending a class somehow?
    Do you have any extra libraries in the web-inf/lib directory that might be conflicting?

  • How to count number of xml nodes , with JSTL XML api?

    I am trying to count the number of nodes in the parsed xml by doing this:
    <x:out select="count($doc/Items/Item)"/>
    There are about 50 item nodes in the source xml, but I get the output as 0
    Is this syntax correct?
    I searched every where but couldn't find the xpath syntax to be used inside jstl xml tags, I was assuming that it's the same as the syntax used in xslt

    Thank you for your reply, sorry I wasnt very clear with my question.
    I want to count the number of nodes inside the jsp file , not inside the xslt file.
    My xml file is something like this for example:
    <?xml version="1.0" encoding="UTF-8"?>
    <DocumentRootNode>
    <Products>
    <Item>1</Item>
    <Item>2</Item>
    <Item>3</Item>
    <Products>
    </DocumentRootNode>
    I want the count of number of Item nodes , in the JSP file.
    I'm doing something like this in the JSP but it gives 0 instead of 3:
    <c:import url="source.xml" var="xml" charEncoding="UTF-8"/>
    <x:parse doc="${xml}" var="xml_doc"/>
    <x:out select="count($xml_doc/Products/Item)"/>
    null

  • JSTL xml not working

    Hi,
    I'm trying to parse an xml document using JSTL XML libraries. The following is a code snippet from my app:
    <x:parse var="ox" xml="${xml}"/>
         <x:set var="pageItemCount" select='count($ox/osSummary/summaryGroup/summaryItem)'/>
         <x:set var="totalRecords" select="string($ox/osSummary/totalRecords)" scope="request"/>
         <c:set var="pages" value="${totalRecords / qp.pageSize}" scope="request"/>
    <<x:forEach var="n" select="$ox/osSummary/summaryGroup/summaryItem">
    I have verified that the 'xml' variable holds the xml document. However, the <x:parse> function does not seem to parse the XML.
    I am guessing there is something wrong with the JSTL version i'm using. If so, how to i change that? I'm using WAS 6.0
    thanks,
    Vasanth

    Had a maybe similar problem a short while ago. Browse this thread and see if that seems like it. Good luck!
    http://forum.java.sun.com/thread.jspa?threadID=5236722
    John

  • Reload web-inf/web.xml file without restarting tomcat

    Please help me if any one have a solution .
    I am doing development in jsp, servlet. I am using tomcat5 as a webserver.
    i want to reload web-inf/web.xml file without restarting tomcat.

    From the tomcat admin page you can stop/start and refresh individual applications. See the tomcat documentation. Which, when you have a question about tomcat, you should always do first.

  • JSP/JSTL & XML

    I am trying to have JSP pages parse and read an XML file and then return some data in an HTML table. I'm using the JSTL libraries and have a basic understanding of them, but I apparently need help.
    My first page just gets the value and passes it to the second page. The second page handles all of the processing. Here is my JSP page:
    <%@page contentType="text/html" %>
    <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
    <%@ taglib prefix="x" uri="http://java.sun.com/jsp/jstl/xml" %>
    <%@include file="index.jsp" %>
    <% String clientID = request.getParameter("enteredID"); %>
    <c:import url="npiXMLTest5.xml" var="doc" />
    <x:parse varDom="dom" doc="${doc}"/>
    <x:set var="srcCID" select="string($dom/npiNumbers/client/clientNum)" />
    <html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>NPI XJTL Test</title></head>
    <body>
    <c:set var="CID" value="<%= clientID %>" />
    <h2>NPI XJTL Test Page</h2>
    <table border="1">
    <tr><th>NPI Number</th><th>Description</th></tr>
    <c:choose>
    <c:when test="${CID}=${srcCID}">
    <x:forEach select="$dom/npiNumbers/client/npiNum" var="$n">
    <tr><td><x:out select="$n/npi" /></td><td><x:out select="$n/desc" /></td></tr>
    </x:forEach>
    </c:when>
    <c:otherwise>
    There is an error with your coding
    </c:otherwise>
    </c:choose>
    </table></body></html>My XML structure is as follows:
    <npiNumbers xsi:schemaLocation="http://localhost/namespace NPI_XSD5.xsd" xmlns="http://localhost/namespace" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <client>
    <clientNum/>
    <clientName/>
    <npiNum>
    <npi/>
    <desc/>
    </npiNum>
    </client>
    </npiNumbers>I am trying to return the results of the <npiNum> element (which can have multiple values) - <npi> and <desc> - in a table based on the <clientNum> element. I try to evaluate the page variable with the xml element. If it matches, I will return a table. A client can have multiple <npiNum> elements, so the construction of the table is in the x:forEach loop.
    I think my problem is getting the variable from JSP to compare against the <clientNum> element in the XML file.
    Any ideas?

    I think your problem is less JSP/JSTL and more querying the XML.
    You are trying to "select all <npinum> elements from a client based on clientnum"
    I am far from an expert on XPath, but I think the following query is what you are after: "/npinumbers/client[clientNum=????]/npiNum"
    To do that with JSTL you would replace ???? with $param:enteredId or $CID (equivalent in your example)
    Here is the resulting JSP page.
    <%@page contentType="text/html" %>
    <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
    <%@ taglib prefix="x" uri="http://java.sun.com/jsp/jstl/xml" %>
    <c:import url="npiXMLTest5.xml" var="doc" />
    <x:parse varDom="dom" doc="${doc}"/>
    <html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>NPI XJTL Test</title></head>
    <body>
    <c:set var="CID" value="${param.enteredId}" />
    <h2>NPI XJTL Test Page</h2>
    <table border="1">
    <tr><th>NPI Number</th><th>Description</th></tr>
    <x:forEach select="$dom/npiNumbers/client[clientNum=$CID]/npiNum" var="n">
      <tr><td><x:out select="npi" /></td><td><x:out select="desc" /></td></tr>
    </x:forEach>
    </table>
    <hr>
    <form>
    <input type="text" name="enteredId"/>
    <input type="submit">
    </form>
    </body></html>I made up the following test file to use with it. I don't know if it was exactly what your requirements are, but it was a best guess based on your info.
    <npiNumbers>
         <client>
              <clientNum>42</clientNum>
              <clientName>Ford Prefect</clientName>
              <npiNum>
                   <npi>123</npi>
                   <desc>life</desc>
              </npiNum>
              <npiNum>
                   <npi>234</npi>
                   <desc>universe</desc>
              </npiNum>
              <npiNum>
                   <npi>456</npi>
                   <desc>everything</desc>
              </npiNum>          
         </client>
         <client>
              <clientNum>666</clientNum>
              <clientName>Satan</clientName>
              <npiNum>
                   <npi>333</npi>
                   <desc>Baby Devil</desc>
              </npiNum>
         </client>
    </npiNumbers>Cheers,
    evnafets

  • Combing jstl/xml tags with jsf - can't pass parameter

    I'm using the jstl/xml tags to parse portions of an xml document. For some value of an attribute I want to render a search link, many of these links may be rendered on a page and I need to track which one has actually been selected using the id of the generating xml element.
    This is what I've tried, both using h:commandLink and a f:param and t:commandLink (tomahawk) and a t:updateActionListener.
    It doesn't seem to be possible to expose the resolved value of the xpath ="@id" in any way that either the tomahawk or core jsf tags can see.
    <x:when select="$control[@type='SEARCH']">
    <input type="text" id='<x:out select="@id"/>' disabled="true">
    <x:set var="selectedId" select="@id"/>
    <h:commandLink action="#{pack.search}" value="#{msg['actionPack.label.search']}" styleClass="linkNoUnderline">
    <f:param value="${selectedID}" name="selectedID"/>
    </h:commandLink>
    <%--<t:commandLink action="#{pack.search}" value="#{msg['actionPack.label.search']}" styleClass="linkNoUnderline">
    <t:updateActionListener property="#{pack.searchingId}" value="${searchId}"/>
    </t:commandLink>--%>
    </x:when>

    The JSF and JSTL tags don't really play well together.
    Particularly conditional and looping tags.
    My suggestion would be - if you're using JSF, don't use JSTL.
    You are right in that the JSF tags don't bother with the xpath expression.
    Would it be possible to shift the xml logic into an action/bean somewhere, and just present the jsp page with a list of relevant objects?
    If I understand you are trying to determine which link was clicked on a page? In the JSF action "pack.search"?
    What method of iterating are you using? an x:forEachLoop? A datatable?

  • Build XML Document in Servlet use JSTL xml tags in JSP

    Is it possible to build an XML document either org.w3c.dom.Document or preferably org.jdom.Document in a Servlet and pass it as a Bean or Bean property to a JSP and use it in the JSTL xml tags? If so how is it done? I don't want to write the document out to a file.
    Thanks
    Mark

    Both DOM and JDOM allow you to serialize XML to an output stream. Use the StringWriter as the output stream and when its finished you will have the XML in a String. Put the String in the Request scope and your JSP should be able to see it.

  • Tomcat connection refused from localhost

    I have Tomcat 5.5.7 installed as a stand-alone server on my local machine. I have installed Java jre 1.5.0 (5.0). The OS is Windows 2000 SP3. The install went without incident. I set system variables JAVA_HOME, CATALINA_HOME, TOMCAT_HOME.
    When I try to access anything using tomcat, I get "The connection was refused when contacting ......" I've used ...
    http://localhost
    http://localhost :8080
    http://127.0.0.1
    http://127.0.0.1:8080
    ...and a number of variations to get at the webapps area. All give exactly the same response.
    I can ping myself, but when I run Steve Gibson's IS Serve, it tells me the port is closed.
    I think I have server.xml set up correctly. Any ideas. Any help will be appreciated. Thanks.
    - Ed Lipchus

    did you try installing tomcat as a windows service
    download tomcat.exe and double click and follow instructions

  • Can't parse xml file in jar file when  can't connect to web server

    My JNLP application throw ConnectException when trying to parse xml during web server offline.
    Steps,
    1. JNLP application has been launched once and all related jar and xml files are already downloaded to local cache.
    2. Then I close web server to test offline launch.I launch the JNLP application using shortcut with -offline parameter.
    3. However the JRE internal xml parser tries to connect to web server and report connection error as web server is down now.
    My concern is the file is already in the cache, why java still try to connect URL. This error happens in JRE 1.5, but it doesn't happen in JRE 1.6. It only happens when web server is down in JRE 1.5.
    I think it may be a bug of JRE, do any one can give me some hint about how to resolve?
    Thanks in advance!!
    I also moved the code piece to a simple web start example, following it the error and code pieces.
    Error Trace in Java console,
    ava.net.ConnectException: Connection refused: connect
         at java.net.PlainSocketImpl.socketConnect(Native Method)
         at java.net.PlainSocketImpl.doConnect(Unknown Source)
         at java.net.PlainSocketImpl.connectToAddress(Unknown Source)
         at java.net.PlainSocketImpl.connect(Unknown Source)
         at java.net.Socket.connect(Unknown Source)
         at java.net.Socket.connect(Unknown Source)
         at sun.net.NetworkClient.doConnect(Unknown Source)
         at sun.net.www.http.HttpClient.openServer(Unknown Source)
         at sun.net.www.http.HttpClient.openServer(Unknown Source)
         at sun.net.www.http.HttpClient.<init>(Unknown Source)
         at sun.net.www.http.HttpClient.New(Unknown Source)
         at sun.net.www.http.HttpClient.New(Unknown Source)
         at sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(Unknown Source)
         at sun.net.www.protocol.http.HttpURLConnection.plainConnect(Unknown Source)
         at sun.net.www.protocol.http.HttpURLConnection.connect(Unknown Source)
         at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)
         at sun.net.www.protocol.jar.URLJarFile.retrieve(Unknown Source)
         at sun.net.www.protocol.jar.URLJarFile.getJarFile(Unknown Source)
         at sun.net.www.protocol.jar.JarFileFactory.get(Unknown Source)
         at sun.net.www.protocol.jar.JarURLConnection.connect(Unknown Source)
         at sun.net.www.protocol.jar.JarURLConnection.getInputStream(Unknown Source)
         at com.sun.org.apache.xerces.internal.impl.XMLEntityManager.setupCurrentEntity(Unknown Source)
         at com.sun.org.apache.xerces.internal.impl.XMLEntityManager.startEntity(Unknown Source)
         at com.sun.org.apache.xerces.internal.impl.XMLEntityManager.startDTDEntity(Unknown Source)
         at com.sun.org.apache.xerces.internal.impl.XMLDTDScannerImpl.setInputSource(Unknown Source)
         at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$DTDDispatcher.dispatch(Unknown Source)
         at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
         at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
         at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
         at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(Unknown Source)
         at com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(Unknown Source)
         at com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(Unknown Source)
         at javax.xml.parsers.DocumentBuilder.parse(Unknown Source)
         at EntXmlUtil.buildDocument(EntXmlUtil.java:57)
         at Notepad.testParseXML(Notepad.java:870)
         at Notepad.main(Notepad.java:153)
         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
         at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
         at java.lang.reflect.Method.invoke(Unknown Source)
         at com.sun.javaws.Launcher.executeApplication(Unknown Source)
         at com.sun.javaws.Launcher.executeMainClass(Unknown Source)
         at com.sun.javaws.Launcher.continueLaunch(Unknown Source)
         at com.sun.javaws.Launcher.handleApplicationDesc(Unknown Source)
         at com.sun.javaws.Launcher.handleLaunchFile(Unknown Source)
         at com.sun.javaws.Launcher.run(Unknown Source)
         at java.lang.Thread.run(Unknown Source)
    Notepad.java
    public void testParseXML() {
         URL xmlURL=Notepad.class.getClassLoader().getResource("xml/Login.xml");
         try {
                   org.w3c.dom.Document doc = EntXmlUtil.buildDocument(xmlURL);
                   System.out.println("Test"+doc);
              } catch (Exception e) {
                   // TODO Auto-generated catch block
                   e.printStackTrace();
    EntXMLUtil.java
    private static DocumentBuilderFactory dbf = null;
         static {
              dbf = DocumentBuilderFactory.newInstance();
              dbf.setNamespaceAware(true);
              dbf.setValidating(true);
              dbf.setIgnoringComments(true);
              dbf.setIgnoringElementContentWhitespace(true);
    public static DocumentBuilderFactory getDocBuilderFactory() {
              return EntXmlUtil.dbf;
    public static Document buildDocument(URL url, String systemId) throws Exception {
              DocumentBuilder db;
              Document doc;
              InputStream is;
              String sysId = null;
              if(systemId == null)
                   sysId = url.toExternalForm();
              else
                   sysId = systemId;
              db = EntXmlUtil.getDocBuilderFactory().newDocumentBuilder();
              is = url.openStream();
              doc = db.parse(is, sysId);
              is.close();
              return doc;
         }

    I finally got a temperary work around for this issue, using JRE5 version lower than update 16(not include update 16).
    i found Sun modify the URL which returned by XXX.class.getClassLoader().getResource("xml/Test.xml,") after update 15, previous it is related with the cache path, like C:\Users\epenwei\AppData\LocalLow\Sun\Java\Deployment\cache\javaws\http\Dlocalhost\P80\DMEntriView\DMapp\AMNotepad.jar!/xml/Test.xml, but after it changes to network path, like http://localhost/Notepad/app/notepad.jar!/xml/Test.xml. However, the latter address doesn't work in Sun's own class com.sun.org.apache.xerces.internal.impl.XMLEntityManager.setupCurrentEntity if offline.It tried to create new URL then connect to web server. So exception is thrown since web server is down.
    if (reader == null) {
    stream = xmlInputSource.getByteStream();
    if(stream != null && encoding != null)
    declaredEncoding = true;
    if (stream == null) {
    URL location = new URL(expandedSystemId);
    URLConnection connect = location.openConnection();
    if (connect instanceof HttpURLConnection) {
         setHttpProperties(connect,xmlInputSource);
    I am not sure whether it is a Java new bug since I only read the codes and didn't debug Sun code. But I am very curious that I have already specify <j2se version="1.5.0_12" href="http://java.sun.com/products/autodl/j2se" /> to specify update 12 for my jws application. And I also see the Java console display like following
    Java Web Start 1.5.0_18
    Using JRE version 1.5.0_12 Java HotSpot(TM) Client VM
    Why java still uses my latest jre lib to run my application?
    Edited by: wei000 on May 22, 2009 5:32 AM

  • Connection refused Exception parsing an xml on a network drive

    I am getting a "java.net.ConnectException: Connection refused: connect" exception when I try to parse an xml file over a network drive with a url like "\\Host\shared\file.xml". The problem only happens if I use a full qualified url to the file, if I map the drive to the local server then it works fine. This means that "\\Host\shared\file.xml" fails while "G:\file.xml" works but the two point to the same file. The other thing is that it fails for JDK 1.4.0 but works file for JDK1.3.1. Same program, same classpath, same server: it works with JDK1.3.1 but throws the exception for JDK1.4.0. Following is the full exception trace:
    java.net.ConnectException: Connection refused: connect
    at java.net.PlainSocketImpl.socketConnect(Native Method)
    at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:295)
    at java.net.PlainSocketImpl.connectToAddress PlainSocketImpl.java:161)
    at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:148)
    at java.net.Socket.connect(Socket.java:425)
    at java.net.Socket.connect(Socket.java:375)
    at sun.net.NetworkClient.doConnect(NetworkClient.java:139)
    at sun.net.NetworkClient.openServer(NetworkClient.java:118)
    at sun.net.ftp.FtpClient.openServer(FtpClient.java:387)
    at sun.net.ftp.FtpClient.<init>(FtpClient.java:651)
    at sun.net.www.protocol.ftp.FtpURLConnection.connect(FtpURLConnection.ja
    va:175)
    at sun.net.www.protocol.ftp.FtpURLConnection.getInputStream(FtpURLConnec
    tion.java:257)
    at java.net.URL.openStream(URL.java:955)
    at org.apache.xerces.readers.DefaultReaderFactory.createReader(DefaultRe
    aderFactory.java:149)
    at org.apache.xerces.readers.DefaultEntityHandler.startReadingFromDocume
    nt(DefaultEntityHandler.java:491)
    at org.apache.xerces.framework.XMLParser.parseSomeSetup(XMLParser.java:3
    12)
    at org.apache.xerces.framework.XMLParser.parse(XMLParser.java:1080)
    at org.apache.xerces.framework.XMLParser.parse(XMLParser.java:1122)

    From the stack trace posted it appears that URL.openStream decided to use FTP to access the file. Of course that won't work. But the key is that a URL is expected, at least that's what I infer from this line:
    at java.net.URL.openStream(URL.java:955)
    And \\Host\shared\file.xml isn't a URL. Looks like 1.4 has fixed something which broke that shortcut. Change it to a real URL, something like
    file:////Host/shared/file.xml
    Four / is probably correct, although you may have to try it with three.

  • Init-params in web.xml are not loaded (Tomcat 4)

    Hello all...
    I register a servlet in webapps/<my-servlet>/WEB-INF/web.xml file, and pass 1 <init-param> tag. The file gets parsed (I know because when I made errors tomcat complained during initialization). However, when in the init method of the servlet I try to access this parameter, its not there. In fact, the servlet has NO init params at all.
    =================================================
    I have the following web.xml file
    <?xml version="1.0" encoding="ISO-8859-1"?>
    <!DOCTYPE web-app
    PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
    "http://java.sun.com/dtd/web-app_2_3.dtd">
    <web-app>
    <servlet>
    <servlet-name>XServlet</servlet-name>
    <servlet-class>com.fxcm.xml.xengine.xdas.XServlet</servlet-class>
    <init-param>
    <param-name>xengine.configFile</param-name>
    <param-value>c:/projects/re/das.config/config.xng</param-value>
    </init-param>
    </servlet>
    <servlet-mapping>
         <servlet-name>XServlet</servlet-name>
         <url-pattern>/xservlet</url-pattern>
    </servlet-mapping>
    </web-app>
    =======================================================
    I have the following servlet
    * XServlet.java
    * Created on May 6, 2002, 1:17 PM
    package com.fxcm.xml.xengine.xdas;
    import javax.servlet.*;
    import javax.servlet.http.HttpServlet;
    import java.io.IOException;
    import java.io.PrintWriter;
    import javax.servlet.ServletException;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    import javax.servlet.ServletConfig;
    import java.util.Enumeration;
    import com.fxcm.xml.xengine.XEngine;
    public class XServlet extends HttpServlet{
    /** Initiates new XServlet */
    public void init(ServletConfig config)
    throws ServletException
              for (Enumeration e = config.getInitParameterNames(); e.hasMoreElements();){
    //This statement never gets printed because the loop never enters here since there are no init parameters
                   System.out.println(e.nextElement());
    super.init(config);
    String str = config.getInitParameter("xengine.configFile");
    System.out.println(str);
    XEngine.init(str.trim()); //This line throws NullPointer, because str is null since there are no initParameters.
    public void doPost(HttpServletRequest req, HttpServletResponse res)
    throws ServletException, IOException{
    // res.setContentType( );
              System.out.println("Got post request in XServlet");
    PrintWriter out = res.getWriter();
    out.println(XEngine.process(req.getInputStream()));
    out.flush();
    out.close();
    ================================================================
    I get the follwoing error in the browser:
    type Exception report
    message Internal Server Error
    description The server encountered an internal error (Internal Server Error) that prevented it from fulfilling this request.
    exception
    java.lang.NullPointerException
         at com.fxcm.xml.xengine.xdas.XServlet.init(Unknown Source)
         at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:918)
         at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:655)
         at org.apache.catalina.servlets.InvokerServlet.serveRequest(InvokerServlet.java:400)
    Please help.
    Thank you,
    Elana

    I know what the problem is. If you call servlet with the default URL (http://host/app/servlet/package.Servlet) than Servlet DOES NOT read init parameters. I don't know why it was designed this way.
    To make servlet read init parameters, you have to assign it a name and then call it with that name, like this:
    <servlet>
    <servlet-name>ServletName</servlet-name>
    <servlet-class>package.ServletClass</servlet-class>
    </servlet>
    <servlet-mapping>
    <servlet-name>ServletName</servlet-name>
    <url-pattern>/app/path/ServletName</url-pattern>
    </servlet-mapping>
    You can then call servlet using path specified in url-pattern and read init parameters in the normal way.

Maybe you are looking for

  • ISE Best Practice for Purging Endpoints

    Maybe I haven't looked long enough or deep enough through the documents and guides, but I am wondering if there is a best practice for purging endpoints in general. For my guest endpoints, I have it set to purge those endpoints every 3 days. When i l

  • Content conversion sender keyfield + unknow length field

    hi, I have a file with lines. the first six chars of each line tells me which type of line it is. I need to split the file to files which contains only one  type of lines each. I bulit data type with 2 fields : ID - length = 6 chars, Data - length un

  • Performance issues, possibly video.

    My computer is by no means new (p4 2.4, 2GB, 128MB AGP video), however, I get particularly crappy performance through most simple tasks. Scrolling in any browswer is SUPER choppy (CPU usage of browser & Xorg spikes when scrolling). Window performance

  • Forcing to use F4 help for a field

    Currently if we enter Partner Number or First name or Last name of a partner in Contacts, Employee and Service Group fields, and click on enter we are getting the relevent BP full name. This happens even if we enter Contact BP number in Employee fiel

  • 4 Types of exception and the code to handle them

    Dear all, I would like to know wheter runtime exception, errors exception, unchecked exception and checked exception are classified as the 4 types of exception. What are the java coding of them? please help.