how to start tomcat server automatically through tomcat 7 maven plugin - maven

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>

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

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

Deploy Java EE Wildfly REST Application to Openshift

I am new to Openshift and having trouble with deploying my Java EE project to it. I have made REST API for a simple webstore. Locally it works fine on Wildfly 9.0.2 I want to deploy it on openshift. I 've made new wildfly9 + mysql5.5 application using eclipse openshit jboss plugin and added a profile to root pom.xml:
<profiles>
<profile>
<id>openshift</id>
<build>
<finalName>webstore</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.3</version>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
<outputDirectory>deployments</outputDirectory>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
My root project consist of several maven modules including store-ear (EAR), store-jpa (JAR), store-rest (WAR), store-web (WAR), store-services (EJB), store-rest-interfaces (JAR),store-service-interfaces (JAR).
I have changed datasourse in JPA configuration (persistence.xml) to use MysqlDB on Openshift.
After pushing back to openshift the build is succesfull, but when it gets deployed it is missing some dependancies (ClassNotFoundException), and fails to deploy main war file.
You use a maven-war plugin in your openshift maven profile.
But you say that your project is packaged as en ear. So you should probably deploy this ear which contains all your project modules (wars, ejbs, libs...) instead of a specific war of your project.
To achieve this, you have to use a maven-ear plugin instead of the maven-war one in your openshift profile which would look like this:
<profile>
<id>openshift</id>
<build>
<plugins>
<plugin>
<artifactId>maven-ear-plugin</artifactId>
<version>2.10</version>
<configuration>
<outputDirectory>deployments</outputDirectory>
</configuration>
</plugin>
</plugins>
</build>
</profile>

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

Tomcat 7 maven plugin complete configuration reference

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

Resources