Can I run the jetty-maven-plugin from within Eclipse? - java

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.

Related

Debugging Thorntail Services in Eclipse?

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.

JRebel only starts when prompt is enabled

I am working on a Spring webapp which I run locally through Tomcat 7. I am working on my project using Eclipse and I use JRebel to apply any changes I make in real time. When I start Tomcat, I get a prompt asking me if I would like to launch the application with a JRebel agent, at which point I say yes and Tomcat launches successfully with JRebel monitoring my changes.
There is also the option to not be asked again in this prompt, and (I may be wrong in assuming this) I thought it would remember my choice to launch with the agent. It doesn't however and proceeds to start without JRebel starting up next time I launch tomcat, if I have checked that option.
My question is is there any way to automatically launch the agent when Tomcat starts (if any of the projects have a JRebel nature of course)?
I am using JRebel 5.3.1.
Managed to solve this issue, thank you for the suggestions.
As Anton Arhipov suggested I looked in the config center to see if the server I was deploying to was there, but it was not for some reason. I am not sure how Tomcat is configured on my machine but I think it has something to do with that.
I managed to get it to launch by adding the JRebel jar as a JVM parameter in my Tomcat settings similar to what Darius suggested. I did this by going to Window -> Preferences -> Tomcat -> JVM Settings and adding the parameter -javaagent:[Path to your jar]/jrebel.jar to the "Append JVM Parameters" box. Now it successfully launches whenever I start Tomcat.

TO Use Cygwin within Eclipse 3.6

I'm working in J2EE application. We are developing application in java/j2ee. In our project we use cygwin to simulate linux os, run shell script included in application and to deploy. How to use eclipse to embed eclipse and cygwin and deloy in run/debug mode.
Am new to this kind of stuff and confused to how to proceed further. Please suggest me how to proceed with this.
Thanks in advance.
Appreciated for guiding...
We r developing j2ee project in window env. and deploying in linux server.
so to simulate linux in windows we use cygwin.
Now we use eclipse to develop and get into cmd prompt and start cygwin and then run basic shell script to initialize variables and build the project and deploy the EAR in linux server ...
For these two purpose i have to toggle the window and i couldn't debug the code and check for check time data.
Is there any possibility to merge cygwin with eclipse to start the server or in run in debug mode, so that my developement process would be efficient and easy to code walk through... My enter team is following the first process which may tedious work.
Can any one suggest to work efficient with this project
Thanks in advance
Don't use shell scripts for your deployment process. Maven almost certainly has plugins for everything your shell scripts are currently doing, and it runs on Windows and Linux transparently.

eclipse remote debugging

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.

Can I set up arbitrary commands in an Eclipse Java project run configuration?

I have a Java Eclipse project, but I don't run it from the command line using java.exe. Instead I run it through a python script that runs the java.
What I'd like to do is run this when I hit the 'Run' button in eclipse and see the output in Eclipse's console window. Unfortunately the available run configuration options available are a little too restrictive and don't seem to allow for this arbitrary 'run anything you like' configuration.
Is this possible? Are there any eclipse plugins that add this kind of configuration option?
I realise I'd probably lose debugger support, but this is not an issue for me.
You could run it through an "external Tools Configuration": it can call any script/command you like, even if that script launches itself your Java program.
(source: abdevelopment.ca)
Then, once it is launched, you can initiate a remote debug session, provided your script did launch the Java program with the right options
-Djava.compiler=NONE -Xnoagent -Xdebug -Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=n
alt text http://www.nakov.com/blog/wp-content/uploads/2008/08/eclipse-remote-debug-configuration.png

Categories