This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 129969 - Can't debug servlet startup
Summary: Can't debug servlet startup
Status: NEW
Alias: None
Product: serverplugins
Classification: Unclassified
Component: Tomcat (show other bugs)
Version: 6.x
Hardware: All Windows XP
: P4 blocker with 1 vote (vote)
Assignee: Thuy.d Nguyen
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-03-12 22:44 UTC by cruxic
Modified: 2010-02-03 15:56 UTC (History)
1 user (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description cruxic 2008-03-12 22:44:32 UTC
If your webapp has a Servlet class with an init() hook method and <load-on-startup> is specified, you cannot (easily)
debug stuff inside init().  My team is new to Netbeans but I'm surprised nobody has filed this issue yet.

If the above jargon does not make sense you can reproduce the problem by following the steps for issue #129968 and
putting a breakpoint in the init() method you added.  The debugger won't stop on it.

I believe the issue is simply because the debugger does not attach until AFTER Tomcat has finished startup, which is too
late for Servlets that specify <load-on-startup> in web.xml.

There are a couple workarounds (neither of which work well for my team):
1) Put a Thread.sleep() in the init() code you wish to debug and manually attach the debugger while it's sleeping.
2) Remove <load-on-startup> from web.xml for your Servlet.  Accessing the servlet URL in your browser will then trigger
initialization.

The reason these workarounds don't work well is:
  * It's not intuitive.  (My team members keep complaining at me that it was so effortless in JBuilder)
  * You have to remember to take out the Thread.sleep() call or restore <load-on-startup> in web.xml before you commit
your code.
  * #1 requires precise timing that is hard to muster in the later hours of a long day of programming.
Comment 1 Petr Hejl 2008-03-13 11:11:45 UTC
There is a workaround:
1) Start tomcat in debug mode
2) Attach debugger
3) _Run_ the app again and again - it will hit the breakpoint

Note you don't need to start-stop-start-stop... the tomcat when you are developing the application.
Comment 2 cruxic 2008-03-20 00:51:02 UTC
Brilliant!  Thanks for setting us straight, phejl.  I guess JBuilder had just trained us to restart Tomcat upon every
change.  That should relieve 90% of our frustration although I'm still curious why it does this sort of double start of
the webapp that I described.

Comment 3 Petr Hejl 2008-03-20 11:09:37 UTC
There is no justification for this being P2. Probably changed accidentaly...

For the web app started twice - see my comment at the issue 129968.