I've got several microservices projects that I'm developing using the Thorntail framework. I'm writing my code using Eclipse. In the past, I've done all of my development using the Wildfly app server, and Eclipse made debugging these apps dead simple. Right Click->Debug As->Debug On Server. Done. Now that I'm using Thorntail, I'm not quite sure how to do it.
From the command line, I would start my Thorntail projects using:
mvn thorntail:run -Dthorntail.useUberJar # Project 1
mvn thorntail:run -Dthorntail.useUberJar -Dthorntail.port.offset=1000 # Project 2
That gets everything up and running, and listening on ports 8080 and 9080. However, the services are not in debug mode and I didn't launch these through Eclipse.
I know I can Right Click->Debug As->Maven Build... and then create a new debug configuration. I've done so, with my goals corresponding to the mvn commands above. However, when I do so no debugger is automatically attached, so breakpoints and such don't work. I'm sure I'm missing a step somewhere, but this is functionality I haven't tried to use before so I'm lost. Any recommendations?
The mvn thorntail:run accepts a system property thorntail.debug.port with a port number. For example, if you run
mvn thorntail:run -Dthorntail.useUberJar -Dthorntail.debug.port=5005
the Java process will wait for remote debugger connection and only then will it continue.
I don't use Eclipse, but I'm pretty sure configuring a remote debugging session isn't hard.
Execute the uberjar with the following parameters. Ensure that all the parameters are specified before the name of the uberjar on the line.
java -agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=$PORT_NUMBER -jar $UBERJAR_FILENAME
$PORT_NUMBER is an unused port number of your choice. Remember this number for the remote debugger configuration.
$UBERJAR_FILENAME is the uberjar.
suspend=y ensures that JVM will pause and wait for remote debugger connection before it starts the application.
To remote debugging it using Eclipse IDE you have to open Eclipse, open source code of the targeted application and create a debug configuration ("Remote Java Application") by specifying the targeted host and port. After this, hit "Debug" button and proceed with the remote debugging.
Related
Screenshot of the issue
Hi guys im using intellij and maven and i was working on my code but when I try to ru it locally im getting this issue, I checked all the configuration but I dont know exactly why this issue appear
This happens when IDE can not connect to mentioned port. It is most likely specified in run debug configuration. This may happen because the port has already been occupied by another process (e.g. There is already Tomcat instance running).
Also if you have antivirus/firewall make sure it does not block IDE process from making connections on localhost: make sure to exclude IDE process, IDE installation home, IDE configuration/system folders, project and library directories from the scan. Try restarting the PC, try using different JMX port in Run/Debug Configuration.
I usually got by with elaborate logging configurations. But now I want to debug parts of the ActiveMQ (5.15.5) broker component in Eclipse (Photon). After downloading, building and running mvn eclipse:eclipse I now have a workspace full of component projects with no associated run configurations. For some reason mvn install generates an executable in activemq-assembly/src/release/bin but that seems to be limited and it is not obvious, what it is that I have to tell eclipse to run.
I have had similar problems before.
In general: Do I just guess a Main (there are a'plenty) and search with trial-and-error? Or is there a structured approach that you can take towards debugging such loosely coupled applications?
I would suggest using remote debugging which can be used by any modern Java IDE (e.g. Eclipse, IDEA, etc.). Follow these steps:
Grab the ActiveMQ source code which corresponds to the version of the broker you're running.
Open the env file in the bin directory of your ActiveMQ instance and uncomment the line defining ACTIVEMQ_DEBUG_OPTS.
Set a break-point with your IDE in the ActiveMQ code.
Start the broker.
Attach the debugger.
Reproduce your problem and debug the code from the break-point you set.
I have a JRebel+Tomcat server run via IntelliJ on my Work (*NIX) machine, and occasionally I'd love to have JRebel update Classes/Resources when I'm at my home (*NIX) machine remotely connected via SSH.
e.g.
home $ ssh work
work $ cd workspace/foo/bar/baz
work $ hey-jrebel-go-update-classes
I handle this today by VNC'ing into my work machine, then in IntelliJ executing "Update Classes and Resources" on my running Tomcat instance, then log back out.
It's rather silly since I'm already SSH'd in. Is there a way to kick off this process via command-line?
JRebel features Remoting facility, which can be used to sync the changes via HTTP to the remote machine. For that, you should enable JRebel on remote Tomcat (via -javaagent:jrebel.jar) and enable JRebel remote plugin that create an HTTP endpoint for negotiating with the IDE plugin. -Drebel.remoting_plugin=true will do.
For more information you can check the tutorial for setting up Remoting with IntelliJ IDEA and Tomcat.
Otherwise, without remoting enabled, you can deploy the app with the rebel.xml config file which will point to the location where the exploded application is and JRebel will make Tomcat to load the resources from that specific location, so you could just synchronize from IntelliJ to that remote location via SSH. JRebel will then work as usual - monitoring the changes in the specified location and reloading the classes/resources as soon as they are being used in the application.
I'm not completely following what you are attempting to do. But if I follow, you basically want to issue a command to a remote server via SSH and, ideally, launch it from within IntelliJ IDEA. You could either:
Use the Terminal window (Tools > Open Terminal), start an ssh connection, and then issue the command manually.
Create an External Tool definition that uses plink (or an equivalent) to execute the ssh command to your remote server. You can create an External Tool Definition in Settings > [IDE Settings] > External Tools. See the screenshot below for an example. The definition (or its group if using groups to add structure to your definitions) will appear on the Tool menu. You can also map a shortcut to it via Settings > [IDE Settings] > Keymap > External Tools. For a multiple command sequence, you can either
write a local script that does it and use the External Tool definition to launch the script
write a remote script and use the plink in an External Tool Definition to run it
put the commands to run in a local file and use plink -m {file} to run them.
We're debugging java webapps, and would like to use the jetty-maven-plugin to launch a Jetty server. All of the documentation I have seen suggests that you should do it from the command line, which makes debugging and setting breakpoints in Eclipse difficult. Plus I'd like to see the output in the console window and be able to stop the process with red button. And do profiling as well.
Anyone know how to do this?
Yes, if you have m2eclipse installed then just enter in "jetty:run" as the goal you want to run.
You can however connect Eclipse's (or any IDE's) debugger to a running Jetty instance by launching the jetty plugin with the JPDA flags, without having to execute from within Eclipse.
I added a Java project to Eclipse and I am running it from the command line. Since it was pre-built, I did not build it. The project, OfBiz, is enabled for remote debugging. Do I need to compile the project in Eclipse before I can remote debug into it?
No you don't need to recompile, but you have to start your application with options like:
-Xdebug -Xrunjdwp:transport= dt_socket,address=1044,server=y,suspend=n
The port here 1044 of course can be changed.
If you application is running, open the debug dialog and attach the eclipse debugger to the application's JVM using "Remote Java Application" / New
EDIT: I forgot to mention that this requires that the precompiled app is start externaly. If you wan't to start it from inside eclipse, you would have to recompile otherwise eclipse can not find the 'Main' class to execute.