views:

769

answers:

2

I'm debugging an application on a remote server running JBoss using Eclipse. My particular problem is a NullPointerException in a JSP. The JSP has too much Java code inside scriptlets but, unfortunately refactoring is not going to be an option. Finding the line that throws the NullPointerException has been incredibly challenging and I'm getting stuck.

How can I debug this JSP remotely to find the line of the scriplet throwing the NullPointerException?

I ended up finding the problem by commenting out lines of the JSP until I isolated the issue. Tedious but, it worked.

+1  A: 

Generally you will be able to find the error on the server log. Since you are running it on a remote server, go to that machine and check the log. It should point out the error.

I find it easier to debug if I am running a local version of the site as I can monitor the server log through eclipse in real time. Perhaps it would be worth it to set up a local copy you can develop with and then just deploy to the remote server when you have fully debugged the code.

Hope this helps.

kgrad
Last line of the server log is:NullPointerException at org.apache.jsp.myjsp._jspService(Unknown Source)I can narrow down it's Java code in the jsp throwing the exception but can narrow down the line.
Owen
Sounds like the debugging symbols are stripped from that JSP. Even debugging won't help much.
Mr. Shiny and New
Looks like you are going to have to do some manual debugging. Null tests and the like. Not pretty but effective.
kgrad
+2  A: 

You can enable remote debugging on some application servers by adding something like this

-Xdebug -Xrunjdwp:transport=dt_socket,address=5001,server=y,suspend=n

to the command line. Then, in your IDE, connect to port 5001 for remote debugging. This page has some examples for various application servers.

I find that debugging JSPs can sometimes be done easily if you have the java source for the compiled JSPs. Check your application server's manual for JSP compilation or pre-compile your JSPs and save the .java files; then use these files as the source for the debugger.

Mr. Shiny and New
accepted because that's the correct command for starting JBoss to connect a remote debug session.
Owen