Tomcat 7 maven plugin complete configuration reference - maven

I cant seem to find the online reference on tomcat 7 maven plugin configurations.
Example :
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.1</version>
<configuration>
<!-- <server>tomcat7</server> -->
<path>/</path>
<aliases>
<alias>myweb.com</alias>
<alias>myweb.mydomain.com</alias>
</aliases>
</configuration>
...
</plugin>
Some examples i got so far that shows more of the configuration options:
http://mojohaus.org/tomcat-maven-plugin/usage.html
How do I configure an additional context path for Maven-Tomcat plugin?
But they are not the complete configuration reference.
I wonder where the configurations reference are located ?

Reference documentation is available in Apache Tomcat web site.
Try http://tomcat.apache.org/maven-plugin-2.1/tomcat7-maven-plugin/run-mojo.html

Related

How to add a Spring project to Tomcat configuration using Eclipse IDE, so that Tomcat will load the index page from web.xml

I have a project imported as an existing Maven project in Eclipse, however I'm having trouble configuring Tomcat so that it loads the index page from web.xml
User Yugerten tried to help with their solution, however I'm obviously doing something wrong and its not running, therefore I include the screenshots of configuration and error log.
Add a plugin configuration to your pom.xml
<build>
...
<plugins>
...
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.2</version>
<configuration>
<url>http://localhost:8080/manager/text</url>
<path>/myWebApp</path>
</configuration>
</plugin>
...
</plugins>
...
</build>
eclipse
Or via Terminal / cmd:
mvn tomcat7:run / mvn tomcat7:deploy / mvn tomcat7:undeploy / mvn tomcat7:undeploy

Running flyway commands from command line using spring boot properties for maven

I have a spring boot project using maven that I've included flyway in:
pom.xml:
<dependency>
<groupId>org.flywaydb</groupId>
<artifactId>flyway-core</artifactId>
<version>6.5.0</version>
</dependency>
and application.properties:
#LOCAL
spring.datasource.url=jdbc:postgresql://localhost:5432/theDatabase
spring.datasource.username=theRightUser
spring.datasource.password=theRightPassword
and it works as expected when I run the application.
However, I'm trying to run mvn flyway:clean from the command line, and it doesn't seem to recognize the configuration correctly:
[ERROR] Failed to execute goal org.flywaydb:flyway-maven-plugin:6.4.4:clean (default-cli) on project my-service: org.flywaydb.core.api.FlywayException: Unable to connect to the database. Configure the url, user and password! -> [Help 1]
I tried adding spring.flyway properties (user/pass/url) in the application.properties file but it gave me the same error. What do I need to do to get flyway to read from the application.properies like it does when the application runs normally?
EDIT: I have made slight progress: I was able to reference my application.properties as a flyway config file by adding this to the pom.xml:
<plugin>
<groupId>org.flywaydb</groupId>
<artifactId>flyway-maven-plugin</artifactId>
<version>6.5.0</version>
<configuration>
<configFiles>${project.basedir}/src/main/resources/application.properties</configFiles>
</configuration>
</plugin>
So now in that file, I have flyway.url, flyway.user and flyway.password. This allows me to run flyway goals from the command line, but is not totally the solution I want. I am looking into using this plugin to try and read the properties into the pom.xml file, and then using those values in the flyway-maven-plugin's <configuration> area.
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>properties-maven-plugin</artifactId>
<version>1.0.0</version>
<executions>
<execution>
<phase>initialize</phase>
<goals>
<goal>read-project-properties</goal>
</goals>
<configuration>
<files>
<file>${project.basedir}/src/main/resources/application.properties</file>
</files>
</configuration>
</execution>
</executions>
</plugin>
which would allow me to do this:
<plugin>
<groupId>org.flywaydb</groupId>
<artifactId>flyway-maven-plugin</artifactId>
<version>6.5.0</version>
<configuration>
<url>${spring.datasource.url}</url>
<user>${spring.datasource.username}</user>
<password>${spring.datasource.password}</password>
</configuration>
</plugin>
When you run flyway as maven goal it will not pick up the properties from the application.properties, instead it will use the configuration provided by the flyway-maven-plugin, you can configure the flyway-maven-plugin in the following way -
Add the following plugin to pom.xml -
<plugin>
<groupId>org.flywaydb</groupId>
<artifactId>flyway-maven-plugin</artifactId>
<version>6.5.0</version>
</plugin>
Then we will configure the flyway-maven-plugin, the Flyway Maven plugin can be configured in a wide variety of following ways (most convenient),
Configuration section of the plugin
The easiest way is to simply use the plugin’s configuration section in your pom.xml:
<plugin>
<groupId>org.flywaydb</groupId>
<artifactId>flyway-maven-plugin</artifactId>
<version>6.5.0</version>
<configuration>
<driver>org.hsqldb.jdbcDriver</driver>
<url>jdbc:hsqldb:file:${project.build.directory}/db/flyway_sample;shutdown=true</url>
<user>SA</user>
<password>mySecretPwd</password>
<connectRetries>10</connectRetries>
<initSql>SET ROLE 'myuser'</initSql>
<schemas>
<schema>schema1</schema>
<schema>schema2</schema>
<schema>schema3</schema>
</schemas>
<callbacks>
<callback>com.mycompany.project.CustomCallback</callback>
<callback>com.mycompany.project.AnotherCallback</callback>
</callbacks>
<skipDefaultCallbacks>false</skipDefaultCallbacks>
<cleanDisabled>false</cleanDisabled>
<skip>false</skip>
<configFiles>
<configFile>myConfig.conf</configFile>
<configFile>other.conf</configFile>
</configFiles>
<workingDirectory>/my/working/dir</workingDirectory>
</configuration>
</plugin>
Maven properties
To make it easy to work with Maven profiles and to logically group configuration, the Flyway Maven plugin also supports Maven properties, update the properties section in pom.xml as follows:
<project>
...
<properties>
<!-- Properties are prefixed with flyway. -->
<flyway.user>myUser</flyway.user>
<flyway.password>mySecretPwd</flyway.password>
<!-- List are defined as comma-separated values -->
<flyway.schemas>schema1,schema2,schema3</flyway.schemas>
<!-- Individual placeholders are prefixed by flyway.placeholders. -->
<flyway.placeholders.keyABC>valueXYZ</flyway.placeholders.keyABC>
<flyway.placeholders.otherplaceholder>value123</flyway.placeholders.otherplaceholder>
</properties>
...
</project>
External Configuration File
Another way is to create a separate .properties file, the default configuration file name is flyway.properties and it should reside in the same directory as the pom.xml file. Encoding is specified by flyway.encoding (Default is UTF-8):
flyway.user=databaseUser
flyway.password=databasePassword
flyway.schemas=schemaName
...
If you are using any other name (e.g customConfig.properties) as the configuration file, then it should be specified explicitly when invoking the Maven command:
$ mvn <goals> -Dflyway.configFile=customConfig.properties
After configuring your flyway-maven-plugin, with the desired configuration, we will be able to execute flyway maven goals from command line.
You can do further reading here.
Hope this helps!

Deployment to JBoss EAP 7 with Maven Wildfly plugin

I'm trying to deploy an application to a local JBoss EAP 7.0 server through Maven. The deploy works fine through both the management console and manually deploying through the "doDeploy" method.
I'm not sure what i need to do in order to get it working.
I've tried following the instructions found on the website but to no avail: https://access.redhat.com/documentation/en-us/red_hat_jboss_enterprise_application_platform/7.0/html/configuration_guide/deploying_applications#deploying_apps_using_maven
here is the relevant part of the pom.xml
<build>
<finalName>${project.artifactId}_${project.version}</finalName>
<sourceDirectory>src</sourceDirectory>
<testSourceDirectory>test</testSourceDirectory>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.7.0</version>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
</configuration>
</plugin>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>3.0.0</version>
<configuration>
<warSourceDirectory>WebContent</warSourceDirectory>
</configuration>
</plugin>
<plugin>
<artifactId>maven-javadoc-plugin</artifactId>
<version>3.0.0</version>
<configuration>
<doclint>none</doclint>
</configuration>
</plugin>
<plugin>
<groupId>org.wildfly.plugins</groupId>
<artifactId>wildfly-maven-plugin</artifactId>
<version>1.2.1.Final</version>
<configuration>
<hostname>${deploy.jboss.hostname}</hostname>
<username>${deploy.jboss.user}</username>
<password>${deploy.jboss.pass}</password>
</configuration>
</plugin>
</plugins>
</build>
I'm unfortunately getting the following error from maven when running mvn clean wildfly:deploy -X -e
Caused by: java.lang.IllegalStateException: WFLYCTL0216: Management resource '[]' not found
at org.wildfly.plugin.core.DefaultDeploymentManager.hasDeployment(DefaultDeploymentManager.java:370)
at org.wildfly.plugin.core.DefaultDeploymentManager.hasDeployment(DefaultDeploymentManager.java:331)
at org.wildfly.plugin.core.DefaultDeploymentManager.forceDeploy(DefaultDeploymentManager.java:85)
at org.wildfly.plugin.deployment.DeployMojo.executeDeployment(DeployMojo.java:70)
at org.wildfly.plugin.deployment.AbstractDeployment.execute(AbstractDeployment.java:150)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
... 21 more
Any ideas as to what could be causing the problem?
EDIT: I've made some progress in identifying the issue. The issue seems to stem from my standalone.xml server configuration used rbac authentication mechanism. Using "simple" the deployment works immediately but using "rbac" with a specific username and password it fails and i cannot get it working. I've opened a ticket on the JBoss forums here to further exposure: https://developer.jboss.org/message/980860#980860
For anyone else who runs into this problem, the issue was that by changing the standalone.xml to use "rbac" manually, it does not 'fully' disable the simple authentication. After some discovery by James R. Perkins he identified the issue but it can be manually resolved by doing the following to the standalone.xml:
<management>
<security-realms>
<security-realm name="ManagementRealm">
<authentication>
<local default-user="$local" skip-group-loading="true"/> <!-- THIS LINE WAS REMOVED -->
The final line was removed and i was now able to deploy using the maven plugin.
For more detailed info, see the question posted on the JBoss developer forums here: https://developer.jboss.org/message/980860#980860

how to start tomcat server automatically through tomcat 7 maven plugin

How to start a tomcat server which is present in my local through tomcat7 maven plugin...how to give the source of my local tomcat server in tomcat plugin so that if we give the tomcat7:run command...local server will run automcatically.
You must provide the url in the plugin configuration.
Note that for Tomcat 8 instances (I havent tested it in earlier tomcat versions) you need domain:port/manager/text
<plugins>
..
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.2</version>
<configuration>
<url>http://localhost:8080/manager/text</url>
<path>/examplePath</path>
</configuration>
</plugin>
..
</plugins>

How to set server port with org.eclipse.jetty:jetty-maven-plugin?

I am currently setting the port via a jetty.xml file and I've been trying to figure out from the new documentation how to actually define an httpConnector through the Maven plugin's configuration. The docs on Eclipse's site seem a bit vague on it and I've been trying to figure this out for a while, thus ending up using a jetty.xml. I'd like to find out the proper way to do this now.
I'm currently using org.eclipse.jetty:jetty-maven-plugin:9.2.1.v20140609.
The jetty-maven-plugin documentation (for jetty 11 at the time of this answer - update) states that you can either configure the httpConnector element in the pom.xml file to setup the ServerConnector preferences or use the jetty.http.port system property to change the port or use the Jetty descriptor i.e. the way you are doing it actually.
Then you have several options:
(Java) System Property:
Change the port when just running your application through the mvn command:
mvn jetty:run -Djetty.http.port=9999
(Maven) Project Property:
Set the property inside your project pom.xml descriptor file:
<properties>
<jetty.http.port>9999</jetty.http.port>
</properties>
Then just run your application through the Jetty plugin and the port will be picked up automatically:
mvn jetty:run
(Maven) Jetty Plugin Configuration:
Set the port in your plugin declaration inside the pom.xml file:
<build>
<plugins>
<plugin>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>9.2.1.v20140609</version>
<configuration>
<httpConnector>
<!--host>localhost</host-->
<port>9999</port>
</httpConnector>
</configuration>
</plugin>
</plugins>
</build>
EDIT
In new versions of jetty-maven-plugin, jetty.http.port is the default port property and jetty.port won't work as in previous plugin versions.
Run following command:
mvn jetty:run -Djetty.port=9999
I guess mvn jetty:run -Djetty.http.port=9999 is deprecated. It didn't work for me.
You may configure the port through the pom.xml:
<build>
<plugins>
<plugin>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>9.2.1.v20140609</version>
<configuration>
<httpConnector>
<port>9999</port>
</httpConnector>
</configuration>
</plugin>
</plugins>
</build>
This works for me, confirmed as I am currently debugging the server in my chrome on port 8088.
mvn jetty:run -Dhttp.port=8088
By Default Jetty runs on 8080 port, if any application like oracle DB using that port in your system then Jetty server will not start and gives some BIND exception. to overcome this if your project is maven project then in pom.xml file use below code, then it works perfectly(here i am using port 8888 which is free in my system)
<!-- The Jetty plugin allows us to easily test the development build by
running jetty:run on the command line. -->
<plugin>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>${jetty.plugin.version}</version>
<configuration>
<scanIntervalSeconds>2</scanIntervalSeconds>
<httpConnector>
<host>localhost</host>
<port>8888</port>
</httpConnector>
</configuration>
</plugin>
<connectors>
<connector>
<port>9999</port>
</connector>
</connectors>
in pom.xml file

Resources