Tuesday, December 19, 2006

Sun AS 9, its really fast, it beats NetBeans.

Okay, let me start of with stating that I am probably doing something wrong here, but yesterday I was amazed by the speed of Sun AS 9.

I'm working on a backend system that uses JPA, and connects with a MIDlet, or rather, at the moment the MIDlet is connecting with the backend. But that's not the issue today. The backend has a daemon running (a thread in the web tier) started by a servlet that generates a data-structure and expands it over time. Because I wanted this to be started at server startup, the thread was started in the servlet's overridden init() method. Because I wasn't sure whether or not my code was working, I set a breakpoint in the init() and started debugging. Guess what, nothing happened, the breakpoint was never hit! Adding some System.outs in the init() showed that it was called, NB's debugger was just never ready to stop on the breakpoint. It seems to be too slow, or the interaction between Sun AS and NB is not synched correctly.
So now I moved the code to the doGet and I kick off the thread in there. It all works nicely and my code works like a charm. And I can debug the code.

So what is going on? I tried several scenario's each time ensuring that I did a clean-build prior to my trial.

Scenario 1: Start my web app from NetBeans by hitting the debug button. Breakpoint in init() didn't pause the app.

Scenario 2: Start Sun AS in NetBeans in debug mode. Breakpoint in init() didn't pause the app.

Scenario 3: Start Sun AS in debug mode and start my web app from NetBeans by hitting the debug button. Breakpoint in init() didn't pause the app.

In all three scenario's the breakpoint in doGet() worked perfectly. Really weird, but at least after a lot of trial and restart of NB it worked, some way.

Iwan

5 comments:

Jerry Smith said...

Just taking a quick peek at the ant scripts, it doesn't look like Netbeans has the suspend=y in the debugging options. I've found that's key to seeing anything executed in init() since that option will not start program running until the debugger has hooked in and you can tell the debugger to continue. I'm not sure where you can set this option in 5.5.

E-One said...

Thanks, sounds like something worth investigating.

Iwan

Anonymous said...

It seems to me, you were mistaken

Anonymous said...

It absolutely agree

Anonymous said...

The same...