Remote debug JBoss AS 7.1 from Eclipse Indigo - eclipse

I read some guides on the subject and made the following steps.
http://oreilly.com/pub/a/java/archive/eclipse-jboss-remote-debug.html?page=8
https://community.jboss.org/thread/177687
JBoss debugging in Eclipse
The guides have some distinctions but on the whole they are similar.
The steps I made.
I compiled and deployed my web project and deployed it on JBoss AS
7.1 by clicking Run on Server -> JBoss AS 7.1 in Eclipse.
I stopped JBoss AS in Eclipse.
I uncommented the line
JAVA_OPTS="$JAVA_OPTS -Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=n"
in the $JBOSS_HOME/bin/standalone.conf file
I executed $JBOSS_HOME/bin/standalone.sh
I updated the page localhost:8080/MyProject/ in the browser and it
worked
I executed Debug -> Debug Configurations in Eclipse, then I created
a new configuration with the localhost as the host, 8787 as the
port, and MyProject as the project name.
I pressed the Debug button in Eclipse.
When I reach a breakpoint I added, nothing happens.
I expected that Eclipse would stop at the breakpoint as it does in a simple Java application project. What did I do wrong?
Eclipse version: Indigo.
Java.
java version "1.6.0_43"
Java(TM) SE Runtime Environment (build 1.6.0_43-b01)
Java HotSpot(TM) 64-Bit Server VM (build 20.14-b01, mixed mode)
Edit #1.
Window -> Preferences -> Java -> Installed JRE's
Edit JRE being used
Edit 'Default VM Arguments' line
-XX:+UseParallelGC
It didn't help.

Instead of making the changes in "standalone.conf", make the change in "standalone.conf.bat" .
Remove the rem from the line "rem set "JAVA_OPTS=%JAVA_OPTS% -Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=n"" .
This has worked for me.

You will need to start JBoss with a few extra options to the JVM. You can set these either in standalone.xml, or via the JAVA_OPTS environment variable. The options look basically the same, but for this post I will use JAVA_OPTS. Read this post from the JBoss Community forum if you want to use standalone.xml to configure the JVM parameters.
Add this line to your existing JAVA_OPTS:
-Xdebug -Xnoagent -Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=n
The port number (8787) above must match your Eclipse setup (see below).
Finally, you will need to tell Eclipse how to connect to the remote process. In Eclipse, click the Debug button’s drop-down arrow and select “Debug Configurations”.
In that dialog, navigate to “Remote Java Application” and click the “New” button.
Under “Project” select the project that contains the code you want to debug.
Under Connection Type make sure “Standard (Socket Attach)” is selected.
Under Connection Properties, make sure the host (e.g., localhost) and port (which must match the port spec in the JAVA_OPTS, in this case 8787) are set.
Click on the “Source” tab and add any projects containing code you want to debug (if there are other projects in your workspace that contain code other than the main project).
In the Common tab, under “Display in favorites menu” select the Debug icon and a handy dandy icon will appear in your Debug toolbar dropdown (the name will be the same as the Project setting from earlier).
If JBoss is already running (with the options set earlier) click Debug to attach. If not, start JBoss, then click Debug to attach.
Now you can set breakpoints, step through your code, etc.
Have fun!

Related

How to enter debug mode in eclipse when launching tomcat from cmd

I am using apache-tomcat-8.5.24 and have the workspace in Eclipse configured and tomcat working properly.
I need though to do some debugging, but I dont know how can I enter debug mode in Eclipse with the tomcat running from cmd? I have done it several times in the past but I was always launching tomcat in debug mode from my IDE.
You would have to enable remote debugging on tomcat for which the following catalina property needs to be added in tomcat startup.sh or tomcat.start.sh or wherever you add tomcat startup properties:
CATALINA_OPTS="$CATALINA_OPTS
-agentlib:jdwp=transport=dt_socket,address=8787,server=y,suspend=n"
Then restart tomcat.
After this is done, you need to open eclipse, and to go "Debug --> Debug Configurations -- type in the search box "remote java application", and create new, then select your module/java project which you want to debug and give the port number same as given in the above command (i.e. 8787 in the example above). Then Apply and launch.
While the other answer may solve someones problem, it didnt solve mine. Though the way i followed and solved my problem is:
First you start tomcat (all services up), and then you start the debug mode in eclipse!!!
For tomcat as i use the catalina.bat jpda run to start my tomcat i just edited it and used it as follows:
catalina.bat jpda run - agentlib:jdwp=transport=dt_socket,address=8000,server=y,suspend=n
For eclipse:
1)In Eclipse’s menu, select Run > Debug Configurations…
2)A new Debug Configurations window will appear
3)In the list on the left, select Remote Java Application. Don’t worry
too much about the word “remote” here. It just means that the JVM
process can either be on the local machine or another machine across
the network.
4)Select New in the context menu (you can either right click to see
the option for it, or select the icon above the list)
5)A new Remote Java Application debug configuration window will appear
6)Change the Name field to say “Tomcat (local)”, or the name of your
web application, your choice. The name you put here can be anything,
but shorter is better because the name will show up in menus.
Eclipse Run Configuration for a separate Tomcat JVM
There are at least three subtabs of configuration: Connect, Source,
and Common. Under the Connect subtab, there is a Project field. Select
the Eclipse project that represents the code you want to debug. For
instance, if you want to debug your webapp, select your webapp’s
Eclipse project here.
All of the other default settings should be fine. You should probably
look through the settings to see if you would like to change any
options, just beware of changing settings if you aren’t sure what the
effect will be. Make sure that the port number you’re setting in the
Connect subtab is the same port number you configured your Tomcat
JVM’s debug server to listen on.
Click Apply, then click Debug. At that point, your Eclipse’s debugger
will connect to your Tomcat JVM’s debug server. Next, switch to the
Eclipse Debug perspective. In Eclipse’s menu, select Window > Open
Perspective > Debug.

Netbeans php project debug breakpoints not working

On windows 10, Wamp PHP, Netbeans 8.1 and X-Debug (I believe), breakpoints don't work when selecting the debug project menu option but they do when debugging a file within the project (CakePHP).
Setting a breakpoint then selecting menu option "debug->debug project" starts a debug session, runs the project but no breakpoints work. Restarting the debugger with menu option "debug->debug file" will not run the application properly because it's the wrong place to start, but refreshing the web page stops correctly at the breakpoint.
Edit: a different test project works ok.
Thanks for any help.
If you already checked all the usual suspects: XDebug installed and configured.
Make sure that Web Root folder is selected under the project.
(if remote server used) Make sure that code on the server is identical to the one in Netbeans. (In rare case that something was edited on the server and not in netbeans)

How to start apache tomcat packaged within eclipse?

My company does not allow me to upload apache tomcat from the official website . They told me that I already have it as a "plug in " in Eclipse . It's sort of packaged . So , anyway I could not find a startup.bat file anywhere .
I have the following folder on my computer that presumably contains apache tomcat somehow installed there. I am not sure whether i have a jboss . Here is the folder
If I go to the jre folder there is a servertool.exe . It looks like this
I am not sure how I can start apache tomcat . I mean I am not allowed to upload the zip file directly form the website, otherwise I could have used the startup.bat . . . I have never encountered a situation like this . I do not have a regular apache tomcat folder .
I tried localhost:8080 no result
How can I start working with it ?
Thanks
Eclipse does not ship with Tomcat. It integrates very nicely with it, though, after you install Tomcat. These instructions are for Eclipse Kepler SR1; other Eclipse versions are similar. There are third-party plugins that do this too, but the native plugin works nicely. Also, I'm not sure, but pretty sure, that you need the "Java EE IDE" version of Eclipse, not just regular Eclipse for Java. The steps:
1) Install Tomcat from the ZIP file (which just means extracting the ZIP to somewhere like c:\tomcat)
2) In Eclipse, choose Preferences from the Window menu; in the search box, type "runtime", then click Runtime Environments under the Server category (if you don't see this, you may not be running Eclipse Java EE; again, not sure if "regular" Eclipse for Java is enough).
3) Click the "Add" button and go through the process of telling Eclipse about where your Tomcat server is (i.e., it's where you just installed it to).
4) Create a Dynamic Web Project for your web-app (regular Java projects won't work; if your code is already in a regular project, migrate it into a Dynamic Web Project).
5) From the Window menu, choose Show View, then Other, then type "servers" and double-click Servers.
6) In The Servers pane, right-click anywhere in the pane and choose New, then Server. Follow the instructions to create a new Server that uses the Tomcat runtime you just created in Eclipse. When you're done, you'll have a Tomcat server listed in the Servers pane.
7) Not it's time to add your Dynamic Web Project to the list of web-apps that this server (that is, this Tomcat) knows about. So, right-click on your Tomcat server in the Servers pane, and choose Add and Remove. In the dialog that opens up, click Add All, then Finish.
8) Start Tomcat by clicking the Debug icon above the Servers pane (it looks like a green bug). Load http://localhost:8080/ (or http://localhost:8080/yourappname depending on your config) and you're done. (You can also run Tomcat by clicking the Run icon -- instead of Debug -- but one of the big reasons to run Tomcat from within Eclipse is that you get to use Eclipse's debugging functionality.)

eclipse debug remote web application

I have a struts2 web application developed in eclipse IDE and exported
it as war file and deployed it in tomcat7 installed in windows server.
Now I need to debug this deployed web application in eclipse inside my local system.
How to bring those codes inside?
I found some links but I stuck with how to bring those code into
eclipse in my local system to place break points.
these are those few links...
link 1 link 2 link 3 link 4
..Or simply navigate to the bin folder and start your tomcat with the following command:
catalina jpda start
No need to make any changes with this approach.
The defaults are the same as quoted by Ingemar: port 8000 and transport=dt_socket.
Confirmed to work with tomcat 7 (.0.40 or newer to be precise).
Then follow his instructions and setup a Remote Java Application debug configuration in Eclipse. Basically, just use the defaults - they match (at least in Juno and Kepler). You might want to check the Source tab or do this on demand while you debug.
... Or, in case you use maven, you might consider the tomcat7-maven-plugin plugin, which will completely keep you inside eclipse.
Happy debugging
Solution for windows:
First you have to modyfy your tomcat startup script (startup.bat):
Put this on top of the startup.bat
set JPDA_ADDRESS=8000
set JPDA_TRANSPORT=dt_socket
...
Then modyfy the following line (nearly at hte end of startup.bat):
call "%EXECUTABLE%" start %CMD_LINE_ARGS%
to
call "%EXECUTABLE%" jpda start %CMD_LINE_ARGS%
Now you can start tomcat by executing startup.bat and tomcat opens the port 8000 for debuging.
Second step is to configure Eclipse:
Select Run > Debug Configurations ...
Create a new configuration by selecting 'Remote Java Application' with a right click.
Check that the right Project is selected.
And modyfy the Connection properties. (Note that the port has to be same (8000) as entered in startup.bat and not the port on which your struts app is running)
Finaly you have to click on Debug
Now you should be able to set breakpoints.

How do i debug a web application running on jetty in eclipse?

never done web programming before. Is there a way to set breakpoints, see variable values in eclipse? The app i want to debug makes a Query string whcih i would like to easily extract.
Click External Tools Config,
Select program and click the new button top left.
Set location to your maven binary
working directory to local workspace and arguments to jetty:run
In the environment tab set the maven opts. Notice socket address = 4000 and suspend=y
The go to debug configurations and add a new remote application. Add a project name and set the socket address. Now run the External tool it should say:
Listening for transport dt_socket at address: 4000
Then you can debug the remote app and add breakpoints etc.
I would run the application with maven using the command: mvnDebug jetty:run
And setup a remote Java application using port 8000, in Eclipse IDE.
See the 'Setting up Maven 2.0.8+' section of: http://docs.codehaus.org/display/MAVENUSER/Dealing+with+Eclipse-based+IDE
None of the answers worked for me. Here's what did work:
Create Maven Eclipse Runtime for your project:
right-click on project -> maven build -> goals: jetty:run
go to JRE tab of your Maven Eclipse Runtime, and in the VM arguments section add:
-Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=n
When you execute this runtime, the first thing the Eclipse console outputs (in blue) is:
Listening for transport dt_socket at address: 8000
Now you can create a Remote Java application Debug Runtime and connect to the debug port (8000 in this example)
I would just expand eaykin's answer as the URL is broken.
Run the Mvn Debug as bellow...
$ mvnDebug -Dmaven.test.skip -Denvironment=dev clean jetty:run
This will wait on port 8000
Preparing to Execute Maven in Debug Mode Listening for transport
dt_socket at address: 8000
Then go to the Eclipse Run --> Debug Configurations --> Remote Java Applications
Define Host as 'localhost' and port as 8000 if they are not default.
If you click on the "Debug" button, this will start the application from mvn.
"Trying to run it this way i get CreateProcess error=193, %1 is not a valid Win32 application."
On windows select mvn.bat instead of mvn.exe.
If by any chance you are using intellij. It is way easier.
Make sure you have jetty plugin installed. Then
In the Maven Tab on the extreme right, expand your project
Expand Plugins
Expand jetty
Right click on jetty:run and select 'Debug DEBUG'Click to see the screenshot for refence
The answer for this post shows you the flags need to pass to the JVM for a remote debugger to attach.
Remote debug Jetty (no mvn, no plugins)
This is the page that explains remote debuggers for the JVM
http://docs.oracle.com/javase/1.3/docs/tooldocs/solaris/jdb.html