jsp/tomcat: ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:269)

this is baffling me… for one thing I never get this error when viewing my photo site from home, only when on another machine…

ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:269)

this always prints in logs in conjunction with a nullpointer…

for nullpointer it gives line in jsp servlets, it’s always this line:

if (imgsList.length == 0) {

what I do is I use java.io to count how many images are in ‘images’ dir (diff no. of images in ‘images’ dir for every page in my photosite)… is it possible that when that code runs sometimes the app hasn’t quite loaded and read that ‘images’ dir yet? is there an equiv in JSP to jQuery’s $(document).ready or something so that I’m sure app has fully loaded before it reads how many images are in ‘images’ dir? again, this error occurs intermittently, and never in my machine at home… I only find out the hard way whenever am looking @ my site in an internet cafe or something… (even at work I never get it… even if I clear cache…)

this is code I run to count images in ‘images’ dir:

FPath = “/chroot/home/…/apache-tomcat-5.5.25/webapps/” + sContext + “/” + sCurrSection + “/” + sCurrPage + “/images/”;
(I do a conditional here with getHeader(“host”) to detect whether I’m in Tomcat localhost or at my website…) then:

File dir = new File(FPath);
String imgsList;
imgsList = dir.list();
if (imgsList.length == 0) { // etc…

I have been using this code unchanged in my app for about three years… don’t get why it’s throwing this weird error now…

thank you…

thank you…

so changed code to this:

if (sHost.indexOf(“localhost”) != -1) {
FPath = “C:/apache-tomcat-5.5.23/webapps/” + sContext + “/” + sCurrSection + “/” + sCurrPage + “/images/”;
} else {
FPath = “/chroot/home/…/apache-tomcat-5.5.25/webapps/” + sContext + “/” + sCurrSection + “/” + sCurrPage + “/images/”;
}

tested yesterday in same mach. where had gotten error the other day, it worked fine… it seems that that was the solution… I think it’s strange, but well, like you say, who knows what strange things happen on the way from the browser to the server…:wink:

thank you very much for all your help…

So, I’m not sure what is happening, but the crux of the mater is that FPath is null.

Looking at this code:


if (sHost.indexOf("localhost") == -1) {
FPath = "/chroot/home/<myUid>/<myHost>/apache-tomcat-5.5.25/webapps/" + sContext + "/" + sCurrSection + "/" + sCurrPage + "/images/";
} else if (sHost.indexOf("localhost") != -1) {
FPath = "C:/apache-tomcat-5.5.23/webapps/" + sContext + "/" + sCurrSection + "/" + sCurrPage + "/images/";
}

You might consider changing the else if statement just to an else. There might be a way that neither one of your conditions is being meet and FPath is staying null. How, I don’t have a clue, sorry.

You are correct Log4j can be replaced with simple System.out.println() methods.

So, what it comes down to is that you most likely need to see what header information is being sent to your server so you can debug the problem. You could just do a simple System.out.println of the host value prior to assigning your FPath attribute.

We have very little control of what happens to our browsers requests once they leave our machines on the internet and intermediate servers can do strange things to our requests.

It is good that you’re not passing the whole url. So hopefully you can ignore the url length issue.

However, it still might we worth it to log all the attributes that come out of the request. Especially the getHeader(“host”). Log all the values using a tool like log4j.

What changed in the last three years. Did you just open this site up publicly?

What is your internal url vs the external url?

I think you misunderstood, the “images” dir name is not included in the url or query string at all…

http://www.francesdelrio.com/photoblog/section1/page1/photos.jsp?pn=1

it’s in the programming code (JSP scriptlet…)

thank you…

How long is the url including the query string?

The query string might be getting truncated by a server between you and your home machine.

I would create a filter that logs all the request attributes so you can see exactly what is being sent to your home machine.

BTW, just sending a file name directory to your webapp is not super secure…

Think about if someone typed in /etc/

What would they get back?

It might be worth it to consider setting the path to your images during start up or have the directory in your WEB-INF/ directory.

this is exact code for grabbing path to “images” dir:

if (sHost.indexOf(“localhost”) == -1) {
FPath = “/chroot/home/<myUid>/<myHost>/apache-tomcat-5.5.25/webapps/” + sContext + “/” + sCurrSection + “/” + sCurrPage + “/images/”;
} else if (sHost.indexOf(“localhost”) != -1) {
FPath = “C:/apache-tomcat-5.5.23/webapps/” + sContext + “/” + sCurrSection + “/” + sCurrPage + “/images/”;
}

urls:

public:
http://www.francesdelrio.com/photoblog/section1/page1/photos.jsp?pn=1

local:
http://localhost:8080/photoblog/section1/page1/photos.jsp?pn=1

my website has been at same server online for almost four years… created the site with Tomcat at home about 3-4 years ago…

I don’t how to use log4j… (I guess what you’re saying couldn’t be achieved simply with some print-out stmts??? :wink:

how error prints in log:

INFO | jvm 1 | 2010/06/21 18:40:40 | java.lang.NullPointerException
INFO | jvm 1 | 2010/06/21 18:40:40 | at org.apache.jsp.section4.page1.photos_jsp._jspService(photos_jsp.java:510)
INFO | jvm 1 | 2010/06/21 18:40:40 | at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:98)
INFO | jvm 1 | 2010/06/21 18:40:40 | at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
INFO | jvm 1 | 2010/06/21 18:40:40 | at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:331)
INFO | jvm 1 | 2010/06/21 18:40:40 | at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:329)
INFO | jvm 1 | 2010/06/21 18:40:40 | at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
INFO | jvm 1 | 2010/06/21 18:40:40 | at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
INFO | jvm 1 | 2010/06/21 18:40:40 | at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:269)

until a few days ago, had never seen this ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:269) stuff…

the line mentioned in
photos_jsp.java:510 is always this line:

if (imgsList.length == 0) {

thank you…