You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Hans Schou <ha...@miracle42.dk> on 2021/05/17 10:33:22 UTC

Re: [EXT] Re: JSP file not found in parent directory

The normalises to:
"https://example.org/am_databaseopen.jsp"


Yes, and that URL is working (I don't get a 404 page not found)

Assuming that
"https://example.org/interfaceparts/mainframenotlogged.jsp"
is located at
"$CATALINA_HOME/webapps/interfaceparts/mainframenotlogged.jsp"


Well the setup is not made with war-files and I don't know why. (I'm just here to fix the problem)

The server has only one Tomcat instance running and it is serving several virtual hosts.
In server.xml the setup is like:

<Host name="example.org" appBase="/mnt/fooapps/sptomcat/foopro">
  <Context debug="0" docBase="/mnt/fooapps/sptomcat/foopro" path="/" reloadable="true"></Context>
</Host>

It is not the way I normally do it. I prefer war-files in /webapps/.

The file mentioned before is here:
/mnt/fooapps/sptomcat/foopro/am_databaseopen.jsp​

When I got to the server another guy had tried with Tomcat 8.5, so now I have tried with 8.0 as it has less security issues but it did not change anything.


best regards
________________________________
From: Mark Thomas <ma...@apache.org>
Sent: Monday, May 17, 2021 09:13
To: users@tomcat.apache.org <us...@tomcat.apache.org>
Subject: [EXT] Re: JSP file not found in parent directory

On 17/05/2021 06:24, Hans Schou wrote:
> Hi
>
> I got this error when accessing my site:
>
> org.apache.jasper.JasperException: /mainframenotlogged.jsp (line: [1], column: [2]) JSP file [../am_databaseopen.jsp] not found
>
> The URL I'm accssing is like
> https://example.org/interfaceparts/mainframenotlogged.jsp
> and when I go into the directory with a console and list the file ../am_databaseopen.jsp it is there.

"../am_databaseopen.jsp" is a relative URL.

It is relative to
"https://example.org/interfaceparts/mainframenotlogged.jsp"

So the absolute URL is:
"https://example.org/interfaceparts/../am_databaseopen.jsp"

The normalises to:
"https://example.org/am_databaseopen.jsp"

Assuming that
"https://example.org/interfaceparts/mainframenotlogged.jsp"
is located at
"$CATALINA_HOME/webapps/interfaceparts/mainframenotlogged.jsp"

then
"https://example.org/am_databaseopen.jsp"
will be located at:
"$CATALINA_HOME/webapps/ROOT/am_databaseopen.jsp"

Note the addition of ROOT.

$CATALINA_HOME/webapps is not equivalent to httpd's document ROOT. Each
webapp application has a context path and is located in a directory/WAR
in $CATALINA_HOME/webapps. The mapping of those directory/WAR names to
context paths is described in:
http://tomcat.apache.org/tomcat-8.5-doc/config/context.html#Naming

Note the special case for the root web application with context path "".

Mark

>
> I then tried to make a symlink to ../am_databaseopen.jsp in the sub-directory and changed the file mainframenotlogged.jsp to use that but it gave the same error (but pointing to a file ind the same directory).
>
> I have gone through permissions and all files are owned by user "tomcat" so that should not be the problem.
>
> The server did chrashed and som configuration got lost and there is no backup.  A new site with Tomcat 8.5.66 has been setup.
>
> Any help much appriciated.
>
>
> bets regards
> Hans
>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: [EXT] Re: JSP file not found in parent directory

Posted by Mark Thomas <ma...@apache.org>.
On 17/05/2021 11:33, Hans Schou wrote:
> 
> The normalises to:
> "https://example.org/am_databaseopen.jsp"
> 
> 
> Yes, and that URL is working (I don't get a 404 page not found)
> 
> Assuming that
> "https://example.org/interfaceparts/mainframenotlogged.jsp"
> is located at
> "$CATALINA_HOME/webapps/interfaceparts/mainframenotlogged.jsp"
> 
> 
> Well the setup is not made with war-files and I don't know why. (I'm just here to fix the problem)
> 
> The server has only one Tomcat instance running and it is serving several virtual hosts.
> In server.xml the setup is like:
> 
> <Host name="example.org" appBase="/mnt/fooapps/sptomcat/foopro">
>    <Context debug="0" docBase="/mnt/fooapps/sptomcat/foopro" path="/" reloadable="true"></Context>
> </Host>

That is going to be messy. Any directory under 
"/mnt/fooapps/sptomcat/foopro" is going to get deployed as a separate 
web application.

It may be that changing appBase to "webapps" is enough to fix this. But 
maybe not.

Is it just the one web application that has been deployed?

> It is not the way I normally do it. I prefer war-files in /webapps/.

I tend to agree although I'll note that deploying an expanded directory 
direct to webapps works just as well as dropping in a WAR.

> The file mentioned before is here:
> /mnt/fooapps/sptomcat/foopro/am_databaseopen.jsp​

And what is the path to "interfaceparts/mainframenotlogged.jsp"

> When I got to the server another guy had tried with Tomcat 8.5, so now I have tried with 8.0 as it has less security issues but it did not change anything.

8.0.x only has less security issues because we stopped checking security 
reports against the 8.0.x code base when it went EOL a little under 3 
years ago. It is almost certainly the case the most, possibly all, of 
the security issues reported against 8.5.x since then apply to 8.0.x and 
I can guarantee that even if you are using the latest 8.0.x release you 
are exposed to publicly known security vulnerabilities. You should not 
be using 8.0.x. 8.5.x is the better choice.

>> org.apache.jasper.JasperException: /mainframenotlogged.jsp (line: [1], column: [2]) JSP file [../am_databaseopen.jsp] not found

Going back to this, there are several places in the Tomcat code base 
where that error message is used. Can you provide the full stack trace 
please so we can figure out what is going wrong.

Mark

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: [EXT] Re: JSP file not found in parent directory

Posted by Christopher Schultz <ch...@christopherschultz.net>.
Hans,

On 5/17/21 09:46, Hans Schou wrote:
> Problem solved in server.xml.
> <Host name="example.org" appBase="/mnt/fooapps/sptomcat/foopro">
> <Context debug="0" docBase="/mnt/fooapps/sptomcat/foopro" path="/" reloadable="true"></Context>
> </Host>
> It was a misconfiguration. A developer found an old server.xml in the mailbox, which revealed the problem.
> AppBase and DocBase should not be equal. They should look like this:
> appBase="/mnt/fooapps/sptomcat"
> docBase="/mnt/fooapps/sptomcat/foopro"
> 
> Lesson learned: Make a backup of your configuration files.

Better yet: revision control.

-chris

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: [EXT] Re: JSP file not found in parent directory

Posted by Hans Schou <ha...@miracle42.dk>.
Problem solved in server.xml.
<Host name="example.org" appBase="/mnt/fooapps/sptomcat/foopro">
<Context debug="0" docBase="/mnt/fooapps/sptomcat/foopro" path="/" reloadable="true"></Context>
</Host>
It was a misconfiguration. A developer found an old server.xml in the mailbox, which revealed the problem.
AppBase and DocBase should not be equal. They should look like this:
appBase="/mnt/fooapps/sptomcat"
docBase="/mnt/fooapps/sptomcat/foopro"

Lesson learned: Make a backup of your configuration files.

Thanx for looking into it.

best regards


________________________________
From: Hans Schou <ha...@miracle42.dk>
Sent: Monday, May 17, 2021 12:33
To: users@tomcat.apache.org <us...@tomcat.apache.org>
Subject: Re: [EXT] Re: JSP file not found in parent directory


The normalises to:
"https://example.org/am_databaseopen.jsp"


Yes, and that URL is working (I don't get a 404 page not found)

Assuming that
"https://example.org/interfaceparts/mainframenotlogged.jsp"
is located at
"$CATALINA_HOME/webapps/interfaceparts/mainframenotlogged.jsp"


Well the setup is not made with war-files and I don't know why. (I'm just here to fix the problem)

The server has only one Tomcat instance running and it is serving several virtual hosts.
In server.xml the setup is like:

<Host name="example.org" appBase="/mnt/fooapps/sptomcat/foopro">
  <Context debug="0" docBase="/mnt/fooapps/sptomcat/foopro" path="/" reloadable="true"></Context>
</Host>

It is not the way I normally do it. I prefer war-files in /webapps/.

The file mentioned before is here:
/mnt/fooapps/sptomcat/foopro/am_databaseopen.jsp​

When I got to the server another guy had tried with Tomcat 8.5, so now I have tried with 8.0 as it has less security issues but it did not change anything.


best regards
________________________________
From: Mark Thomas <ma...@apache.org>
Sent: Monday, May 17, 2021 09:13
To: users@tomcat.apache.org <us...@tomcat.apache.org>
Subject: [EXT] Re: JSP file not found in parent directory

On 17/05/2021 06:24, Hans Schou wrote:
> Hi
>
> I got this error when accessing my site:
>
> org.apache.jasper.JasperException: /mainframenotlogged.jsp (line: [1], column: [2]) JSP file [../am_databaseopen.jsp] not found
>
> The URL I'm accssing is like
> https://example.org/interfaceparts/mainframenotlogged.jsp
> and when I go into the directory with a console and list the file ../am_databaseopen.jsp it is there.

"../am_databaseopen.jsp" is a relative URL.

It is relative to
"https://example.org/interfaceparts/mainframenotlogged.jsp"

So the absolute URL is:
"https://example.org/interfaceparts/../am_databaseopen.jsp"

The normalises to:
"https://example.org/am_databaseopen.jsp"

Assuming that
"https://example.org/interfaceparts/mainframenotlogged.jsp"
is located at
"$CATALINA_HOME/webapps/interfaceparts/mainframenotlogged.jsp"

then
"https://example.org/am_databaseopen.jsp"
will be located at:
"$CATALINA_HOME/webapps/ROOT/am_databaseopen.jsp"

Note the addition of ROOT.

$CATALINA_HOME/webapps is not equivalent to httpd's document ROOT. Each
webapp application has a context path and is located in a directory/WAR
in $CATALINA_HOME/webapps. The mapping of those directory/WAR names to
context paths is described in:
http://tomcat.apache.org/tomcat-8.5-doc/config/context.html#Naming

Note the special case for the root web application with context path "".

Mark

>
> I then tried to make a symlink to ../am_databaseopen.jsp in the sub-directory and changed the file mainframenotlogged.jsp to use that but it gave the same error (but pointing to a file ind the same directory).
>
> I have gone through permissions and all files are owned by user "tomcat" so that should not be the problem.
>
> The server did chrashed and som configuration got lost and there is no backup.  A new site with Tomcat 8.5.66 has been setup.
>
> Any help much appriciated.
>
>
> bets regards
> Hans
>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org