Reloading JSPs edited in Eclipse, run with tomcat7-maven-plugin - java

How can I get a Tomcat instance started with tomcat7-maven-plugin on the command line to reload JSPs when I edit and save them in Eclipse? It's of note that I don't want to start Tomcat via Eclipse, as I depend on some Maven plugin executions that m2e doesn't know how to map.
I start Tomcat thusly, on the command line:
mvn clean package -U tomcat7:run-war-only
Here is the configuration of the Tomcat plugin:
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.2</version>
<configuration>
<systemProperties>
<spring.profiles.active>local</spring.profiles.active>
</systemProperties>
<path>/</path>
<port>8080</port>
<contextReloadable>true</contextReloadable>
</configuration>
</plugin>
When I change and save a JSP in the source of the project, it'd be lovely if Tomcat could reload that without having to go through a full clean/compile/test/package/start cycle.

This can be done by adding a tomcat server plugin to your eclipse and then deploying your war in tomcat through eclipse and not from command line.
If you do that, when you make any changes in JSP or Java, eclipse auto refreshes your war with out you manually triggering it.

Try
mvn clean package -U tomcat7:run
As run-war-only run a packaged war so won't see your code changes.
if you want debug in your ide use
mvnDebug clean package -U tomcat7:run
Then attach a debugger to port 8000
HTH

Related

UI code goes missing when deploying to Heroku

I have a Spring-MVC app that uses AngularJS for the front-end and Java in the backend. The java code is in src/main/java and the UI code is in src/main/resources/static. I'm building a fat jar using Maven.
Running locally = everything works.
I can also run the jar from the command line and everything works.
When I deploy to Heroku, the app returns a 404 on / ... it seems like it can't find the UI code anywhere.
I have an identical app with a different (less fancy) AngularJS UI, and it deploys to Heroku without any issues. The only real difference is the UI code exists at the parent src/main/resources/static while my custom app uses gulp - and gulp builds the ui code src/main/resources/static/dist. My Maven POM moves that /dist to target/classes/static when I run the package job, and that's working fine... After mvn clean package I can run my app through IntelliJ or at the command line using java -jar target/blah.jar. But when I push it to Heroku I get an application error, and the Heroku log cites a 404 on path="/".
Note my starting point for these projects was the Stormpath examples for spring-boot-web-angular. The stock example deploys fine with same Procfile, so the only difference is the /dist that my custom UI code has - but Maven should be taking care of that.
My Procfile contains:
web: java $JAVA_OPTS -Dserver.port=$PORT -jar target/*.jar
Pom excerpt that copies the UI code to the right spot in target/:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>3.0.1</version>
<executions>
<execution>
<id>copy-resources</id>
<phase>validate</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${basedir}/target/classes/static</outputDirectory>
<resources>
<resource>
<directory>src/main/resources/static/dist</directory>
<filtering>false</filtering>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
I've been googling for days and reached out to Heroku support, but they said they can't help.
I can't tell if the Maven piece isn't getting picked up when I git push heroku master (after packing locally), or if I'm missing a config option or something in my Procfile.
Would very much appreciate a pointer in the right direction.

Run/debug configurations for a Google App Engine project in Intellij IDEA?

As per title. Right now my workflow is as follows:
To deploy:
Open terminal from IDEA, go mvn appengine:deploy.
To run in localhost:
Open terminal, go mvn appengine:devserver.
To debug in localhost: thanks to this answer, open terminal, go
mvn appengine:devserver
mvn appengine:devserver_stop
mvn appengine:devserver_start
And then run the remote configuration which is described in that answer.
Question
Can these 3 tasks be simplified by defining three configurations, so to avoid having to open terminal and type commands?
I’d like to have two run configurations to deploy and run in localhost, and one debug configuration to debug locally. Is that possible? How?
Note: I am using the Community Edition of IntelliJ.
For what it’s worth, I have commented in the appropriate lines in pom.xml:
<plugin>
<groupId>com.google.appengine</groupId>
<artifactId>appengine-maven-plugin</artifactId>
<version>${appengine.version}</version>
<configuration>
<enableJarClasses>false</enableJarClasses>
<version>${app.version}</version>
<!-- Comment in the below snippet to bind to all IPs instead of just localhost -->
<!-- address>0.0.0.0</address>
<port>8080</port -->
<!-- Comment in the below snippet to enable local debugging with a remote debugger
like those included with Eclipse or IntelliJ -->
<jvmFlags>
<jvmFlag>-agentlib:jdwp=transport=dt_socket,address=8000,server=y,suspend=n</jvmFlag>
</jvmFlags>
</configuration>
</plugin>

Maven rpm plugin tries to run installation script on build

I am trying to create an RPM package to install a piece of software however whenever I try to build it using the rpm plugin it will run the install script while building which will fail since my machine is not the intended target (nor should it be)
The setup is this
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>rpm-maven-plugin</artifactId>
<version>2.1.2</version>
<extensions>true</extensions>
<configuration>
<group>Applications/Software</group>
<mappings>
<mapping>
<directory>/tmp/${project.artifactId}</directory>
<filemode>755</filemode>
<username>user</username>
<groupname>group</groupname>
<sources>
<source>
<location>src/main/resources/</location>
</source>
</sources>
</mapping>
</mappings>
<requires>
<require>unzip</require>
</requires>
<preinstallScriptlet>
<scriptFile>src/main/scripts/preinstall.sh</scriptFile>
<fileEncoding>utf-8</fileEncoding>
</preinstallScriptlet>
<installScriptlet>
<scriptFile>src/main/scripts/install.sh</scriptFile>
<fileEncoding>utf-8</fileEncoding>
</installScriptlet>
</configuration>
</plugin>
I have also configured the pom packaging to be rpm and I am running "mvn clean package" to generate the rpm.
This is just a builder project meaning that all it is meant to do is to package all files within src/main/resources in the rpm together with scriptlets which will execute when that rpm is run on some target machine.
Am I missing something?
I am building the rpm on an Ubuntu 14.04 machine with rpmbuild installed
I just read the RPM documentation and found out that this is totally correct. The install scriptlet is called when the RPM is build, what you probably need is a preinstall or postinstall scriptlet. The installation itself (copying the files) is done by RPM.
Reference: http://www.rpm.org/max-rpm/s1-rpm-inside-scripts.html

tell grails maven plugin to use servlet 2.5 instead of 3.0

I might have a stupid and really obvious question:
I basically have a grails 2.3.8 project, build using maven 3.2, with the grails maven plugin 2.4.3
<plugin>
<groupId>org.grails</groupId>
<artifactId>grails-maven-plugin</artifactId>
<version>2.4.3</version>
<configuration>
<!-- Whether for Fork a JVM to run Grails commands -->
<fork>true</fork>
<grailsVersion>${grails.version}</grailsVersion>
</configuration>
<extensions>true</extensions>
</plugin>
when I do a
mvn clean install
I keep getting the following exception:
java.lang.NoClassDefFoundError: javax/servlet/AsyncContext
at java.lang.Class.privateGetDeclaredMethods(Class.java:2484)
at java.lang.Class.getDeclaredMethods(Class.java:1827)
at org.codehaus.groovy.util.LazyReference.getLocked(LazyReference.java:46)
my BuildConfig specifies grails to utilize, servlet 2.5
grails.servlet.version = "2.5"
and all my test's are working fine, if I run them from grails directly using:
grails test-app :integration
but fail with the given exception, if I run them from the command line
mvn clean install
my dependency report lists the correct servlet version:
javax.servlet:servlet-api:jar:2.5:provided
anybody has an idea how to solve this?
thanks

Deploy war file to jetty using jenkins

I deployed the war file to tomcat using jenkins as a post-build action
WAR/EAR files=**/demo.war
Context path=application
Container=tomcat 7
Manager user name=admin
Manager password=admin
Tomcat URL=https://localhost:8080/
How to deploy a war file to jetty instead of tomcat using jenkins. The project is a maven project which does not have any plugin for jetty.
I think the simplest way to do this is the following:
1. Add to pluguns of pom.xml next lines
<plugin>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>9.1.1.v20140108</version>
<configuration>
<stopPort>9966</stopPort>
<stopKey>stopKey</stopKey>
<stopWait>20</stopWait>
</configuration>
</plugin>
2. Change goals to
mvn jetty:stop jetty:run-forked
If you cannot change pom.xml then you can create separate pom.xml (on other folder). And run the same tasks with this pom.xml. Post Steps > Invoke top-level maven target > advavanced

Categories

Resources