You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by Glenn Nielsen <gl...@voyager.apg.more.net> on 2001/03/20 21:39:30 UTC

Tomcat 4, webapp running from WAR file

Is the ability to run from a WAR file directly without unarchiving it
into the webapps directory completely implemented?

Jasper gives me a null pointer when it tries to see if a JSP needs
to be recompiled in its Outdated method because getRealPath() returns null,
getServletConfig().getServletContext().getRealPath(jspUri));

java.lang.NullPointerException
        at java.io.File.<init>(File.java:181)
        at org.apache.jasper.compiler.JspCompiler.isOutDated(JspCompiler.java:175)
        at org.apache.jasper.compiler.Compiler.compile(Compiler.java:118)
        at org.apache.jasper.servlet.JspServlet.loadJSP(JspServlet.java:488)
        at org.apache.jasper.servlet.JspServlet$JspServletWrapper.loadIfNecessary(Js
pServlet.java:158)
        at org.apache.jasper.servlet.JspServlet$JspServletWrapper.service(JspServlet
.java:170)
        at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:340)
        at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:418)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
        ...

Glenn

----------------------------------------------------------------------
Glenn Nielsen             glenn@more.net | /* Spelin donut madder    |
MOREnet System Programming               |  * if iz ina coment.      |
Missouri Research and Education Network  |  */                       |
----------------------------------------------------------------------

Re: Tomcat 4, webapp running from WAR file

Posted by Glenn Nielsen <gl...@voyager.apg.more.net>.
Remy Maucherat wrote:
> 
> Quoting Glenn Nielsen <gl...@voyager.apg.more.net>:
> 
> > Is the ability to run from a WAR file directly without unarchiving it
> > into the webapps directory completely implemented?
> 
> No, I'm working on some fixes for Jasper (including one for the trace you
> included).
> 
> > Jasper gives me a null pointer when it tries to see if a JSP needs
> > to be recompiled in its Outdated method because getRealPath() returns
> > null,
> > getServletConfig().getServletContext().getRealPath(jspUri));
> 
> Here, it should use getServletConfig().getServletContext().getResource
> (jspUri).openConnection().getLastModified().
> 
> There are other places where Jasper will break because of over reliance on
> getRealPath() and getPathTranslated() (in both cases, the servlet container is
> allowed to return null, and will do so when there is no physical file on the
> filesystem).
> 
> Remy


Ok, I ran across that when I started working on implementing the logic
for how webapps are unarchived.  It sidetracked me for a bit.  I'll let
you take care of the Jasper fixes for using JSP's directly from a WAR file.

Glenn

----------------------------------------------------------------------
Glenn Nielsen             glenn@more.net | /* Spelin donut madder    |
MOREnet System Programming               |  * if iz ina coment.      |
Missouri Research and Education Network  |  */                       |
----------------------------------------------------------------------

Re: Tomcat 4, webapp running from WAR file

Posted by Remy Maucherat <re...@apache.org>.
----- Original Message -----
From: "Glenn Nielsen" <gl...@voyager.apg.more.net>
To: <to...@jakarta.apache.org>
Sent: Wednesday, March 21, 2001 6:54 AM
Subject: Re: Tomcat 4, webapp running from WAR file


> Remy,
>
> The ability to compile JSP pages directly from a WAR file without
> unarchiving jar files and class files into a work directory will not
> be possible until javac can use URL's instead of a file system classpath.
> Those changes to javac will not be available for quite a while.

I know.

> Until that time I think the Context path should exist so that
> getRealPath(), getResource(), getPathTranslated() work for jar and
> class files broken out into the work directory.

GetRealPath and getPathTranslated will return the right values if running
from the filesystem.

> I have implemented a way to dynamically build the classpath needed
> by javac using the URLClassLoader.getURLs() that works great in Jasper
> except for web apps running from a war file because I can't find any
> way to get the real system file path to the jar files or classes
directory.
> This allows decoupling of Jasper from Tomcat for the CLASSPATH attribute.

-1 for this patch.
Could you revert that, please ?
The whole thing was working very fine from a WAR yesterday evening.

The JARs and classes are copied in the work directory if they are not real
files on the filesystem, and the classpath property in the classpath can be
used by javac.

> We can put comments in both Tomcat & Jasper that this can be removed once
> javac supports URL's in addition to the classpath.

Remy


Re: Tomcat 4, webapp running from WAR file

Posted by Glenn Nielsen <gl...@voyager.apg.more.net>.
Craig, thanks for reverting those changes for Remy, you beat me to it.

"Craig R. McClanahan" wrote:
> 
> On Wed, 21 Mar 2001, Glenn Nielsen wrote:
> 
> > Remy,
> >
> > The ability to compile JSP pages directly from a WAR file without
> > unarchiving jar files and class files into a work directory will not
> > be possible until javac can use URL's instead of a file system classpath.
> > Those changes to javac will not be available for quite a while.
> >
> 
> Glenn, I'd like you to revert the recent patches you did regarding the
> Jasper classpath attribute ... at least until after beta 2.  It broke
> things that were already working for me.
> 
> > Until that time I think the Context path should exist so that
> > getRealPath(), getResource(), getPathTranslated() work for jar and
> > class files broken out into the work directory.
> >
> 
> Nope ... there is no such thing as a disk file pathname to the context
> root when you are running out of a WAR
> file.  ServletContext.getRealPath() (and therefore
> HttpServletRequest.getPathTranslated()) will return null in such a
> case.  It's up to Jasper to deal with that issue, and figure out the last
> modified date a different way -- by opening the URLConnection and checking
> the lastModified property.
> 
> ServletContext.getResource() and ServletContext.getResourceAsStream() are
> the portable mechanisms to access the static resources of the web app,
> including the source code to JSP pages.
> 
> > I have implemented a way to dynamically build the classpath needed
> > by javac using the URLClassLoader.getURLs() that works great in Jasper
> > except for web apps running from a war file because I can't find any
> > way to get the real system file path to the jar files or classes directory.
> > This allows decoupling of Jasper from Tomcat for the CLASSPATH attribute.
> >
> 
> That's why the previous code pulled out a copy of the JAR files into the
> WORK directory.  This was working right, and got broken by your patch.
> 
> > We can put comments in both Tomcat & Jasper that this can be removed once
> > javac supports URL's in addition to the classpath.
> >
> > Regards,
> >
> > Glenn
> >
> 
> Craig
> 
> > Remy Maucherat wrote:
> > >
> > > Quoting Glenn Nielsen <gl...@voyager.apg.more.net>:
> > >
> > > > Is the ability to run from a WAR file directly without unarchiving it
> > > > into the webapps directory completely implemented?
> > >
> > > No, I'm working on some fixes for Jasper (including one for the trace you
> > > included).
> > >
> > > > Jasper gives me a null pointer when it tries to see if a JSP needs
> > > > to be recompiled in its Outdated method because getRealPath() returns
> > > > null,
> > > > getServletConfig().getServletContext().getRealPath(jspUri));
> > >
> > > Here, it should use getServletConfig().getServletContext().getResource
> > > (jspUri).openConnection().getLastModified().
> > >
> > > There are other places where Jasper will break because of over reliance on
> > > getRealPath() and getPathTranslated() (in both cases, the servlet container is
> > > allowed to return null, and will do so when there is no physical file on the
> > > filesystem).
> > >
> > > Remy
> >
> > --
> > ----------------------------------------------------------------------
> > Glenn Nielsen             glenn@more.net | /* Spelin donut madder    |
> > MOREnet System Programming               |  * if iz ina coment.      |
> > Missouri Research and Education Network  |  */                       |
> > ----------------------------------------------------------------------
> >

-- 
----------------------------------------------------------------------
Glenn Nielsen             glenn@more.net | /* Spelin donut madder    |
MOREnet System Programming               |  * if iz ina coment.      |
Missouri Research and Education Network  |  */                       |
----------------------------------------------------------------------

Re: Tomcat 4, webapp running from WAR file

Posted by "Craig R. McClanahan" <cr...@apache.org>.

On Wed, 21 Mar 2001, Glenn Nielsen wrote:

> Remy,
> 
> The ability to compile JSP pages directly from a WAR file without
> unarchiving jar files and class files into a work directory will not
> be possible until javac can use URL's instead of a file system classpath.
> Those changes to javac will not be available for quite a while.
> 

Glenn, I'd like you to revert the recent patches you did regarding the
Jasper classpath attribute ... at least until after beta 2.  It broke
things that were already working for me.

> Until that time I think the Context path should exist so that
> getRealPath(), getResource(), getPathTranslated() work for jar and
> class files broken out into the work directory.
> 

Nope ... there is no such thing as a disk file pathname to the context
root when you are running out of a WAR
file.  ServletContext.getRealPath() (and therefore
HttpServletRequest.getPathTranslated()) will return null in such a
case.  It's up to Jasper to deal with that issue, and figure out the last
modified date a different way -- by opening the URLConnection and checking
the lastModified property.

ServletContext.getResource() and ServletContext.getResourceAsStream() are
the portable mechanisms to access the static resources of the web app,
including the source code to JSP pages.

> I have implemented a way to dynamically build the classpath needed
> by javac using the URLClassLoader.getURLs() that works great in Jasper
> except for web apps running from a war file because I can't find any
> way to get the real system file path to the jar files or classes directory.
> This allows decoupling of Jasper from Tomcat for the CLASSPATH attribute.
> 

That's why the previous code pulled out a copy of the JAR files into the
WORK directory.  This was working right, and got broken by your patch.

> We can put comments in both Tomcat & Jasper that this can be removed once
> javac supports URL's in addition to the classpath.
> 
> Regards,
> 
> Glenn
> 

Craig


> Remy Maucherat wrote:
> > 
> > Quoting Glenn Nielsen <gl...@voyager.apg.more.net>:
> > 
> > > Is the ability to run from a WAR file directly without unarchiving it
> > > into the webapps directory completely implemented?
> > 
> > No, I'm working on some fixes for Jasper (including one for the trace you
> > included).
> > 
> > > Jasper gives me a null pointer when it tries to see if a JSP needs
> > > to be recompiled in its Outdated method because getRealPath() returns
> > > null,
> > > getServletConfig().getServletContext().getRealPath(jspUri));
> > 
> > Here, it should use getServletConfig().getServletContext().getResource
> > (jspUri).openConnection().getLastModified().
> > 
> > There are other places where Jasper will break because of over reliance on
> > getRealPath() and getPathTranslated() (in both cases, the servlet container is
> > allowed to return null, and will do so when there is no physical file on the
> > filesystem).
> > 
> > Remy
> 
> -- 
> ----------------------------------------------------------------------
> Glenn Nielsen             glenn@more.net | /* Spelin donut madder    |
> MOREnet System Programming               |  * if iz ina coment.      |
> Missouri Research and Education Network  |  */                       |
> ----------------------------------------------------------------------
> 


Re: Tomcat 4, webapp running from WAR file

Posted by Glenn Nielsen <gl...@voyager.apg.more.net>.
Remy,

The ability to compile JSP pages directly from a WAR file without
unarchiving jar files and class files into a work directory will not
be possible until javac can use URL's instead of a file system classpath.
Those changes to javac will not be available for quite a while.

Until that time I think the Context path should exist so that
getRealPath(), getResource(), getPathTranslated() work for jar and
class files broken out into the work directory.

I have implemented a way to dynamically build the classpath needed
by javac using the URLClassLoader.getURLs() that works great in Jasper
except for web apps running from a war file because I can't find any
way to get the real system file path to the jar files or classes directory.
This allows decoupling of Jasper from Tomcat for the CLASSPATH attribute.

We can put comments in both Tomcat & Jasper that this can be removed once
javac supports URL's in addition to the classpath.

Regards,

Glenn

Remy Maucherat wrote:
> 
> Quoting Glenn Nielsen <gl...@voyager.apg.more.net>:
> 
> > Is the ability to run from a WAR file directly without unarchiving it
> > into the webapps directory completely implemented?
> 
> No, I'm working on some fixes for Jasper (including one for the trace you
> included).
> 
> > Jasper gives me a null pointer when it tries to see if a JSP needs
> > to be recompiled in its Outdated method because getRealPath() returns
> > null,
> > getServletConfig().getServletContext().getRealPath(jspUri));
> 
> Here, it should use getServletConfig().getServletContext().getResource
> (jspUri).openConnection().getLastModified().
> 
> There are other places where Jasper will break because of over reliance on
> getRealPath() and getPathTranslated() (in both cases, the servlet container is
> allowed to return null, and will do so when there is no physical file on the
> filesystem).
> 
> Remy

-- 
----------------------------------------------------------------------
Glenn Nielsen             glenn@more.net | /* Spelin donut madder    |
MOREnet System Programming               |  * if iz ina coment.      |
Missouri Research and Education Network  |  */                       |
----------------------------------------------------------------------

Re: Tomcat 4, webapp running from WAR file

Posted by Remy Maucherat <re...@betaversion.org>.
Quoting Glenn Nielsen <gl...@voyager.apg.more.net>:

> Is the ability to run from a WAR file directly without unarchiving it
> into the webapps directory completely implemented?

No, I'm working on some fixes for Jasper (including one for the trace you 
included).

> Jasper gives me a null pointer when it tries to see if a JSP needs
> to be recompiled in its Outdated method because getRealPath() returns
> null,
> getServletConfig().getServletContext().getRealPath(jspUri));

Here, it should use getServletConfig().getServletContext().getResource
(jspUri).openConnection().getLastModified().

There are other places where Jasper will break because of over reliance on 
getRealPath() and getPathTranslated() (in both cases, the servlet container is 
allowed to return null, and will do so when there is no physical file on the 
filesystem).

Remy