How to stop tomcat 7 with maven in eclipse - maven

When I run my maven web project in eclipse. I go to pom.xml, right click on the file and
1. Maven Clean
2. Build Resources
3. Maven Build ..
Then I type tomcat7:run (for tomcat 7) for tomcat 6 , tomcat:run in the tomcat goals field in eclipse . It just starts. But I want to know how
1. To stop it
2. Rebuild the source and redeploy
in elipse or any other quick easy step. Isn't there any way to do all stuff to start the tomcat instead of repeating fore said steps(maven clean.. building resource.. again type tomcat7:run ... ) in eclipse.

Can you try right click on pom.xml > Run As > Maven Build...
Define here in the Goals section all your commands, something like: clean install tomcat7:run
My recommendation is to check skip tests for faster start up time, you can add extra paramenters like -Denvironment=qa if needed or VM arguments (from the JRE tab) like -Xmx2048m -Xms256m
Also, put a name to the configuration since you will be able to Run it again with a simple click or you could copy the .launch file eclipse generates into your application and commit it.
To stop the server just click the red square from the console view.
Hope it helps.

Following worked for me:
mvn tomcat7:shutdown
http://tomcat.apache.org/maven-plugin-2.2/tomcat7-maven-plugin/shutdown-mojo.html

You can use JRebel to hot-deploy your changes, no need to stop/start the app.
In IntelliJ use Ctrl+Shift+F9 to recompile and hot-deploty current changes.
Installing JRebel takes 5 minutes, and running app under JRebel is relally easy:
mvn <your usual parameteres here> -Djrebel.
If you search around, you can get JRebel for free.
Also, nothing stops you from running your maven application in a command line. Then stopping your app is as easy as hitting Ctrl+C.
You can also try maven tomcat shutdown plugin: http://tomcat.apache.org/maven-plugin-2.0/tomcat7-maven-plugin/shutdown-mojo.html.

I use JBoss Tools for managing Containers from Eclipse.

Just close the window for eclipse if the red square from the console view is not available.

Related

How make Intellij do before launch actions when redeploy external artifact?

I build an artifact (ear) with maven and deploy it to a local WebSphere Application Server 8 with Intellij IDEA 15, so I configured "before launch" action "mvn clean package".
Intellij starts WAS and deplopyment goes well, but when I try to do a redeploy, maven begins to build the artifact but installation it to WAS goes in a parallel and fails, so when maven finishes there is no proper insalled applicaion and I have to run "deploy" in Intellij manually by clicking a green arrow using a mouse to get it run.
How can I tell Intellij wait for "before launch" tasks to be finished before it will do the redeploy?
Have you tried the MultiRun plugin?
It completely solved my problem with launching/running multiple sub-tasks in sequence (or not in sequence if you choose) before the primary task is launched.
Finally I wrote a wsadmin script to redeploy the app and assigned the intellij idea shortcut to run it.

How to have Buildship recognize existing projects in Eclipse Mars

I just converted my Maven project to a gradle project. It was a multi project structure:
master-project
pom.xml
---->project1
-------->pom.xml
---->project2
-------->pom.xml
---->project3
-------->pom.xml
I ran a gradle init on it and have this structure now:
master-project
build.gradle
---->project1
-------->build.gradle
---->project2
-------->build.gradle
---->project3
-------->build.gradle
Everything builds fine, and I have been able to get some things done with that I couldn't figure out how to do with Maven, so that's great. Next step was to integrate that into the IDE since the Maven Dependencies are gone since I have removed the pom.xml files.
However the project isn't recognized as a gradle project - and I am not sure how to change that?
In Eclipse Mars it's still recognized as a Maven build, not gradle....
Thanks in advance.
EDIT: I reimported the projects which enabled the plugin for Eclipse. Now I am having weird behavior.
The build works from the command line, however when attempting the same execution from within Eclipse, it fails trying to copy the file dependencies.
For example:
Couldn't copy dependency jakarta-regexp-1.4.jar
java.nio.file.NoSuchFileException: C:\Users\user.m2\repository\jakarta-regexp\jakarta-regexp\1.4\jakarta-regexp-1.4.jar -> build\jfx\app\lib\jakarta-regexp-1.4.jar
I haven't changed the repo from maven yet - just changed the build scripts. This is running from the master project. So I am confused as to why the script would work from the commandline but not from within eclipse.
EDIT 2: Turns out this behavior is also present when running from the command line when the --daemon flag is set. Is there anyway to run the tasks without the daemon in Buildship? Or perhaps a way to fix this issue when the --daemon flag is enabled?
Thanks.
The issue with the build was that there is a leak in the JDK when bundling the JRE with the native app. This only happens when running with the --daemon flag (which all IDEs user). Therefore until this is fixed you will need to run gradle --stop and then run the clean.
The plug in I am using is no longer running the native task when running with --daemon.

Run dynamic web project with maven in debug mode

I built a dynamic web project with tomcat7 server on maven. To test the project I run mvn tomcat7:run every time anything is changed. This seems to time consuming.
Is there any way to run this in debug mode so I don't have to run project every time I change something in files? mvn --debug doesn't seem to work.
You can use JRebel.
See the answer to this question from stackoverflow for configuring maven with JRebel.
use mvnDebug for debugging/breakpoints.
Otherwise if any class change yup you have to restart (in order to recompile)

Hot deploy war maven project in embedded tomcat

I have maven war project.
I know inplace. it deploys to a given server. But i want to deploy on embedded tomcat and dont want to restart everytime. just say
for first time run deploy
Then change some java class and say redeploy. All in embedded tomcat.
Is this possible ?
Could the Tomcat Maven Plugin help with this?
You can use it by using the command tomcat:run
This page describes how to set up your POM/settings to make calling the plugin easier (using a prefix vs having to use full groupId/artifactId of plugin on the command line).
Maybe you can have a look at the executable war/jar feature see http://tomcat.apache.org/maven-plugin-2/executable-war-jar.html
So that will produce a simple jar which contains tomcat classes. You will be able to simply run: java -jar pathtofile.jar.

Debug a maven plugin's execution in a maven web-project

Is there any way to actually debug a maven plugin while it is in action. What I mean is that for example we have the maven-clean-plugin. So when this plugin executes it's action can we somehow debug and check inside the source code of maven-clean-plugin?
Obviously we would have to associate the Java source for the plugin in eclipse but how can we set it for debugging?
Thanks.
EDIT: Changing the subject
I'm sorry guys maybe I should have been more precise. Actually I have my web-app which is a maven project, which makes use of 3rd party maven plugins. Now when I do a mvn clean install I need to debug my 3rd party maven plugin. Now in my maven dependency I dont get a dependency to that plugin jar, which is quite normal. Any ideas?
If you are using Eclipse with the m2eclipse plugin, simply launch your build with Debug As... instead of Run as....
If you are not using m2eclipse, run mvnDebug instead of mvn (for Maven 2.0.8+) and attach a remote debugger on port 8000. For Maven 2.0.8<, add the remote debuggin options to the start script.
Of course, you need to import the sources of the plugin in your workspace.
See also
Developing and debugging Maven plugins
Dealing with Eclipse-based IDE
If you want to debug Maven execution in eclipse, here is how I did it, with mostly command-line tools (no Eclipse plugin used) (may be off at some points, I haven't done that for 6 months):
Run, from the command line, mvndebug in place of the mvn command. Maven will begin launching and wait for an external debugger to appear on a TCP port before resuming. Note the port number.
Configure in Eclipse a custom, remote debug configuration. (See http://www.ibm.com/developerworks/library/os-ecbug/ , Remote debugging) - set the port number as the one used by mvndebug. Also put the source files that you will be using for debugging in the Debug configuration.
Launch the remote debug configuration. Maven should resume and you will catch bugs in Eclipse.
This might be slightly off, since I'm going to talk about IntelliJ IDEA. With IDEA, you can load a maven project directly, and then simply right click on one of the build lifecycle phases (clean, package, install etc...) and choose debug. The IDE then runs that phase with the correct classpath and drops you into a debugger.
I've used the debugger to debug several of my own plugins. I've never tried debugging a third party plugin, although I imagine this will be relatively painless if the jar still has debug symbols in it and you have corresponding source code.
The community edition of IDEA is available for no fee.
Just replace mvn with mvnDebug in your command:
mvnDebug clean install
As result JVM listens for debugger at port 8000. For finer control you can set MAVEN_OPTS environment variable with standard JVM debug parameters:
export MAVEN_OPTS="-Xdebug -Xnoagent -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000"
mvn clean install
In NetBeans 7.4, Right-click the project > Properties > Actions. Pick the Build project action (or any other), then next to "Set Properties" click Add and Debug Maven Build.

Resources