Maven command: mvn tomcat:run - tomcat6

When using mvn tomcat:run, Maven downloads the Tomcat bundles into the target directory and the plugin starts this Tomcat instance with the web project. This Tomcat instance is not visible in Eclipse's server view.
But I have a local Tomcat 6 installed, can I configure the Tomcat Plugin in a way that it uses this local Tommcat instance (under CATALINA_HOME) instead of installing a new version into the target project?

This is by design. The official doc for tomcat:run says:
When developping a war project, you usually build your war and deploy it to an installed Tomcat instance. This is time and resources consuming and take time to install locally the instance.
The run mojo give you the opportunity to save that by simply running your war inside an embeded Tomcat instance in your Maven build.
So I have to start the installed Tomcat instance in the server view and then the maven plugin is using this server instance for goals other then tomcat:run.

1)upgrade your Tomcat to Tomcat 7,
2)Configure your Tomcat users.xml to include a set of credentials :
<tomcat-users>
<role rolename="manager-gui"/>
<role rolename="manager-script"/>
<role rolename="manager-jmx"/>
<role rolename="manager-status"/>
<role rolename="manager"/>
<role rolename="admin-gui"/>
<role rolename="admin-script"/>
<role rolename="admin"/>
<role rolename="manager-gui"/>
<role rolename="manager-script"/>
<user password="password" roles="manager-gui, manager-script, manager-jmx, manager-status, manager, admin-gui, admin-script, admin" username="admin"/>
</tomcat-users>
Your Maven .settings.xml:
<server>
<id>local_tomcat</id>
<username>admin</username>
<password>password</password>
</server>
Create a new 'dev' profile with new Tomcat plugin:
<profile>
<id>dev</id>
<build>
<finalName>tjb</finalName>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat-maven-plugin</artifactId>
<version>2.0-beta-1</version>
<configuration>
<url>http://localhost:8080/manager/text</url>
<server>local_tomcat</server>
<path>/</path>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.1.1</version>
</plugin>
</plugins>
</pluginManagement>
</build>
</profile>

Related

Apache Karaf feature offline issue

In karaf org.apache.karaf.features.cfg file
I have added
featuresRepositories=mvn:org.apache.cxf.karaf/apache-cxf/3.0.8/xml/features
featuresBoot = cxf-jaxws
The cxf feature could fetch and be installed when karaf started with the connection.
But it will fail without connection, how can I pre-install cxf feature?
This is likely far from most optimal solution for this (would love to hear about the better ones) but you could create offline-repository project using karaf-feature-archetype and configure karaf-maven-plugin use something like following configuration:
<plugin>
<groupId>org.apache.karaf.tooling</groupId>
<artifactId>karaf-maven-plugin</artifactId>
<configuration>
<startLevel>50</startLevel>
<aggregateFeatures>true</aggregateFeatures>
<checkDependencyChange>true</checkDependencyChange>
<failOnDependencyChange>false</failOnDependencyChange>
<logDependencyChanges>true</logDependencyChanges>
<overwriteChangedDependencies>true</overwriteChangedDependencies>
</configuration>
<executions>
<execution>
<id>features-add-to-repo</id>
<phase>generate-resources</phase>
<goals>
<goal>features-add-to-repository</goal>
</goals>
<configuration>
<descriptors>
<!-- Feature repository paths -->
<descriptor>mvn:groupId/artifactId/version/xml/features</descriptor>
</descriptors>
<features>
<!-- features and their artifacts + dependencies to add to offline repository-->
<feature>featureName</feature>
<feature>featureName/version</feature>
</features>
<repository>target/offline-repository</repository>
</configuration>
</execution>
</executions>
</plugin>
When packaging the project i.e with command maven clean install (in environment with online access) it'll generate offline-repository under target folder which you can copy to your offline environment and tell karaf to use it by adding it to org.ops4j.pax.url.mvn.defaultRepositories in file org.ops4j.pax.url.mvn.cfg i.e file:${user.home}/offline-repository#snapshots#id=local if its located in home directory.
features.xml itself can be empty this is just to use karaf-maven-plugin not to create an actual feature repository.
Just be careful if you need to create a new version of the offline-repository to replace the old one. If the new version is missing any of the artifacts that are currently installed to karaf it can cause issues when trying to remove/uninstall them.

queue.yaml not deployed when i use mvn appengine:deploy

I updated my pom.xml to use the new mvn appengine plugin
<plugin>
<groupId>com.google.cloud.tools</groupId>
<artifactId>appengine-maven-plugin</artifactId>
<version>1.2.0</version>
<configuration>
<project>{project_id}</project>
<devserver.host>0.0.0.0</devserver.host>
<devserver.port>1984</devserver.port>
</configuration>
</plugin>
Now when I run mvn appengine:deploy it converts my queue.xml to queue.yaml in the staging directory. However this queue configuration is not deployed.
I have tried so many ways to deploy it to google cloud but nothing worked. This setup is for my cloud endpoints project setup. The documentations do not cover this.
This is the maven plugin code i added after trying your suggestion out .
<plugin>
<groupId>com.google.cloud.tools</groupId>
<artifactId>appengine-maven-plugin</artifactId>
<version>1.2.0</version>
<configuration>
<project>{project_id}</project>
<devserver.host>0.0.0.0</devserver.host>
<devserver.port>1984</devserver.port>
</configuration>
</plugin>
I opened a similar issue on the project board
By default, only the app.yaml file is deployed (which represents the application).
If you want (in addition, or only) the queue.yaml, or even the cron or index, you need to specify those files inside the plugin configuration.
<plugin>
<groupId>com.google.cloud.tools</groupId>
<artifactId>appengine-maven-plugin</artifactId>
<version>${appengine.maven.plugin.version}</version>
<configuration>
<deployables>
<param>target/appengine-staging/app.yaml</param>
<param>target/appengine-staging/cron.yaml</param>
<param>target/appengine-staging/queue.yaml</param>
<param>target/appengine-staging/index.yaml</param>
</deployables>
</configuration>
</plugin>
Please remember that if you specificy certain files, the app.yaml files should be added as well. It is deployed by default only if the deployabels parameter is missing.
Playing with this parameter you can choose which files to deploy

How to set version when deploying gae java?

Since Intellij Idea IDE gae deployment plugin does not work, I have to use mvn appengine:update. It always deploy to version 1, ignoring version in appengine-web.xml.
How to set version with mvn appengine:update deployment?
Another way is, don't add anything on the app engine plugin as it is hard to changes each time the pom.xml better pass the version information from the command line, like this
mvn clean package appengine:deploy -Dapp.deploy.version=your-version-here
reference document here
You can set it via a Maven property:
<properties>
<appengine.appId>my-application-id</appengine.appId>
<appengine.version>my-application-version</appengine.version>
</properties>
PS: I'm also setting the applicationId here, you don't necessarily need that.
Add the following into the plugins section in the project pom.xml file:
<plugin>
<groupId>com.google.cloud.tools</groupId>
<artifactId>appengine-maven-plugin</artifactId>
<version>2.2.0</version>
<configuration>
<deploy.projectId>java</deploy.projectId>
<deploy.version>1</deploy.version>
</configuration>
</plugin>
Set the version in plugin property
<plugin>
<groupId>com.google.cloud.tools</groupId>
<artifactId>appengine-maven-plugin</artifactId>
<version>1.3.2</version>
<configuration>
<version>2</version>
</configuration>
</plugin>

change default port 8080 maven gae goal appengine:devserver

I'm having a problem, probably is quite simple but I did not find the solution yet.
I'm trying to launch my local GAE server (through Run-configurations of Eclipse) on a specific port (8888 in my case) but it starts only at default port 8080 and after trying with different options ... I'm not lucky
Any ideas?
Run this from the cmd line: mvn help:describe -Dcmd=appengine:devserver -Ddetail - you'll see all the available options for appengine:devserver goal.
The one that you want is:
mvn appengine:devserver -Dappengine.port=8888
The Google Plugin for eclipse (GPE) allows you to specify the port number on the second tab ('Server') in a run configuration.
If you're not using that (which you probably should be) you can configure the port in your pom directly like this:
<plugin>
<groupId>com.google.appengine</groupId>
<artifactId>appengine-maven-plugin</artifactId>
<version>${gae.version}</version>
<configuration>
<port>8080</port>
<address>0.0.0.0</address>
</configuration>
</plugin>
What have you tried?
Have you tried adding the --port 8888 option to your run configuration?
If you are following the tutorial:
https://cloud.google.com/appengine/docs/standard/java/quickstart
It seems that the documentation has changed:
https://cloud.google.com/appengine/docs/flexible/java/maven
Use <host> instead of <address>
Here is how you bind the host address for Docker:
<plugin>
<groupId>com.google.cloud.tools</groupId>
<artifactId>appengine-maven-plugin</artifactId>
<version>1.3.2</version>
<configuration>
<enableJarClasses>false</enableJarClasses>
<port>8080</port>
<host>0.0.0.0</host>
<admin_host>0.0.0.0</admin_host>
</configuration>
</plugin>

How to build GAE application for SDK v1.7.5 (with Maven)

I'm trying to make GAE 1.7.5 work with Maven:
<properties>
<gae.version>1.7.5</gae.version>
<gae-runtime.version>1.7.5.1</gae-runtime.version>
<maven.gae.plugin.version>0.9.6</maven.gae.plugin.version>
</properties>
<plugin>
<groupId>net.kindleit</groupId>
<artifactId>maven-gae-plugin</artifactId>
<version>${maven.gae.plugin.version}</version>
<configuration>
<unpackVersion>${gae.version}</unpackVersion>
<serverId>appengine.google.com</serverId>
<appDir>${webappDirectory}</appDir>
</configuration>
<dependencies>
<dependency>
<groupId>net.kindleit</groupId>
<artifactId>gae-runtime</artifactId>
<version>${gae-runtime.version}</version>
<type>pom</type>
</dependency>
</dependencies>
</plugin>
However there is this problem:
[WARNING] The POM for net.kindleit:maven-gae-plugin:jar:0.9.6 is missing, no dependency information available
[WARNING] Failed to retrieve plugin descriptor for net.kindleit:maven-gae-plugin:0.9.6: Plugin net.kindleit:maven-gae-plugin:0.9.6 or one of its dependencies could not be resolved: Failed to read artifact descriptor for net.kindleit:maven-gae-plugin:jar:0.9.6
[WARNING] The POM for org.eclipse.m2e:lifecycle-mapping:jar:1.0.0 is invalid, transitive dependencies (if any) will not be available, enable debug logging for more details
Then eventually, will end into BUILD FAILURE.
How to build my GAE against version 1.7.5 with Maven?
You can use the App Engine Maven Plugin. We also have a guestbook sample app on github.
The official appengine-maven-plugin supports 1.7.6, you could use the 1.7.5 version if you want, but 1.7.6 is current now.

Resources