tags:

views:

522

answers:

1

Here's the situation: I practiced creating a mini blog application. I used Strut's EventDispatchAction to handle all post related methods like updating and listing posts.

I have an update() method (http://mywebsite/post?update) that updates the database and then if it's successful it forwards to the same action class but I used a different method to handle it, the list() method (http://mywebsite/post?list) which lists all the posts of the current user. The problem is it doesn't work and throws up a:

javax.servlet.ServletException:

The server side component of the HTTP Monitor has detected a java.lang.StackOverflowError. This happens when there is an infinite loop in the web module. Correct the cause of the infinite loop before running the web module again.

Do you guys have any idea on how to fix this? Any help would be greatly appreciated!

EDIT: I solved it guys. I just need to put value in the parameter of my forward, in my case I have to do: post?list=list instead of just post?list (the normal way). The method is ignored I guess if it doesn't have a value. It's really weird why Struts is behaving like this. Maybe someone can shed some light on this?

+1  A: 

Is there no more exception information, like a stack trace?

Do you have unit tests for the list() method? A stack overflow is almost always caused by a recursive method (or cycle of methods) but without any more information about the stack trace, it's very hard to diagnose it further.

If you can't get a full stack trace after the exception has been thrown, you might want to add more logging into list() and the methods it calls, to show you where the recursion is occurring.

EDIT: Okay, looking at the stack trace it looks like you've got one action forwarding either to itself, or to another action which forwards back to the first one. It looks like your code isn't involved, given that it doesn't appear in the stack trace. Check your Struts config for cycles.

The other interesting bit of the stack trace is "org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter" - is this application running in your IDE? Does it still fail if you run it not in the IDE?

Jon Skeet
Here's the stack trace: http://pastebin.com/m6a785f4fOn an unrelated note, I saw your name Jon on the ads here at SO. Cool :D
ajushi
That is indeed an infinite loop/recursion ...
Thilo
Here's the update method's forward: <forward name="updatePostSuccess" path="/post.do?list"/>It seems that it's not executing the list() method (/post.do?list) as it should. I'll try to run it out of Netbeans.
ajushi
Hi guys, it still produces the same errors when I ran it outside of Netbeans.
ajushi