deploying a war file with maven to tomcat using HTTPS - java

I'm using Tomcat 8, Maven 3.1.1 , JDK 1.8.0_31 and tomcat7-maven-plugin 2.2 .
My OS is Windows 7 64 bit.
I can't deploy a war file to Tomcat when it's configured for HTTPS. HTTP works fine.
I found two threads on Stackoverflow but they didn't solve my problem.
The keystore file contains only one entry.
My maven settings.xml contains valid admin credentials for the tomcat server.
Here is the POM plugin configuration.
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.2</version>
<configuration>
<url>https://localhost:8443/manager/text</url>
<server>tomcat8-local</server>
<path>/entryServlet</path>
<httpsPort>8443</httpsPort>
<keystoreFile>D:\intellij-project\keystore\keystore</keystoreFile>
<keystorePass>pass1</keystorePass>
</configuration>
</pugin>
This is the maven output:
[INFO] --- tomcat7-maven-plugin:2.2:deploy (default-cli) # intellij-project ---
[INFO] Deploying war to https://localhost:8443/entryServlet
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.194s
[INFO] Finished at: Wed Jan 21 10:13:29 CET 2015
[INFO] Final Memory: 17M/206M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.tomcat.maven:tomcat7-maven-plugin:2.2:deploy (default-cli) on project intellij-project:
Cannot invoke Tomcat manager: sun.security.validator.ValidatorException:
PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException:
unable to find valid certification path to requested target -> [Help 1]

I found the solution: I had to import my self-created certificate in
the Java keystore located in JAVA_HOME/jre/lib/security
I followed these instructions:
No more 'unable to find valid certification path to requested target'

Related

Deployment failed: repository element was not specified in the POM

I imported an Maven application for the Intellij Idea. After configure Spring and Hibernate, i tried to build it. But, Maven return an error to me, the error is:
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 8.571 s
[INFO] Finished at: 2019-07-04T15:49:48-03:00
[INFO] Final Memory: 16M/211M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy (default-deploy) on project GECi: Deployment failed: repository element was not specified in the POM inside distributionManagement element or in -DaltDeploymentRepository=id::layout::url parameter -> [Help 1]
[ERROR]
If you can help me, i'll appreciate that :D Thanks
Calling mvn deploy means you want to deploy to a Maven repository. You need to specify that repository in the <distributionManagement> element of the POM.

deploy using Jboss Tools plugin for OpenShift generates error invalid target release: 1.8

I'm using JBoss Tools plugin in my project to deploy the application to OpenShift. When command to deploy the build failure. Follow the log of the error below:
Stopping jbossews cartridge
Sending SIGTERM to jboss:354331 ...
Stopping MySQL 5.5 cartridge
Stopping PHPMyAdmin cartridge
Waiting for stop to finish
Waiting for stop to finish
Repairing links for 1 deployments
Building git ref 'master', commit 11577ee
Using Maven mirror /var/lib/openshift/56cb57232d5271befc00009a/app-root/runtime/repo//.openshift/config/settings.rhcloud.xml
Apache Maven 3.0.4 (r1232336; 2012-12-18 14:36:37-0500)
Maven home: /usr/share/java/apache-maven-3.0.4
Java version: 1.7.0_95, vendor: Oracle Corporation
Java home: /usr/lib/jvm/java-1.7.0-openjdk-1.7.0.95/jre
Default locale: en_US, platform encoding: ANSI_X3.4-1968
OS name: "linux", version: "2.6.32-573.18.1.el6.x86_64", arch: "i386", family: "unix"
Found pom.xml... attempting to build with 'mvn --global-settings /var/lib/openshift/56cb57232d5271befc00009a/app-root/runtime/repo//.openshift/config/settings.rhcloud.xml clean package -Popenshift -DskipTests'
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Picos 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.4.1:clean (default-clean) # Picos ---
[INFO]
[INFO] --- maven-resources-plugin:2.5:resources (default-resources) # Picos ---
[debug] execute contextualize
[WARNING] Using platform encoding (ANSI_X3.4-1968 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 1 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) # Picos ---
[INFO] Changes detected - recompiling the module!
[WARNING] File encoding has not been set, using platform encoding ANSI_X3.4-1968, i.e. build is platform dependent!
[INFO] Compiling 102 source files to /var/lib/openshift/56cb57232d5271befc00009a/app-root/runtime/repo/target/classes
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 5.770s
[INFO] Finished at: Tue Feb 23 13:43:53 EST 2016
[INFO] Final Memory: 8M/114M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project Picos: Fatal error compiling: invalid target release: 1.8 -> [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
An error occurred executing 'gear postreceive' (exit code: 1)
Error message: CLIENT_ERROR: Failed to execute: 'control build' for /var/lib/openshift/56cb57232d5271befc00009a/jbossews
I'm locally using java tomcat 8 and 8 to run my project. I think it has to do with it. What should I do so that I can do to deploy OpenShift?
Could someone help me?
You need to use Java 7 and (probably) Tomcat 7 locally to develop your application so that it is compatible with OpenShift Online. If you want to keep using Java 8, you should try deploying to the WildFly or JBoss EAP cartridges.

Unable to redeploy the java application to tomcat7 using maven deployment

This is my pom.xml
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.2</version>
<configuration>
<url>http://192.168.10.42:8086/manager/html</url>
<server>TomcatServer</server>
<path>/MavenExample321</path>
<username>XXX</username>
<password>XXXXXX</password>
</configuration>
</plugin>
Am trying to redeploy the java application using maven using following command
mvn tomcat7:redeploy
am able to deploy but unable to redeploy application to same path second time, its giving the following error
[INFO] tomcatManager status code:200, ReasonPhrase:OK
[INFO] OK - Undeployed application at context path /MavenExample321
[INFO] FAIL - Failed to deploy application at context path /MavenExample321
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 56.490s
[INFO] Finished at: Wed Nov 25 11:00:38 IST 2015
[INFO] Final Memory: 16M/183M
[INFO] ------------------------------------------------------------------------
Finally I found the solution.
Use following update tag in configuration
<update>true</update>
and use the following command to undeploy last deployed application and redeploy the new war file with same name.
mvn clean tomcat:deploy

How to install tomcat maven plugin?

I'm trying to run the basic CXF maven archetype.
I've just tried to install tomcat7-maven-plugin-2.2.jar manually using :
mvn -X install:install-file -Dfile=/tmp/path/tomcat7-maven-plugin-2.2.jar -DgroupId=org.apache.tomcat.maven -DartifactId=tomcat7-maven-plugin -Dversion=2.2 -Dpackaging=jar
which leads to :
[INFO] Installing /tmp/path/tomcat7-maven-plugin-2.2.jar to /home/userxxx/.m2/repository/org/apache/tomcat/maven/tomcat7-maven-plugin/2.2/tomcat7-maven-plugin-2.2.jar
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
[INFO] ------------------------------------------------------------------------
[INFO] Total time: < 1 second
[INFO] Finished at: Fri Jan 23 17:50:42 CET 2015
[INFO] Final Memory: 4M/179M
[INFO] ------------------------------------------------------------------------
BUT when I try to call it on my project via :
mvn clean install tomcat:run-war
It says :
[INFO] Searching repository for plugin with prefix: 'tomcat'.
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] The plugin '**org.codehaus.mojo**:tomcat-maven-plugin' does not exist or no valid version could be found
Would u have an idea why maven is looking for "org.codehaus.mojo" groupId instead of "org.apache.tomcat.maven" ?
I know it was hosted at "org.codehaus.mojo" before, so is it a bug ?
Should I install the plugin in this groupId ?
Ok, I get it, the comment in the CXF archetype is wrong :
<!-- mvn clean install tomcat:run-war to deploy
Look for "Running war on http://xxx" and
"Setting the server's publish address to be /yyy"
in console output; WSDL browser address will be
concatenation of the two: http://xxx/yyy?wsdl
-->
It should say mvn clean install **tomcat7**:run-war to deploy to correspond to the plugin they use in this archetype.

How to start launch the HSQLDB server as described in the Hibernate tutorial?

Trying to follow step #4 in this Hibernate tutorial:
mvn exec:java -Dexec.mainClass="org.hsqldb.Server" -Dexec.args="-database.0 file:target/data/tutorial"
I am getting this error:
[INFO] Scanning for projects...
[INFO] Searching repository for plugin with prefix: 'exec'.
[INFO] ------------------------------------------------------------------------
[INFO] Building First Hibernate Tutorial
[INFO] task-segment: [exec:java]
[INFO] ------------------------------------------------------------------------
[INFO] Preparing exec:java
[INFO] No goals needed for project - skipping
[INFO] [exec:java {execution: default-cli}]
[WARNING]
java.lang.ClassNotFoundException: org.hsqldb.Server
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
at org.codehaus.mojo.exec.ExecJavaMojo$1.run(ExecJavaMojo.java:285)
at java.lang.Thread.run(Thread.java:662)
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] An exception occured while executing the Java class. org.hsqldb.Server
[INFO] ------------------------------------------------------------------------
[INFO] For more information, run Maven with the -e switch
[INFO] ------------------------------------------------------------------------
[INFO] Total time: < 1 second
[INFO] Finished at: Mon Dec 17 16:35:42 EST 2012
[INFO] Final Memory: 6M/15M
[INFO] ------------------------------------------------------------------------
This is despite downloading the latest hsqldb package and installing it per the FAQ. The hsqldb.jar file is located in C:\hsqldb-2.2.9\hsqldb-2.2.9\hsqldb\lib and the classpath env var points at it:
CLASSPATH=C:\hsqldb-2.2.9\hsqldb-2.2.9\hsqldb\lib
So why am I receiving this ClassNotFoundException: org.hsqldb.Server error?
What am I doing wrong?
First of all, your CLASSPATH is not generally correct for any jar. A jar name must be specified, for example:
CLASSPATH=C:\hsqldb-2.2.9\hsqldb-2.2.9\hsqldb\lib\hsqldb.jar
Second, CLASSPATH is not necessary for this tutorial, as it is a Maven project. You should add the relevant dependency to the pom.xml file that is described in section 1.1.1 of the tutorial you mention. Simply add this block to the ones listed in the pom.xml, inside the tab:
<dependency>
<groupId>org.hsqldb</groupId>
<artifactId>hsqldb</artifactId>
<version>2.2.9</version>
</dependency>
According to http://docs.oracle.com/javase/7/docs/technotes/tools/windows/classpath.html, you need to specify the whole path ending with .jar. If there are multiple jar files, maybe try specifying C:\path\to\hibernate*.jar
If you only specify directories, only *.class files are loaded.
Other possiblity is the CLASSPATH variable you set only valid for a shell session, not globally -- hence the maven command is not reading it. Try setting it via Windows system settings.
I would recommend to download fresh copy of tutorial from http://sourceforge.net/projects/hibernate/files/hibernate3/3.3.2.GA/ and try to build it. If you will be missing dependendiens like hsqldb or commons-logging and others I got this problem solved by adding maven project repository - https://repository.jboss.org/nexus/content/repositories/thirdparty-releases. Once all artifacts downloaded I was able to run HSQLDB server. Would recommend to compare your current project with freshly downloaded one. It should solve your problem.

Categories

Resources