NetBeans Forums

 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
  

Unable to debug with Netbeans 6.9.1 and Maven plugin Jetty

 
Post new topic   Reply to topic    NetBeans Forums -> Java EE Users
View previous topic :: View next topic  
Author Message
sabarish1967



Joined: 10 Oct 2011
Posts: 5

PostPosted: Mon Oct 10, 2011 11:16 pm    Post subject: Unable to debug with Netbeans 6.9.1 and Maven plugin Jetty Reply with quote

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?



config.rar
 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

PostPosted: Tue Oct 11, 2011 11:15 pm    Post subject: Reply with quote

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

PostPosted: Wed Oct 12, 2011 3:07 am    Post subject: Reply with quote

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? Crying or Very sad
Back to top
mdeggers



Joined: 28 Jan 2009
Posts: 208

PostPosted: Wed Oct 12, 2011 8:50 am    Post subject: Reply with quote

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/



nb-jettydebug.png
 Description:
settings for debugging jetty
 Filesize:  52.74 KB
 Viewed:  3086 Time(s)

nb-jettydebug.png



nb-jettystart.png
 Description:
settings for starting jetty
 Filesize:  51.44 KB
 Viewed:  3086 Time(s)

nb-jettystart.png



helloworld.zip
 Description:
Simple Struts 2 project

Download
 Filename:  helloworld.zip
 Filesize:  29.82 KB
 Downloaded:  35 Time(s)

Back to top
sabarish1967



Joined: 10 Oct 2011
Posts: 5

PostPosted: Wed Oct 12, 2011 2:38 pm    Post subject: My config snapshot! Reply with quote

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!



config.rar
 Description:

Download
 Filename:  config.rar
 Filesize:  588.52 KB
 Downloaded:  67 Time(s)

Back to top
mdeggers



Joined: 28 Jan 2009
Posts: 208

PostPosted: Wed Oct 12, 2011 9:11 pm    Post subject: Reply with quote

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/



nb-maven-external-gimp.png
 Description:
Using NetBeans' external Maven - do this.
 Filesize:  48.72 KB
 Viewed:  3070 Time(s)

nb-maven-external-gimp.png



nb-maven-config-gimp.png
 Description:
Configuring an external Maven for NetBeans
 Filesize:  76.85 KB
 Viewed:  3070 Time(s)

nb-maven-config-gimp.png



nb-maven-internal-gimp.png
 Description:
Using NetBeans' internal Maven - don't do this.
 Filesize:  48.87 KB
 Viewed:  3070 Time(s)

nb-maven-internal-gimp.png


Back to top
sabarish1967



Joined: 10 Oct 2011
Posts: 5

PostPosted: Thu Oct 13, 2011 2:35 am    Post subject: Resolved! Thank you! Reply with quote

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

PostPosted: Thu Oct 13, 2011 3:24 am    Post subject: Reply with quote

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

PostPosted: Thu Oct 13, 2011 4:12 am    Post subject: Reply with quote

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
Display posts from previous:   
Post new topic   Reply to topic    NetBeans Forums -> Java EE Users All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum


Powered by phpBB
By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2012, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo