Classes not getting published to embedded tomcat server of maven (tomcat:run) - maven

I'm using eclipse indigo IDE, apache tomcat 6.0 server, m2e plugin,jdk 1.6 softwares in my project.
After i make some changes in java code i do clean & maven build and the start the tomcat embedded server using maven i.e. 'tomcat:run' plugin command. But after following all steps i don't see my changes reflecting at all.
Now after i build all classes i see that all the class files are generated inside 'target' folder which i confirmed with the time at which it was generated.So i believe these class files are not getting published to embedded tomcat server of maven for some reasons.
P.S - I don't start/stop or use tomcat server configured in eclipse as i believe embedded tomcat server of maven doesn't use tomcat server in eclipse and it works by itself.Please correct me if i'm wrong here.
Please help me out.
[Update]:
Might be useful for someone who is facing similar issue.
The above problem was because of eclipse project settings file getting corrupted as i was encountering the same problem when i imported the same projects in different workspaces.But when i included modified codes alone in new workspace,it worked fine. All my changes were getting reflected.

use tomcat7:run
Then configure backgroundProcessorDelay see http://tomcat.apache.org/maven-plugin-2.1/tomcat7-maven-plugin/run-mojo.html#backgroundProcessorDelay with > 0

Related

GWT application deployed locally to Intellij Tomcat does not see breakpoints in gwt-aware client-module

Some facts about the application:
It consists of several modules, one of which is a GWT client module
Spring 3
GWT 2.6.1 (+ compatible GXT)
Is packaged as .war and can be deployed to a standalone Tomcat
Chrome add-on does not work anymore, so until recently I had to rely on Eclipse + embedded Jetty + Firefox 24 to be able to launch the app in DevMode and debug it
The other day I decided to try to launch it in IntelliJ IDEA and see if the debugging would work there.
Observations after deploying the app via a local Tomcat configuration in IntelliJ:
The app is deployed just fine (wither using war or exploded war artifact). Basically, Intellij takes the work directory from the standalone Tomcat installation and moves it into its installation folder (eg. .IntelliJIdea2019.1/system/Tomcat/Unnamed_MYAPP). Config files get also copied to the config dir.
The webapps dir of Tomcat stays within the original Tomcat installation and the app is deployed there
At first I thought the breakpoints are not recognized at all. However, it turned out that I was testing breaking only within the GWT client module; when I later tried some other module - the execution stopped as expected.
Now, what's interesting is that when I would develop and debug with Jetty, if I made a change to the GWT client-module, I could simply reload the page and it would appear.
With Intellij and Tomcat, it's the opposite. Breakpoints do not work as mentioned, but also refreshing, eg. via Update classes (instead of full redeployment) does not work, whereas for the other module it does.
Is there a way to somehow adjust my artifact so that GWT module as well can be debugged?
My exploded war artifact looks like this:
< output root >
META-INF
MANIFEST.MF
WEB-INF
classes
GWT module compile output
lib
web.xml
webapp directory contents
GWT client module GWT compiler output
Actually, it was a silly situation - I was expecting the execution to stop at the breakpoints set in the Java code of the gwt-aware module -- but since it was already transpiled to Javascript -- that was impossible.
The only way for breakpoints to stop in such a module is to use the DevMode.

Project that under tomcat webapps folder can not be found

I would like to deploy my project on tomcat server.
When i develop the project, i using eclipse with tomcat, and everything is ok.
I would like to deploy directly to tomcat server now.
I put my project folder under tomcat's webapps folder, and restart tomcat server.
But it shows 404 error when i open http://localhost:8080/myproject/
why this happen, and how can i figure it out?
It is not straight forward when you invoke Tomcat from within Eclipse. Please read the FAQ section at https://wiki.eclipse.org/WTP_Tomcat_FAQ
It explains how if you start Tomcat from within Eclipse, the binaries of original directories of Tomcat are used, but the web apps etc are stored separately in the Eclipse Workspace.

Maven project with maven-shade-plugin doesn't deploy to SpringSource Server correctly

We assemble a war file from several Maven based projects.
One of the projects uses maven-shade-plugin to include additional library inside its target jar file. Let's call it x.jar for the sake of this discussion.
When maven builds the war file it contains the correct x.jar file with packaged additional library inside.
We use Spring Source of the latest version (3.4.0) to deploy it to the server configured in Spring Source. Server is Sprint TC Server 2.0.3.
As soon as the project gets deployed to the server (which is Sprint TC Server 2.0), the jar file (x.jar) somehow gets replaced with incorrect small one without packaged library inside.
This smaller x.jar doesn't exist anywhere in the file system before the deployment, so it looks like Spring Source compiles it on its own.
As a result we can't deploy our system in Spring Source.
Do you, guys, the reason or a workaround for our problem?
----------- UPDATE -----------
We've conducted a test. We've broken maven pom.xml file before we deployed it and as a result Spring Source deployed the original files without recompiling it. It resulted in a correct deployment.
This test shows that Spring Source rebuilds jars silently upon deploying them to servers.
Is there a way to stop it or to make it work properly?
My suggestion, unfortunately, is to not use the shade plugin, but rather a clever combination between assembly, dependency and jar plugins, kinda like the guy in the answer here:
Invalid or corrupt JAR File built by Maven shade plugin
If you have any trouble configuring it, let me know.
And if you have the error logs of the server, it would be nice to post them as well.

Configure tomcat runtime using maven

Is it possible to configure a complete tomcat runtime within Eclipse using Maven/m2eclispe.
A maven goal to downloaded tomcat, create the server withing the eclipse environment and add the specified war files to the server ?
Or can some of these goals be implemented ?
You might want to take a look at this solution or check out the maven cargo plugin.
The first solution uses the sysdeo tomcat plugin, which I've personally used in the past, which worked quite well. It does not download tomcat though for you. You will have to do that manually.
Right now I'm working with the maven cargo plugin (not an eclipse plugin though), which will download a tomcat instance for your for development purposes.

Automatic deployement with Jenkins/jetty

I would like to setup a continuous integration environment whereby after committing the source code, it triggers a build process that checks out the code, runs tests, constructs a war file and deploys the same to jetty server such that the users/testers can access the application on the browser.
Is this possible ?
Am using maven and jetty (I am not willing to change this. I use jetty both for development and in production). For CI, I am exploring Jenkins but am open to other opensource solutions.
If possible, how do I setup the environment.
I found a maven plugin named cargo. It has everything that I needed. I added it into my pom so that I could deploy and undeploy using mvn cargo:deploy/mvn cargo:undeploy. I created a new jenkins job and added undeploy, package deploy maven goals as build steps. Everything is working perfectly.
it's definitely possible. In a previous project, the build server (teamcity) copied the war to a shared nfs location between the build server and the application server and run a little shell script that connected to the application server and restarted jetty.
We used ant inside maven to manage the deployment, I remember we used the copy and sshexec tasks.
I'm sure that there are many other solutions, but that one worked for us.
I reviewed a lot of posts like this but I want something that is maven independent. Look here, this is selfcontained runner in on hudson/jenkins. You only need 'war', even manual jetty installation is not needed. Deploy war on jetty in Jenkins or Hudson job

Resources