| View previous topic :: View next topic |
| Author |
Message |
sabarish1967
Joined: 10 Oct 2011 Posts: 5
|
Posted: Mon Oct 10, 2011 11:16 pm Post subject: Unable to debug with Netbeans 6.9.1 and Maven plugin Jetty |
|
|
Dear All:
I wrote a sample spring 2.x application. Set couple of break points in the controller. Then, as a standard procedure I did the following:
- Started mvnDebug jetty:run ( the server is listening to 8000, I verified it)
- I started netbeans and loaded the project I wanted to debug, used the netbeans menu option to attach to the debugger @ 8000. I got the confirmation that the user program has been submitted:
Attaching to <machineNAme>:8000
User program running
LineBreakpoint HelloController.java : 32 successfully submitted.
LineBreakpoint HelloController.java : 35 successfully submitted.
Then I open a browser and tried to access the url which invokes this controller, I see nothing happens, I am expecting the execution to stop at line 32 above. Any pointers?
| Description: |
| the steps I did to attach the debugger |
|
 Download |
| Filename: |
config.rar |
| Filesize: |
292.36 KB |
| Downloaded: |
53 Time(s) |
|
|
| Back to top |
|
 |
mdeggers
Joined: 28 Jan 2009 Posts: 208
|
Posted: Tue Oct 11, 2011 11:15 pm Post subject: |
|
|
You do some things differently than I do. Here's how I use NetBeans,
Maven, and Jetty.
I just ran this on NetBeans 6.9.1 with no problems. I should try this
with the new Jetty 7 plugin on NetBeans 7.0.1.
First of all, I add the Jetty plugin to my pom.xml. For me, it looks like the
following (using Jetty 6).
| Code: | <plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>maven-jetty-plugin</artifactId>
<configuration>
<!-- automatic scan every 10 seconds - comment out manual reload
<scanIntervalSeconds>10</scanIntervalSeconds>
-->
<stopPort>8006</stopPort>
<stopKey>stop</stopKey>
<!-- manual reload - comment out scan. press
enter in the output window
-->
<reload>manual</reload>
</configuration>
</plugin> |
Note that this will have Jetty serving on port 8080. This has nothing to
do with the debug port.
Next, I create three custom actions for the project. To create a custom
action, do the following.
1. Right-mouse click on the project
2. Select Properties
3. In the wizard, select Actions on the left
4. Click on the Add Custom . . . button on the right
The three custom actions that I created are:
1. jettyStart - to start Jetty
a. The Execute Goals: entry is jetty:run
b. The Set Properties: entry is maven.test.skip=true
2. jettyStop - to stop Jetty
a. The Execute Goals: entry is jetty:stop
3. jettyDebug - to debug with Jetty
a. The Execute Goals: entry is jetty:run
b. The Set Properties: entry is
maven.test.skip=true
jpda.listen=maven
netbeans.deploy.debugmode=true
I probably don't need the netbeans.deploy.debugmode=true since I'm
not using the Debug menu item. I haven't tested this though.
I next wrote the HelloWorld Struts 2 example and placed a line breakpoint
in EditAction where it populates a form with information from a bean.
To debug with Maven and Jetty, I did the following.
1. Built the project with the standard Build menu entry
2. Right-mouse click on the project name
3. Select Custom->jettyDebug
The debugger console comes up and I get a LineBreakpoint sucessuflly
submitted.
The debugger is automatically attached, and I get the
Watchers / Variables window in the output area of the IDE.
When I run the program and access the particular action, the following
happens.
1. The source file is opened (if not already)
2. A green bar and pointer sit on the line breakpoint
3. The debug console reports that the breakpoint has been reached
4. The Debugger explorer is populated
5. I can browse the variable values in the output area
6. The debugger toolbar is activated
Stepping into and out of parts of the code work as expected.
The jettyStop custom actions shuts down Jetty and ends the debugging
session.
I hope that helps.
. . . . just my two cents.
/mde/
|
|
| Back to top |
|
 |
sabarish1967
Joined: 10 Oct 2011 Posts: 5
|
Posted: Wed Oct 12, 2011 3:07 am Post subject: |
|
|
Thanx a ton mde, but I get all the steps running as prescribed by you successfullu, but when I access the controller through the URL, it does not stop at the break points. I am not sure what else I need to do?
|
|
| Back to top |
|
 |
mdeggers
Joined: 28 Jan 2009 Posts: 208
|
Posted: Wed Oct 12, 2011 8:50 am Post subject: |
|
|
Hard to say without looking a bit more at your configuration.
I've attached a small Struts 2 program, along with screen shots of the
necessary custom actions. The jettyStop custom action is the same as my
previous post.
You'll have to change the location of the log4j directory. See the
properties in the two screen shots.
Try placing a line break point at line 43 of EditAction.java. The class is in
org.mdeggers.helloworld.action.
This works cleanly on Fedora 15, NetBeans 6.9.1, JDK 1.6.0_26, and the
latest version 6 of the Jetty plugin.
I'm using the Nimbus look and feel since the GTK look and feel is pretty
broken for Gnome 3 / GTK 3.
I hope this helps.
just my two cents . . . .
/mde/
| Description: |
| settings for debugging jetty |
|
| Filesize: |
52.74 KB |
| Viewed: |
3115 Time(s) |

|
| Description: |
| settings for starting jetty |
|
| Filesize: |
51.44 KB |
| Viewed: |
3115 Time(s) |

|
| Description: |
|
 Download |
| Filename: |
helloworld.zip |
| Filesize: |
29.82 KB |
| Downloaded: |
35 Time(s) |
|
|
| Back to top |
|
 |
sabarish1967
Joined: 10 Oct 2011 Posts: 5
|
Posted: Wed Oct 12, 2011 2:38 pm Post subject: My config snapshot! |
|
|
Dear MDE:
I appreciate your patience to get this going for me. I have attached the snapshot of the config I have in my IDE. I see that the IDE reports that there are no threads running!
| Description: |
|
 Download |
| Filename: |
config.rar |
| Filesize: |
588.52 KB |
| Downloaded: |
68 Time(s) |
|
|
| Back to top |
|
 |
mdeggers
Joined: 28 Jan 2009 Posts: 208
|
Posted: Wed Oct 12, 2011 9:11 pm Post subject: |
|
|
I think I found your problem. At least I can reproduce it (and a lot of other
really unpleasant behavior).
In all fairness, you do get a warning when doing this, so unless you've
unchecked a box in the warning dialogue, you should be aware of some
issues.
I reproduced your errors by unchecking the Use external Maven for
build execution box in [Project-name]->Properties->Actions. See the
nb-maven-internal-gimp.png picture below.
Doing this leads to all sorts of unpleasantness. Debug doesn't work,
attempting to stop Jetty doesn't work, and then restarting Jetty fails since
the port is already bound to an existing Jetty instance that could not be
stopped.
To solve this, you'll have to do three things.
1. Install Maven and put it on your path
This is not difficult at all, and recommended (even by NetBeans). Please
see http://maven.apache.org/ for instructions.
2. Configure that Maven to be used with NetBeans
NetBeans should automatically find Maven if it's on your path, but in case
it doesn't, you can browse to it and select it.
See the picture for Tools->Options->Miscellaneous->Maven
(nb-maven-config-gimp.png).
3. Make sure your project uses the external Maven
In [Project-name]->Properties->Actions, make sure that the Use external
Maven for build execution is checked. See nb-maven-external-gimp.png.
Depending on what you've done with Maven in your project, you may
have to restart the IDE.
Hopefully this will get you running.
. . . . just my two cents.
/mde/
| Description: |
| Using NetBeans' external Maven - do this. |
|
| Filesize: |
48.72 KB |
| Viewed: |
3099 Time(s) |

|
| Description: |
| Configuring an external Maven for NetBeans |
|
| Filesize: |
76.85 KB |
| Viewed: |
3099 Time(s) |

|
| Description: |
| Using NetBeans' internal Maven - don't do this. |
|
| Filesize: |
48.87 KB |
| Viewed: |
3099 Time(s) |

|
|
|
| Back to top |
|
 |
sabarish1967
Joined: 10 Oct 2011 Posts: 5
|
Posted: Thu Oct 13, 2011 2:35 am Post subject: Resolved! Thank you! |
|
|
Thank you mde, I appreciate your effort here to educate me and get me going, I resolved the issue, in fact it is my bad, I should have used the correct URL, here is what happened
http://localhost:8080/ was producing the same output as
http://locahost:8080/welcome.htm
but the later invocation method actually got the controller hook and I was able to step through the controller code.
|
|
| Back to top |
|
 |
mdeggers
Joined: 28 Jan 2009 Posts: 208
|
Posted: Thu Oct 13, 2011 3:24 am Post subject: |
|
|
Glad you figured it out.
Other stuff still holds true though. Using the internal (NetBeans-supplied)
Maven seems to cause a lot of troubles.
And yes, if you never hit the right URL, it's hard to run the controller and
engage the break point.
I learned something too - don't use the internal Maven for anything other
than trivial experiments.
. . . . just my two cents.
/mde/
|
|
| Back to top |
|
 |
sabarish1967
Joined: 10 Oct 2011 Posts: 5
|
Posted: Thu Oct 13, 2011 4:12 am Post subject: |
|
|
| mdeggers wrote: | Glad you figured it out.
Other stuff still holds true though. Using the internal (NetBeans-supplied)
Maven seems to cause a lot of troubles.
And yes, if you never hit the right URL, it's hard to run the controller and
engage the break point.
I learned something too - don't use the internal Maven for anything other
than trivial experiments.
. . . . just my two cents.
/mde/ |
Yes, so our development team has advised us to set this to external and so we are good I guess! Thanks!
|
|
| Back to top |
|
 |
|