You are viewing a plain text version of this content. The canonical link for it is here.
Posted to general@jakarta.apache.org by Pawan Pandey <pa...@mediaring.com.sg> on 1999/11/28 10:37:30 UTC

Error in startup

Hi

I am new to this mailing list so i dont exactly know the status.

 i have a problem, i have downloaded tomcat(v tomcat-19991123.tar.Z)

i have unpacked it and now when i try to start it up it gives me following
error-

SAXParseException: file:/opt/local/tomcat/server.xml : 5
  msg : java.lang.NullPointerException

(where /opt/local/tomcat is the home directory of all tomcat files)

I tried to find out what is the cause of error  and i could trace it back to
this line -
                String s3 = urlconnection.getContentType();
in com.sun.xml.parser.Resolver class

I dont know why ,but getContentTypeFor() method(called from
org.apache.tomcat.protocol.WARConnection.getContentType()) is throwing
nullpointerexception

any help as to how to overcome this problem is solicited

thanx in advance

pawan


Re: Error in startup

Posted by Bob Jamison <rj...@lincom-asg.com>.

Pawan Pandey wrote:

>  i have a problem, i have downloaded tomcat(v tomcat-19991123.tar.Z)
>
> i have unpacked it and now when i try to start it up it gives me following
> error-
>
> SAXParseException: file:/opt/local/tomcat/server.xml : 5
>   msg : java.lang.NullPointerException
>
> For additional commands, e-mail: general-help@jakarta.apache.org

Pawan,

I found this same problem a few days ago, and sent a msg to this list
showing what I found, and a little hack that works for me:
Hope this helps.




----SNIP---




On line 281 of URLConnection.java

    /**
     * Returns the FileNameMap.
     *
     * @returns the FileNameMap
     * @since JDK1.2
     */
    public static FileNameMap getFileNameMap() {
 return new FileNameMap() {
            public String getContentTypeFor(String fileName) {
                return fileNameMap.getContentTypeFor(fileName);
            }
        };
    }


The effect of the static call depending on fileNameMap not
being null brings about the danger of a NullPointerException,
which definitely happens in WARConnection.java, line 147,
generating a SAXParseException from line 5 of the server.xml
file (when it is getting the mime-type for a .dtd file).



    public String getContentType() {
        // XXX
        // hmmm .. what about the mimeTypes associated with
        // this context
        return URLConnection.getFileNameMap().getContentTypeFor(path);
    }

It seems that on the platforms where I have seen Tomcat working,
(Linux, Windows, Solaris), this call is working, thus fileNameMap
is being previously set.  However, I see nowhere in the API any
requirement that this be the case, so although I sent the bug in to
SGI, this might be an instance where Tomcat needs to be a bit more
architecture-proof for portability.  This might actually be a problem
in ProjectX (who knows?  ;-)

It appears from the code, that what is desired, is knowing that the
file is -not- an xml (I may be wrong).   Thus this little addition I put
in
the constructor of WARConnection, at line 90, seems to do the job
fine:

    public WARConnection (URL url)
    throws MalformedURLException {
        super(url);

    parseSpecs(url);
    setFileNameMap(new java.net.FileNameMap(){
           public String getContentTypeFor(String fileName) {
           if (fileName==null || fileName.length()<1)
             return null;
           String name=fileName.toLowerCase();
           String type=null;
           if (name.endsWith(".xml"))
             type="text/xml";
           else if (name.endsWith(".dtd"))
             type="text/dtd";
           else
             type="application/unknown";
           return type;
           }

    });
    }

I might have the types or the reasoning wrong, but the code works,
and Tomcat boots nicely now on Irix/JDK 1.2.1.


Bob Jamison
Sr. Software Engr
LinCom Corp




Re: Error in startup

Posted by Aaron Tavistock <aa...@ten.net>.
Just wanted to throw in my two cents that this is not an isolated
incident.  I'm having the same problem and am not sure on how to resolve
it.

If someone know the answer to this one, please post it to the group.

Pawan Pandey wrote:
> 
> Hi
> 
> I am new to this mailing list so i dont exactly know the status.
> 
>  i have a problem, i have downloaded tomcat(v tomcat-19991123.tar.Z)
> 
> i have unpacked it and now when i try to start it up it gives me following
> error-
> 
> SAXParseException: file:/opt/local/tomcat/server.xml : 5
>   msg : java.lang.NullPointerException
> 
> (where /opt/local/tomcat is the home directory of all tomcat files)
> 
> I tried to find out what is the cause of error  and i could trace it back to
> this line -
>                 String s3 = urlconnection.getContentType();
> in com.sun.xml.parser.Resolver class
> 
> I dont know why ,but getContentTypeFor() method(called from
> org.apache.tomcat.protocol.WARConnection.getContentType()) is throwing
> nullpointerexception
> 
> any help as to how to overcome this problem is solicited
> 
> thanx in advance
> 
> pawan
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: general-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: general-help@jakarta.apache.org