A
A
Alexiuscrow2014-12-21 13:08:26
Java
Alexiuscrow, 2014-12-21 13:08:26

Why can't deploy war file on Tomcat 8 via Maven?

There is a JSF project. You need to run it on the Tomcat 8 server. I
wrote POM:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>alexiuscrow</groupId>
  <artifactId>LabJSF</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <packaging>war</packaging>
  <name>LabJSF</name>
  
  <dependencies>
  	<dependency>
      <groupId>org.apache.myfaces.core</groupId>
      <artifactId>myfaces-api</artifactId>
      <version>2.2.6</version>
    </dependency>
  </dependencies>
  
  <build>
    <sourceDirectory>JavaSource</sourceDirectory>
    <finalName>LabJSF</finalName>
    
    <resources>
      <resource>
        <directory>JavaSource</directory>
        <excludes>
          <exclude>**/*.java</exclude>
        </excludes>
      </resource>
    </resources>
    
    <plugins>
      <plugin>
        <artifactId>maven-war-plugin</artifactId>
        <version>2.4</version>
        <configuration>
          <warSourceDirectory>WebContent</warSourceDirectory>
          <failOnMissingWebXml>false</failOnMissingWebXml>
        </configuration>
      </plugin>
      
      <plugin>
    <groupId>org.apache.tomcat.maven</groupId>
    <artifactId>tomcat7-maven-plugin</artifactId>
    <version>2.2</version>
    <configuration>
      <url>http://localhost:8080/manager/text</url>
      <server>TomcatServer</server>
      <path>/jsflearning</path>
    </configuration>
  </plugin>
  
    </plugins>
  </build>
  
</project>

read that the connected plugin for tomacat 7 should work under tomacat 8 as well.
In %TOMCAT7_PATH%/conf/tomcat-users.xml I wrote:
<?xml version='1.0' encoding='cp1251'?>

<tomcat-users xmlns="http://tomcat.apache.org/xml"
              xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
              xsi:schemaLocation="http://tomcat.apache.org/xml tomcat-users.xsd"
              version="1.0">

  <role rolename="manager-gui"/>
  <role rolename="admin-gui"/>
  <role rolename="manager-script"/>
  <role rolename="manager"/>
  <user username="admin" password="password" roles="manager-gui,admin-gui,mmanager-script,manager" />
  
</tomcat-users>

... and in %MAVEN_PATH%/conf/settings.xml :
<?xml version="1.0" encoding="UTF-8"?>
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
...
  <servers>
    <server>
      	<id>TomcatServer</id>
      	<username>admin</username>
      	<password>password</password>
    </server>
  </servers>
...
</settings>

but as a result I got:
[INFO] Scanning for projects...
[INFO]
[INFO] Using the builder org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder with a thread count of 1
[INFO]
[INFO] ----- -------------------------------------------------- -----------------
[INFO] Building LabJSF 0.0.1-SNAPSHOT
[INFO] -------------------- -------------------------------------------------- --
[INFO]
[INFO] >>> tomcat7-maven-plugin:2.2:deploy (default-cli) @ LabJSF >>>
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default -resources)@LabJSF---
[WARNING] Using platform encoding (Cp1251 actually) to copy filtered resources, ie build is platform dependent!
[INFO] Copying 1 resource
[INFO]
[INFO] --- maven-compiler-plugin:2.5.1:compile (default-compile) @ LabJSF ---
[INFO] Nothing to compile - all classes are up to date
[ INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ LabJSF ---
[WARNING] Using platform encoding (Cp1251 actually) to copy filtered resources, ie build is platform dependent!
[INFO] skip non existing resourceDirectory D:\alexiuscrow\workspace\LabJSF\src\test\resources
[INFO]
[INFO] --- maven-compiler-plugin:2.5.1:testCompile (default-testCompile) @ LabJSF -- -
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ LabJSF ---
[INFO]
[INFO] - -- maven-war-plugin:2.4:war (default-war) @ LabJSF ---
[INFO] Packaging webapp
[INFO] Assembling webapp [LabJSF] in [D:\alexiuscrow\workspace\LabJSF\target\LabJSF]
[ INFO] Processing war project
[INFO] Copying webapp resources [D:\alexiuscrow\workspace\LabJSF\WebContent]
[INFO] Webapp assembled in [1995 msecs]
[INFO] Building war: D:\alexiuscrow\workspace\LabJSF\target\ LabJSF.war
[INFO]
[INFO] <<< tomcat7-maven-plugin:2.2:deploy (default-cli) @ LabJSF <<<
[INFO]
[INFO] --- tomcat7-maven-plugin:2.2:deploy (default-cli) @ LabJSF ---
[INFO] Deploying war to localhost:8080/jsflearning Uploading
: localhost:8080/manager/text/deploy?path= %2Fjsflearning
[INFO] I/O exception (java.net.SocketException) caught when processing request: Connection reset by peer: socket write error
[INFO] Retrying request Uploading
: localhost:8080/manager/text/deploy?path=%2Fjsflearning
[INFO] I/O exception (java.net.SocketException) caught when processing request: Connection reset by peer: socket write error
[INFO] Retrying request Uploading
: localhost:8080/manager/text/deploy?path=%2Fjsflearning
[INFO] I/O exception (java.net.SocketException) caught when processing request: Connection reset by peer: socket write error
[INFO] Retrying request Uploading
: localhost:8080/manager/text/deploy?path=%2Fjsflearning
[INFO] ]------------------------------------------------ -----------------------
[INFO] BUILD FAILURE
[INFO] ------------------- -------------------------------------------------- ---
[INFO] Total time: 31.470 s
[INFO] Finished at: 2014-12-21T11:38:47+02:00
[INFO] Final Memory: 10M/24M
[INFO] -------- -------------------------------------------------- -------------
[ERROR] Failed to execute goal org.apache.tomcat.maven:tomcat7-maven-plugin:2.2:deploy (default-cli) on project LabJSF: Cannot invoke Tomcat manager: Connection reset by peer: socket write 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] cwiki.apache.org/confluence/display/MAVEN/MojoExec...

What could be the problem and how to fix it?
PS In order to change the location of the local repository in %MAVEN_PATH%/conf/settings.xml I tried to write:
<?xml version="1.0" encoding="UTF-8"?>
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
...
<localRepository>D:\alexiuscrow\mvn-repo</localRepository>
...
</settings>

but the result is the same (${user.home}/.m2/repository).
It is quite a logical assumption that the problems with deploying via maven and changing the local repository are due to the fact that for some reason maven "does not see" the %MAVEN_PATH%/conf/settings.xml file. Why is this happening?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexiuscrow, 2014-12-21
@Alexiuscrow

Problem solved.
An error was made in the %TOMCAT7_PATH%/conf/tomcat-users.xml file in the line

...
<user username="admin" password="password" roles="manager-gui,admin-gui,mmanager-script,manager" />
...

1 extra letter "m" in "manager-script"

P
Power, 2014-12-21
@Power

It seems that your tomcat is not running or is not running on port 8080.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question