Deploy maven project to tomcat - java

I have Maven project and Tomcat server.
I work in IDEA when I click in "Maven LifeCicle" -> "deploy", i have a problem:
[INFO] --- maven-deploy-plugin:2.7:deploy (default-deploy) # TestMaven ---
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 8.035 s
[INFO] Finished at: 2014-09-20T13:52:32+04:00
[INFO] Final Memory: 11M/93M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy (default-deploy) on project TestMaven: Deployment failed: repository element was not specified in the POM inside distributionManagement element or in -DaltDeploymentRepository=id::layout::url parameter -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
Piace of my POM.xml is:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>tomcat-maven-plugin</artifactId>
<configuration>
<server>tomcat</server>
<url>http://localhost:8080/manager/text</url>
</configuration>
</plugin>
Not worked or:
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.0</version>
</plugin>
also not worked.

In the default maven lifecycle mvn deploy means to deploy one or more build artifacts to a maven repository. The reason is because the maven-deploy-plugin's deploy goal is bound to the deploy phase of the lifecycle. This configuration is automatically done when you use for example packaging jar.
In maven
a maven build lifecycle is made up of phases
a phase is made up of plugin goals
the packaging type (e.g. jar, ear, war) pre-configures plugins goals for execution in a lifecycle phase
In order to solve your problem I would first package the webapp and then invoke the deploy goal of the tomcat7-maven-plugin.
mvn package org.apache.tomcat.maven:tomcat7-maven-plugin:2.0:deploy
or simply
mvn package tomcat7:deploy
The mvn command above means:
invoke the default build lifecycle until phase package
then the goal deploy of the tomcat7 plugin.
If you want to know how maven resolves tomcat7:deploy to org.apache.tomcat.maven:tomcat7-maven-plugin:2.0:deploy you should read more about plugin groups and plugin naming conventions.

With maven deploy command, usually gets errors for various reasons.
if you work in Unix/Linux system, I recommend using "rsync" method on console. (You can write own shell script to manage easily). It helps not only deploying without a problem but also helps to get time while redeploying (only uploading changed / new files). Because maven deploy / redeploy uploads your project as a bundle in jar/war. However "rysnc" method uploads your project files one by one.
Before using it, you should sure that two conditions.
1- your project is built in target folder (Spring Tool Suite)
2- you have access to tomcat via ssh
example code : (v_ : prefix which is variable(customizable))
rsync -avz v_your_project_in_target root#v_ip:v_tomcat_name/webapps/v_project_name

Related

Maven WildFly Plugin: Could not execute goal deploy

I want to deploy my war-files with the maven wildfly-plugin.
I use the wildfly-8.2.0.Final-version and I was to force to change the port of the management-console to http://127.0.0.1:9990.
This is my maven configuration:
<plugin>
<groupId>org.wildfly.plugins</groupId>
<artifactId>wildfly-maven-plugin</artifactId>
<version>1.0.2.Final</version>
<configuration>
<jbossHome>C:\wildfly-8.2.0.Final</jbossHome>
<hostname>127.0.0.1</hostname>
<port>8080</port>
<serverConfig>standalone-full.xml</serverConfig>
</configuration>
</plugin>
I get following error:
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.705 s
[INFO] Finished at: 2016-02-01T22:46:43+01:00
[INFO] Final Memory: 21M/171M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.wildfly.plugins:wildfly-maven-plugin:1.0.2.Final:deploy (default-cli) on project wildfly: Could not execute goal deploy on C:\Users\laudatio\Documents\Java\wildfly\target\wildfly.war. Reason: I/O Error could not execute operation '{
[ERROR] "operation" => "read-attribute",
[ERROR] "address" => [],
[ERROR] "name" => "launch-type"
[ERROR] }': java.io.IOException: Unknown service name
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
Any suggestions?
The error message isn't great, it's been fixed upstream, but the issue is you've got the wrong port defined. The plugin uses the management port which by default is 9990. If you change the configuration to <port>9990</port> or leave it off it should work.
A side note most of the configuration you have is not needed. The jbossHome and serverConfig are only needed for the run and start goals. If you're just deploying you don't need any of that configuration defined. The defaults should be correct.
The reason of the problem could be one of the following:
The deployment of any archive (jar, war, ear) through wildfly-maven-plugin plugin will happen only if the WildFly is listening at its management port which is 9990 by default. So make sure that WildFly is listening at its management port.
If WildFly is listening at its management port then check if your host file located at %SYSTEM_ROOT%\System32\drivers\etc for windows machine is configured correctly. i.e. your local host is mapped correctly for both IPv4 and IPv6.
127.0.0.1 localhost
::1 localhost

The POM for org.picketlink.distribution:picketlink-jbas7:jar:2.8.0. is missing, no dependency information available

I'm trying to run the picketlink quickstarts from:
https://github.com/jboss-developer/jboss-picketlink-quickstarts
More specifically:
https://github.com/jboss-developer/jboss-picketlink-quickstarts/tree/master/picketlink-federation-saml-idp-basic
But in each attempt to install the maven dependencies I get the next error:
Could not find artifact org.picketlink.distribution:picketlink-jbas7:jar:2.8.0.Beta1-SNAPSHOT
Here is the whole log after my $ mvn clean package jboss-as:deploy
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building PicketLink Quickstart: picketlink-federation-saml-idp-basic 2.8.0.Beta1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[WARNING] The POM for org.picketlink.distribution:picketlink-jbas7:jar:2.8.0.Beta1-SNAPSHOT is missing, no dependency information available
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.650 s
[INFO] Finished at: 2015-10-17T01:39:15-05:00
[INFO] Final Memory: 6M/80M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project picketlink-federation-saml-idp-basic: Could not resolve dependencies for project org.picketlink.quickstarts:picketlink-federation-saml-idp-basic:war:2.8.0.Beta1-SNAPSHOT: Could not find artifact org.picketlink.distribution:picketlink-jbas7:jar:2.8.0.Beta1-SNAPSHOT -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/DependencyResolutionException
I've seen that you might need to add a settings.xml to your maven folder, but I don't know how to make or what to put in that file.
As you already said, maven is telling you that org.picketlink.distribution:picketlink-jbas7:jar:2.8.0.Beta1-SNAPSHOT dependency is missing and I believe this is because you didn't install it previously.
As I can see jboss-picketlink-quickstarts is a bunch of projects which have a parent pom.xml where you can find your project as a module:
<module>picketlink-federation-saml-idp-basic</module>
So, you have to clone the whole jboss-picketlink-quickstarts project and run mvn install from the parent project.
This will lead you with all dependencies that you will need resolved into your local maven repository (usually ~/.m2/repository).
Try it, it will solve your dependency. Some times you have to call maven with -U to force -SNAPSHOT dependencies.
Hope it helps!

Error running Google App Engine quickstart : POM for com.google.appengine:appengine-maven-plugin:jar:1.9.24 is missing

Any help getting me past this error would be appreciated. Google searches don't seem to turn up any helpful results.
I am on a Macbook Pro running OSX Yosemite and using the Java 1.7.0_71 with Maven 3.3. Maven was installed via HomeBrew.
To get an introduction of Google App Engine, I followed the instructions for the quickstart from https://cloud.google.com/appengine/docs/java/gettingstarted/introduction and reach the page instructions at https://cloud.google.com/appengine/docs/java/gettingstarted/ui_and_code without issue.
After creating the guestbook.jsp file and running mvn appengine:devserver I get the following build failure.
[INFO] Scanning for projects...
[WARNING] The POM for com.google.appengine:appengine-maven-plugin:jar:1.9.24 is missing, no dependency information available
[WARNING] Failed to retrieve plugin descriptor for com.google.appengine:appengine-maven-plugin:1.9.24: Plugin com.google.appengine:appengine-maven-plugin:1.9.24 or one of its dependencies could not be resolved: Failure to find com.google.appengine:appengine-maven-plugin:jar:1.9.24 in https://repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced
Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-metadata.xml
Downloading: https://repo.maven.apache.org/maven2/org/codehaus/mojo/maven-metadata.xml
Downloaded: https://repo.maven.apache.org/maven2/org/codehaus/mojo/maven-metadata.xml (20 KB at 4.3 KB/sec)
Downloaded: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-metadata.xml (13 KB at 2.2 KB/sec)
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 6.435 s
[INFO] Finished at: 2015-07-22T21:10:29-04:00
[INFO] Final Memory: 10M/245M
[INFO] ------------------------------------------------------------------------
[ERROR] No plugin found for prefix 'appengine' in the current project and in the plugin groups [org.apache.maven.plugins, org.codehaus.mojo] available from the repositories [local (/Users/nissandookeran/.m2/repository), central (https://repo.maven.apache.org/maven2)] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/NoPluginFoundForPrefixException
Version 1.9.24 of the Appengine Maven Plugin hasn't been deployed to Maven Central yet, for whatever reason. Probably the easiest thing to do is to open your pom.xml, find the <version> of appengine-maven-plugin that it's using, and make it use 1.9.23 instead of ${appengine.version} or 1.9.24 or whatever it's using.
If it is due to a new version you can try also to run mvn appengine:devserver -U
You have to include the following in the pom file
<plugin>
<groupId>com.google.cloud.tools</groupId>
<artifactId>appengine-maven-plugin</artifactId>
<version>1.9.48</version>
</plugin>

Oracle JDBC 7 as Maven dependency

I'm attempting to add Oracle JDBC to my project as a maven dependency. I've followed multiple tutorials online which suggest various means to add a third party dependency.
I've opted for the local installation method, but like (this person) I'm experiencing issues.
I run the following command to install the jar:
mvn install:install-file -Dfile={lib/ojdbc7.jar} -DgroupId=com.oracle -DartifactId=ojdbc7 -Dversion=12.1.0.1 -Dpackaging=jar
and it succeeds with:
[INFO] --- maven-install-plugin:2.3:install-file (default-cli) # standalone-pom ---
[INFO] Installing /home/<myfolder>/{lib/ojdbc7.jar} to /home/<myname>/.m2/repository/com/oracle/ojdbc7/12.1.0.1/ojdbc7-12.1.0.1.jar
I have then added the following to my pom:
<dependency>
<groupId>com.oracle</groupId>
<artifactId>ojdbc7</artifactId>
<version>12.1.0.1</version>
</dependency>
and yet when I compile I get the following:
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.307s
[INFO] Finished at: Sat May 02 20:40:07 NZST 2015
[INFO] Final Memory: 8M/56M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project xxx: Could not resolve dependencies for project com.xxx:xxx:jar:1.0-SNAPSHOT: Failure to find com.oracle:ojdbc7:jar:12.1.0.1 in http://repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/DependencyResolutionException
I've played around with the -U and -o flags to no avail. I have also tried installing the jar by first cding into the lib directory (as suggested by Raghuram on the other question) with no change.
Solution
Manually place this ojdbc7-12.1.0.1.jar file in your Local Maven/Cache Repository.
Use mvn deploy goal while you are using 3rd Party Jar/Proprietary JAR Files in your Local Maven Repository.

Downloading Jetty source and Javadoc jars with maven and linking them to binary jars in Eclipse

I am working on a web app project written in Java (1.6) using Eclipse IDE (3.6), and have decided to use Jetty (8.0.4) as the web server and servlet container. I am using maven (2) for dependency and build management. To get started, I decided to write a simple test application to make sure I had things working end-to-end. This is working fine, and I am able to start up the server and create some simple servlets. However, the source and Javadoc jars were not downloaded by maven, so when the mouse hovers over method names or classes, no documentation is found. It just reports the following:
Open Declaration javax.servlet.http.HttpServletResponse
Note: This element neither has attached source nor attached Javadoc and hence no Javadoc could be found.
I've searched for how to do this, and all I could find was this page on the Eclipse website describing how to configure maven to download the source modules as well. It says that the source module jars have the same name as the binary jars, with the suffix "-sources". I added source module dependencies to my maven config for each binary module, like so:
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-server</artifactId>
<version>${jettyVersion}</version>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-server-sources</artifactId>
<version>${jettyVersion}</version>
</dependency>
However, maven failed to find the source module dependencies:
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Jetty Servlet Example 0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
Downloading: http://repo1.maven.org/maven2/org/eclipse/jetty/jetty-server-sources/8.0.4.v20111024/jetty-server-sources-8.0.4.v20111024.pom
[WARNING] The POM for org.eclipse.jetty:jetty-server-sources:jar:8.0.4.v20111024 is missing, no dependency information available
Downloading: http://repo1.maven.org/maven2/org/eclipse/jetty/jetty-servlet-sources/8.0.4.v20111024/jetty-servlet-sources-8.0.4.v20111024.pom
[WARNING] The POM for org.eclipse.jetty:jetty-servlet-sources:jar:8.0.4.v20111024 is missing, no dependency information available
Downloading: http://repo1.maven.org/maven2/org/eclipse/jetty/jetty-util-sources/8.0.4.v20111024/jetty-util-sources-8.0.4.v20111024.pom
[WARNING] The POM for org.eclipse.jetty:jetty-util-sources:jar:8.0.4.v20111024 is missing, no dependency information available
Downloading: http://repo1.maven.org/maven2/org/eclipse/jetty/jetty-server-sources/8.0.4.v20111024/jetty-server-sources-8.0.4.v20111024.jar
Downloading: http://repo1.maven.org/maven2/org/eclipse/jetty/jetty-servlet-sources/8.0.4.v20111024/jetty-servlet-sources-8.0.4.v20111024.jar
Downloading: http://repo1.maven.org/maven2/org/eclipse/jetty/jetty-util-sources/8.0.4.v20111024/jetty-util-sources-8.0.4.v20111024.jar
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3.098s
[INFO] Finished at: Sun Apr 15 15:42:59 PDT 2012
[INFO] Final Memory: 5M/180M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project hello-world: Could not resolve dependencies for project org.example:hello-world:jar:0.1-SNAPSHOT: The following artifacts could not be resolved: org.eclipse.jetty:jetty-server-sources:jar:8.0.4.v20111024, org.eclipse.jetty:jetty-servlet-sources:jar:8.0.4.v20111024, org.eclipse.jetty:jetty-util-sources:jar:8.0.4.v20111024: Could not find artifact org.eclipse.jetty:jetty-server-sources:jar:8.0.4.v20111024 in central (http://repo1.maven.org/maven2) -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/DependencyResolutionException
Any pointers on how to configure maven to download the Jetty sources and javadocs?
Try to recreate your Eclipse project with this Maven command:
mvn eclipse:eclipse -DdownloadSources=true -DdownloadJavadocs=true
Another option is to update your pom.xml:
<plugin>
<artifactId>org.eclipse.jetty</artifactId>
<version>${jettyVersion}</version>
<configuration>
<downloadSources>true</downloadSources>
<downloadJavadocs>true</downloadJavadocs>
</configuration>
</plugin>
Both solutions only work if the source and javadocs were provided to the repo you're downloading from.
In your case (and your version) it should work because you can find the sources.jar in the Jetty repository.

Categories

Resources