From 153af9a3e076a85578eca829d06c2044d4fe2a34 Mon Sep 17 00:00:00 2001 From: lperez Date: Wed, 24 May 2017 12:36:50 +0200 Subject: [PATCH 1/5] handle failed tomcat war deployment --- .../tomcat/maven/common/messages/messages.properties | 2 ++ .../tomcat/maven/common/messages/messages_fr.properties | 4 +++- .../maven/plugin/tomcat6/AbstractI18NTomcat6Mojo.java | 9 ++++++++- .../tomcat/maven/plugin/tomcat7/AbstractTomcat7Mojo.java | 8 ++++++++ .../tomcat/maven/plugin/tomcat8/AbstractTomcat8Mojo.java | 9 ++++++++- 5 files changed, 29 insertions(+), 3 deletions(-) diff --git a/common-tomcat-maven-plugin/src/main/resources/org/apache/tomcat/maven/common/messages/messages.properties b/common-tomcat-maven-plugin/src/main/resources/org/apache/tomcat/maven/common/messages/messages.properties index da29fb97..2cadf6e4 100644 --- a/common-tomcat-maven-plugin/src/main/resources/org/apache/tomcat/maven/common/messages/messages.properties +++ b/common-tomcat-maven-plugin/src/main/resources/org/apache/tomcat/maven/common/messages/messages.properties @@ -109,3 +109,5 @@ ReloadMojo.reloadingApp = Reloading application at {0} # tomcatHttpStatusError = Tomcat return http status error: {0}, Reason Phrase: {1} +tomcatHttpDeployBodyError = FAIL +tomcatHttpBodyError = Tomcat return http body error: {0} diff --git a/common-tomcat-maven-plugin/src/main/resources/org/apache/tomcat/maven/common/messages/messages_fr.properties b/common-tomcat-maven-plugin/src/main/resources/org/apache/tomcat/maven/common/messages/messages_fr.properties index f180d09c..7a74970b 100644 --- a/common-tomcat-maven-plugin/src/main/resources/org/apache/tomcat/maven/common/messages/messages_fr.properties +++ b/common-tomcat-maven-plugin/src/main/resources/org/apache/tomcat/maven/common/messages/messages_fr.properties @@ -106,4 +106,6 @@ UndeployMojo.undeployError = N'a pas pu retirer l'application : {0} ReloadMojo.reloadingApp = Rechargement de l'application sur {0} -tomcatHttpStatusError = Tomcat a retourn\u00E9 un code HTTP en erreur: {0}, raison: {1} \ No newline at end of file +tomcatHttpStatusError = Tomcat a retourn\u00E9 un code HTTP en erreur: {0}, raison: {1} +tomcatHttpDeployBodyError = ECHEC +tomcatHttpBodyError = Tomcat a retourn\u00E9 un corps HTTP en erreur: {0} \ No newline at end of file diff --git a/tomcat6-maven-plugin/src/main/java/org/apache/tomcat/maven/plugin/tomcat6/AbstractI18NTomcat6Mojo.java b/tomcat6-maven-plugin/src/main/java/org/apache/tomcat/maven/plugin/tomcat6/AbstractI18NTomcat6Mojo.java index f53eb16c..41b73394 100644 --- a/tomcat6-maven-plugin/src/main/java/org/apache/tomcat/maven/plugin/tomcat6/AbstractI18NTomcat6Mojo.java +++ b/tomcat6-maven-plugin/src/main/java/org/apache/tomcat/maven/plugin/tomcat6/AbstractI18NTomcat6Mojo.java @@ -79,6 +79,13 @@ protected void checkTomcatResponse( TomcatManagerResponse tomcatResponse ) messagesProvider.getMessage( "tomcatHttpStatusError", statusCode, tomcatResponse.getReasonPhrase() ) + ": " + tomcatResponse.getHttpResponseBody() ); - } + } else if(tomcatResponse.getHttpResponseBody().startsWith(messagesProvider.getMessage("tomcatHttpDeployBodyError"))) { + { + getLog().error( messagesProvider.getMessage( "tomcatHttpBodyError", + tomcatResponse.getHttpResponseBody() ) ); + throw new MojoExecutionException( + messagesProvider.getMessage( "tomcatHttpBodyError", + tomcatResponse.getHttpResponseBody() )); + } } } diff --git a/tomcat7-maven-plugin/src/main/java/org/apache/tomcat/maven/plugin/tomcat7/AbstractTomcat7Mojo.java b/tomcat7-maven-plugin/src/main/java/org/apache/tomcat/maven/plugin/tomcat7/AbstractTomcat7Mojo.java index ed4ff246..a9660503 100644 --- a/tomcat7-maven-plugin/src/main/java/org/apache/tomcat/maven/plugin/tomcat7/AbstractTomcat7Mojo.java +++ b/tomcat7-maven-plugin/src/main/java/org/apache/tomcat/maven/plugin/tomcat7/AbstractTomcat7Mojo.java @@ -77,6 +77,14 @@ protected void checkTomcatResponse( TomcatManagerResponse tomcatResponse ) messagesProvider.getMessage( "tomcatHttpStatusError", statusCode, tomcatResponse.getReasonPhrase() ) + ": " + tomcatResponse.getHttpResponseBody() ); + } else if(tomcatResponse.getHttpResponseBody().startsWith(messagesProvider.getMessage("tomcatHttpDeployBodyError"))) { + { + getLog().error( messagesProvider.getMessage( "tomcatHttpBodyError", + tomcatResponse.getHttpResponseBody() ) ); + throw new MojoExecutionException( + messagesProvider.getMessage( "tomcatHttpBodyError", + tomcatResponse.getHttpResponseBody() )); + } } } } diff --git a/tomcat8-maven-plugin/src/main/java/org/apache/tomcat/maven/plugin/tomcat8/AbstractTomcat8Mojo.java b/tomcat8-maven-plugin/src/main/java/org/apache/tomcat/maven/plugin/tomcat8/AbstractTomcat8Mojo.java index 74126fb1..a99cac31 100644 --- a/tomcat8-maven-plugin/src/main/java/org/apache/tomcat/maven/plugin/tomcat8/AbstractTomcat8Mojo.java +++ b/tomcat8-maven-plugin/src/main/java/org/apache/tomcat/maven/plugin/tomcat8/AbstractTomcat8Mojo.java @@ -77,6 +77,13 @@ protected void checkTomcatResponse( TomcatManagerResponse tomcatResponse ) messagesProvider.getMessage( "tomcatHttpStatusError", statusCode, tomcatResponse.getReasonPhrase() ) + ": " + tomcatResponse.getHttpResponseBody() ); - } + } else if(tomcatResponse.getHttpResponseBody().startsWith(messagesProvider.getMessage("tomcatHttpDeployBodyError"))) { + { + getLog().error( messagesProvider.getMessage( "tomcatHttpBodyError", + tomcatResponse.getHttpResponseBody() ) ); + throw new MojoExecutionException( + messagesProvider.getMessage( "tomcatHttpBodyError", + tomcatResponse.getHttpResponseBody() )); + } } } From e13cd3b62c0e7b3c97fc35b3328bff289fe9c342 Mon Sep 17 00:00:00 2001 From: yqiu Date: Wed, 24 May 2017 15:32:45 +0200 Subject: [PATCH 2/5] sorry, fix the } --- .../tomcat/maven/plugin/tomcat6/AbstractI18NTomcat6Mojo.java | 1 + .../apache/tomcat/maven/plugin/tomcat8/AbstractTomcat8Mojo.java | 1 + 2 files changed, 2 insertions(+) diff --git a/tomcat6-maven-plugin/src/main/java/org/apache/tomcat/maven/plugin/tomcat6/AbstractI18NTomcat6Mojo.java b/tomcat6-maven-plugin/src/main/java/org/apache/tomcat/maven/plugin/tomcat6/AbstractI18NTomcat6Mojo.java index 41b73394..8bc04182 100644 --- a/tomcat6-maven-plugin/src/main/java/org/apache/tomcat/maven/plugin/tomcat6/AbstractI18NTomcat6Mojo.java +++ b/tomcat6-maven-plugin/src/main/java/org/apache/tomcat/maven/plugin/tomcat6/AbstractI18NTomcat6Mojo.java @@ -89,3 +89,4 @@ protected void checkTomcatResponse( TomcatManagerResponse tomcatResponse ) } } } +} diff --git a/tomcat8-maven-plugin/src/main/java/org/apache/tomcat/maven/plugin/tomcat8/AbstractTomcat8Mojo.java b/tomcat8-maven-plugin/src/main/java/org/apache/tomcat/maven/plugin/tomcat8/AbstractTomcat8Mojo.java index a99cac31..e751703f 100644 --- a/tomcat8-maven-plugin/src/main/java/org/apache/tomcat/maven/plugin/tomcat8/AbstractTomcat8Mojo.java +++ b/tomcat8-maven-plugin/src/main/java/org/apache/tomcat/maven/plugin/tomcat8/AbstractTomcat8Mojo.java @@ -87,3 +87,4 @@ protected void checkTomcatResponse( TomcatManagerResponse tomcatResponse ) } } } +} From 10efcd85e8159ef6468b1f519ba429f938923d3d Mon Sep 17 00:00:00 2001 From: lperez Date: Wed, 24 May 2017 15:49:24 +0200 Subject: [PATCH 3/5] space before : --- .../tomcat/maven/common/messages/messages_fr.properties | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/common-tomcat-maven-plugin/src/main/resources/org/apache/tomcat/maven/common/messages/messages_fr.properties b/common-tomcat-maven-plugin/src/main/resources/org/apache/tomcat/maven/common/messages/messages_fr.properties index 7a74970b..6431fab1 100644 --- a/common-tomcat-maven-plugin/src/main/resources/org/apache/tomcat/maven/common/messages/messages_fr.properties +++ b/common-tomcat-maven-plugin/src/main/resources/org/apache/tomcat/maven/common/messages/messages_fr.properties @@ -106,6 +106,6 @@ UndeployMojo.undeployError = N'a pas pu retirer l'application : {0} ReloadMojo.reloadingApp = Rechargement de l'application sur {0} -tomcatHttpStatusError = Tomcat a retourn\u00E9 un code HTTP en erreur: {0}, raison: {1} +tomcatHttpStatusError = Tomcat a retourn\u00E9 un code HTTP en erreur : {0}, raison: {1} tomcatHttpDeployBodyError = ECHEC -tomcatHttpBodyError = Tomcat a retourn\u00E9 un corps HTTP en erreur: {0} \ No newline at end of file +tomcatHttpBodyError = Tomcat a retourn\u00E9 un corps HTTP en erreur : {0} \ No newline at end of file From bf249b3f411db1534cff229779a06fb2801e6ccb Mon Sep 17 00:00:00 2001 From: lperez Date: Wed, 24 May 2017 16:47:33 +0200 Subject: [PATCH 4/5] space before : --- .../apache/tomcat/maven/common/messages/messages_fr.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common-tomcat-maven-plugin/src/main/resources/org/apache/tomcat/maven/common/messages/messages_fr.properties b/common-tomcat-maven-plugin/src/main/resources/org/apache/tomcat/maven/common/messages/messages_fr.properties index 6431fab1..a44dc8c7 100644 --- a/common-tomcat-maven-plugin/src/main/resources/org/apache/tomcat/maven/common/messages/messages_fr.properties +++ b/common-tomcat-maven-plugin/src/main/resources/org/apache/tomcat/maven/common/messages/messages_fr.properties @@ -106,6 +106,6 @@ UndeployMojo.undeployError = N'a pas pu retirer l'application : {0} ReloadMojo.reloadingApp = Rechargement de l'application sur {0} -tomcatHttpStatusError = Tomcat a retourn\u00E9 un code HTTP en erreur : {0}, raison: {1} +tomcatHttpStatusError = Tomcat a retourn\u00E9 un code HTTP en erreur : {0}, raison : {1} tomcatHttpDeployBodyError = ECHEC tomcatHttpBodyError = Tomcat a retourn\u00E9 un corps HTTP en erreur : {0} \ No newline at end of file From ef71179cada846d3f276024af2a88a346769bb90 Mon Sep 17 00:00:00 2001 From: lperez Date: Wed, 24 May 2017 12:36:50 +0200 Subject: [PATCH 5/5] space before : (+3 squashed commits) Squashed commits: [10efcd8] space before : [e13cd3b] sorry, fix the } [153af9a] handle failed tomcat war deployment --- .../tomcat/maven/common/messages/messages.properties | 2 ++ .../maven/common/messages/messages_fr.properties | 4 +++- .../maven/plugin/tomcat6/AbstractI18NTomcat6Mojo.java | 10 +++++++++- .../maven/plugin/tomcat7/AbstractTomcat7Mojo.java | 8 ++++++++ .../maven/plugin/tomcat8/AbstractTomcat8Mojo.java | 10 +++++++++- 5 files changed, 31 insertions(+), 3 deletions(-) diff --git a/common-tomcat-maven-plugin/src/main/resources/org/apache/tomcat/maven/common/messages/messages.properties b/common-tomcat-maven-plugin/src/main/resources/org/apache/tomcat/maven/common/messages/messages.properties index da29fb97..2cadf6e4 100644 --- a/common-tomcat-maven-plugin/src/main/resources/org/apache/tomcat/maven/common/messages/messages.properties +++ b/common-tomcat-maven-plugin/src/main/resources/org/apache/tomcat/maven/common/messages/messages.properties @@ -109,3 +109,5 @@ ReloadMojo.reloadingApp = Reloading application at {0} # tomcatHttpStatusError = Tomcat return http status error: {0}, Reason Phrase: {1} +tomcatHttpDeployBodyError = FAIL +tomcatHttpBodyError = Tomcat return http body error: {0} diff --git a/common-tomcat-maven-plugin/src/main/resources/org/apache/tomcat/maven/common/messages/messages_fr.properties b/common-tomcat-maven-plugin/src/main/resources/org/apache/tomcat/maven/common/messages/messages_fr.properties index f180d09c..a44dc8c7 100644 --- a/common-tomcat-maven-plugin/src/main/resources/org/apache/tomcat/maven/common/messages/messages_fr.properties +++ b/common-tomcat-maven-plugin/src/main/resources/org/apache/tomcat/maven/common/messages/messages_fr.properties @@ -106,4 +106,6 @@ UndeployMojo.undeployError = N'a pas pu retirer l'application : {0} ReloadMojo.reloadingApp = Rechargement de l'application sur {0} -tomcatHttpStatusError = Tomcat a retourn\u00E9 un code HTTP en erreur: {0}, raison: {1} \ No newline at end of file +tomcatHttpStatusError = Tomcat a retourn\u00E9 un code HTTP en erreur : {0}, raison : {1} +tomcatHttpDeployBodyError = ECHEC +tomcatHttpBodyError = Tomcat a retourn\u00E9 un corps HTTP en erreur : {0} \ No newline at end of file diff --git a/tomcat6-maven-plugin/src/main/java/org/apache/tomcat/maven/plugin/tomcat6/AbstractI18NTomcat6Mojo.java b/tomcat6-maven-plugin/src/main/java/org/apache/tomcat/maven/plugin/tomcat6/AbstractI18NTomcat6Mojo.java index f53eb16c..8bc04182 100644 --- a/tomcat6-maven-plugin/src/main/java/org/apache/tomcat/maven/plugin/tomcat6/AbstractI18NTomcat6Mojo.java +++ b/tomcat6-maven-plugin/src/main/java/org/apache/tomcat/maven/plugin/tomcat6/AbstractI18NTomcat6Mojo.java @@ -79,6 +79,14 @@ protected void checkTomcatResponse( TomcatManagerResponse tomcatResponse ) messagesProvider.getMessage( "tomcatHttpStatusError", statusCode, tomcatResponse.getReasonPhrase() ) + ": " + tomcatResponse.getHttpResponseBody() ); - } + } else if(tomcatResponse.getHttpResponseBody().startsWith(messagesProvider.getMessage("tomcatHttpDeployBodyError"))) { + { + getLog().error( messagesProvider.getMessage( "tomcatHttpBodyError", + tomcatResponse.getHttpResponseBody() ) ); + throw new MojoExecutionException( + messagesProvider.getMessage( "tomcatHttpBodyError", + tomcatResponse.getHttpResponseBody() )); + } } } +} diff --git a/tomcat7-maven-plugin/src/main/java/org/apache/tomcat/maven/plugin/tomcat7/AbstractTomcat7Mojo.java b/tomcat7-maven-plugin/src/main/java/org/apache/tomcat/maven/plugin/tomcat7/AbstractTomcat7Mojo.java index ed4ff246..a9660503 100644 --- a/tomcat7-maven-plugin/src/main/java/org/apache/tomcat/maven/plugin/tomcat7/AbstractTomcat7Mojo.java +++ b/tomcat7-maven-plugin/src/main/java/org/apache/tomcat/maven/plugin/tomcat7/AbstractTomcat7Mojo.java @@ -77,6 +77,14 @@ protected void checkTomcatResponse( TomcatManagerResponse tomcatResponse ) messagesProvider.getMessage( "tomcatHttpStatusError", statusCode, tomcatResponse.getReasonPhrase() ) + ": " + tomcatResponse.getHttpResponseBody() ); + } else if(tomcatResponse.getHttpResponseBody().startsWith(messagesProvider.getMessage("tomcatHttpDeployBodyError"))) { + { + getLog().error( messagesProvider.getMessage( "tomcatHttpBodyError", + tomcatResponse.getHttpResponseBody() ) ); + throw new MojoExecutionException( + messagesProvider.getMessage( "tomcatHttpBodyError", + tomcatResponse.getHttpResponseBody() )); + } } } } diff --git a/tomcat8-maven-plugin/src/main/java/org/apache/tomcat/maven/plugin/tomcat8/AbstractTomcat8Mojo.java b/tomcat8-maven-plugin/src/main/java/org/apache/tomcat/maven/plugin/tomcat8/AbstractTomcat8Mojo.java index 74126fb1..e751703f 100644 --- a/tomcat8-maven-plugin/src/main/java/org/apache/tomcat/maven/plugin/tomcat8/AbstractTomcat8Mojo.java +++ b/tomcat8-maven-plugin/src/main/java/org/apache/tomcat/maven/plugin/tomcat8/AbstractTomcat8Mojo.java @@ -77,6 +77,14 @@ protected void checkTomcatResponse( TomcatManagerResponse tomcatResponse ) messagesProvider.getMessage( "tomcatHttpStatusError", statusCode, tomcatResponse.getReasonPhrase() ) + ": " + tomcatResponse.getHttpResponseBody() ); - } + } else if(tomcatResponse.getHttpResponseBody().startsWith(messagesProvider.getMessage("tomcatHttpDeployBodyError"))) { + { + getLog().error( messagesProvider.getMessage( "tomcatHttpBodyError", + tomcatResponse.getHttpResponseBody() ) ); + throw new MojoExecutionException( + messagesProvider.getMessage( "tomcatHttpBodyError", + tomcatResponse.getHttpResponseBody() )); + } } } +}