天道酬勤,学无止境

Tomcat deployement issue in a Maven project

I have been trying to create a simple maven web based project to be confident about maven. I have added tomcat7 plugin in my pom.xml to use it as a server. But when i started to deploy my war file to tomcat by using

tomcat7:deploy

it is throwing an error as follows,

[INFO] Deploying war to http://127.0.0.1:8080/MavenWeb  
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 13.585s
[INFO] Finished at: Wed Jan 30 16:03:06 IST 2013
[INFO] Final Memory: 9M/24M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.tomcat.maven:tomcat7-maven-plugin:2.0:deploy  (default-cli) on project MavenWeb: Cannot invoke Tomcat manager: Connection to http://127.0.0.1:8080 refused: Connection refused -> [Help 1]

My plugin section in pom.xml is as follows.

<plugin>
    <groupId>org.apache.tomcat.maven</groupId>
    <artifactId>tomcat7-maven-plugin</artifactId>
    <version>2.0</version>
    <configuration>
       <url>http://127.0.0.1:8080/manager/html</url>
       <warFile>/home/shebin/Maven Folder/MavenWeb/target/MavenWeb.war</warFile>
   <server>TomcatServer</server>
       <path>/MavenWeb</path>
   <username>tomcat</username>
       <password>tomcat</password>
    </configuration>
</plugin>

.m2/settings.xml and /home/shebin/apache-maven-3.0.4/conf/settings.xml

<server>
        <id>TomcatServer</id>
        <username>tomcat</username>
        <password>tomcat</password>
</server>

/home/shebin/apache-tomcat-7.0.35/conf/tomcat-users.xml

<role rolename="manager-gui"/>
<user username="tomcat" password="tomcat" roles="manager-gui"/>

I have came through various solution and nothing is working in my way. My Maven version is 3.0.4 and using tomcat7 plugin.

评论

The url in configuration of maven plugin should be <url>http://127.0.0.1:8080/manager/text</url> which corresponds to the role manager-script.

Also, it is worth noted that after changing the roles in {TOMCAT_HOME}/conf/tomcat-users.xml, you have to restart the tomcat server for reloading the configuration. I know this is a common sense, but my experience told me that some of you may really stuck at here.

This error message

[ERROR] Failed to execute goal org.apache.tomcat.maven:tomcat7-maven-plugin:2.0:deploy  (default-cli) on project MavenWeb: Cannot invoke Tomcat manager: Connection to http://127.0.0.1:8080 refused: Connection refused -> [Help 1]

insinuates this is authentication related. Try and change this

<role rolename="manager-gui"/>
<user username="tomcat" password="tomcat" roles="manager-gui"/>

to

<role rolename="manager-script"/>
<user username="tomcat" password="tomcat" roles="manager-script"/>

Access from the maven plugin will not happen over the browser based admin client :)

I ran into the same issue. You'll need to add an extra role to the mix: manager-jmx. So your tomcat-users.xml file should have.

<user username="tomcat" password="tomcat" roles="manager-script, manager-jmx"/>

I got this working too thanks to points in this post.. Things I got stuck on were: The POM file - you need a slash on the beginning of the path (or it tried to install it under /manager/ and fails):

<plugin>
    <groupId>org.apache.tomcat.maven</groupId>
    <artifactId>tomcat7-maven-plugin</artifactId>
    <version>2.2</version>
    <configuration>
        <url>http://10.54.17.35:8080/manager/text</url>
        <server>LoginForTomcat</server>
        <path>/displayService</path>
    </configuration>
</plugin>

provide server credentials in ~/.m2/settings.xml:

<servers>
    <server>
        <id>LoginForTomcat</id>
        <username>figgy</username>
        <password>passw0rd</password>
    </server>
</servers>

On the tomcat server, you need to define manager-script and manager-jmx:

  <role rolename="manager-gui"/>
  <role rolename="manager-script"/>
  <role rolename="manager-jmx"/>
  <user username="figgy" password="passw0rd" roles="manager-gui,manager-script,manager-jmx"/>

Looking over this everything here is in the posts above, posting this to clarify things.

受限制的 HTML

  • 允许的HTML标签:<a href hreflang> <em> <strong> <cite> <blockquote cite> <code> <ul type> <ol start type> <li> <dl> <dt> <dd> <h2 id> <h3 id> <h4 id> <h5 id> <h6 id>
  • 自动断行和分段。
  • 网页和电子邮件地址自动转换为链接。

相关推荐
  • 获取 maven 对 Tomcat 进行并行部署(Get maven to do parallel deployments to Tomcat)
    问题 我找不到让 Maven 使用 Tomcat 7 的并行部署进行 Tomcat 7 部署的标准化方法: http://tomcat.apache.org/tomcat-7.0-doc/config/context.html#Parallel_deployment 有没有可靠的方法来做到这一点? 也许总是保持应用程序的两个版本上线? 回答1 你可以在这个用例中使用 tomcat7-maven-plugin : <plugin> <groupId>org.apache.tomcat.maven</groupId> <artifactId>tomcat7-maven-plugin</artifactId> <version>2.2</version> <configuration> <path>/WebappName##${maven.build.timestamp}</path> <url>http://localhost:8080/manager/text</url> <username>tomcat</username> <password>tomcat</password> <update>true</update> </configuration> </plugin> 如您所见,版本是在path元素中指定的,基于此示例中的构建时间戳。 当然,如果您不想让所有旧版本继续运行
  • java.lang.ClassNotFoundException:org.springframework.web.context.ContextLoaderListener(java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener)
    问题 我在构建路径中包括了这些: 所有春季图书馆 Apache Tomcat 7.0库 该项目在启动过程中仍然失败: SEVERE: Error configuring application listener of class org.springframework.web.context.ContextLoaderListener java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1676) at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1521) at org.apache.catalina.core.DefaultInstanceManager.loadClass(DefaultInstanceManager.java:415) at org.apache.catalina.core.DefaultInstanceManager.loadClassMaybePrivileged
  • tomcat:deploy:“无法调用 Tomcat 管理器:连接被拒绝”(tomcat:deploy: “Cannot invoke Tomcat manager: Connection refused”)
    问题 我尝试使用 Maven 将我的应用程序部署到 Tomcat,我找到了这个示例。 这是我的 pom.xml 的片段: <!-- Maven Tomcat Plugin --> <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>tomcat-maven-plugin</artifactId> <configuration> <url>http://127.0.0.1:8080/</url> <server>TomcatServer</server> </configuration> </plugin> <!-- Maven compiler plugin --> <plugin> <artifactId>maven-compiler-plugin</artifactId> <configuration> <source>1.6</source> <target>1.6</target> </configuration> </plugin> 当我运行tomcat:deploy我收到此错误: Cannot invoke Tomcat manager: Connection refused 。 这是完整的堆栈跟踪: [ERROR] Failed to execute goal org.codehaus.mojo
  • Maven 不会部署到 tomcat; 给出“405”错误(Maven won't deploy to tomcat; gives '405' error)
    问题 我正在尝试将一个简单的 JSF 应用程序部署到本地机器上的 Tomcat 8 服务器上。 当我运行 mvn tomcat:deploy 时,我得到以下反馈: C:\_workspace\portfolio>mvn tomcat:deploy [INFO] Scanning for projects... [WARNING] [WARNING] Some problems were encountered while building the effective model for com.italic:portfolio:war:0.0.1-SNAPSHOT [WARNING] 'build.plugins.plugin.version' for org.codehaus.mojo:tomcat-maven-plugin is missing. @ line 38, column 12 [WARNING] [WARNING] It is highly recommended to fix these problems because they threaten the stability of your build. [WARNING] [WARNING] For this reason, future Maven versions might no longer
  • Deploy Maven Project using Eclipse and Tomcat
    I developed a very simple web service using eclipse for edit the code and tomcat 8.5 for deploy the web service. The Name of maven project is PruebaMaven and I can deploy that with success getting the classic hello world. My problem is that when I want to access an a method associate to localhost:8080/PruebaMaven/Services/Login/Validate, the tomcat response is HTTP 404 - Not found The method that I want to access is a POST type, so I'm expecting that the response of the tomcat server be a HTTP 405. I dont know if my thinking is correct or im wrong and the response of tomcat is apropiate. In
  • 使用 Eclipse 和 Tomcat 部署 Maven 项目(Deploy Maven Project using Eclipse and Tomcat)
    问题 我开发了一个非常简单的 web 服务,使用 eclipse 编辑代码和 tomcat 8.5 部署 web 服务。 maven 项目的名称是 PruebaMaven,我可以成功部署它并获得经典的 hello world。 我的问题是,当我想访问一个关联到localhost:8080/PruebaMaven/Services/Login/Validate ,tomcat 响应是HTTP 404 - Not found 我想访问的方法是 POST 类型,所以我期望 tomcat 服务器的响应是HTTP 405 。 我不知道我的想法是正确的还是错误的,tomcat 的响应是适当的。 如果我的想法是正确的,有人知道我的问题在哪里吗?
  • Eclipse maven-enabled web app references workspace projects, but those are not deployed when running Tomcat server
    I have a web application (Eclipse's Dynamic Web App) which uses Maven (m2e-wtp) for the build and dependencies management. This web app's POM references a few other projects in my workspace, which happen to be eclipse plugins built with maven as well (built using Tycho), and also other third party libraries which come from Maven's repository. Everything works fine when I run maven from the CLI. All dependencies are included in the WEB-INF/lib directory just as expected. The problem is when I attempt to run the project using Eclipse. I run the app in a configured Tomcat server inside Eclipse
  • 启用了Eclipse maven的Web应用程序引用了工作空间项目,但是在运行Tomcat服务器时未部署这些项目(Eclipse maven-enabled web app references workspace projects, but those are not deployed when running Tomcat server)
    问题 我有一个Web应用程序(Eclipse的Dynamic Web App),它使用Maven(m2e-wtp)进行构建和依赖关系管理。 这个Web应用程序的POM引用了我工作区中的其他一些项目,这些项目恰好是用maven构建的eclipse插件(使用Tycho构建),以及来自Maven存储库的其他第三方库。 当我从CLI运行maven时,一切正常。 正如预期的那样,所有依赖项都包含在WEB-INF / lib目录中。 问题是当我尝试使用Eclipse运行项目时。 我在Eclipse内已配置的Tomcat服务器中运行该应用程序,但工作区中引用的项目未添加到已部署的war中。 我尝试将它们添加到Deployment Assembly(在项目首选项下),并且效果很好,但是每次更新Maven配置时,这些设置都会被m2e抹掉。 我在几个地方读到,我们不应该在此处手动添加条目,因为所有依赖项都应由m2e管理... 问题是:当我从Eclipse运行它时,如何使Eclipse将工作区项目依赖项添加到Web应用程序的WEB-INF / lib中? 我正在使用Eclipse J2EE 4.3.1(Kepler SR1)。 我还尝试右键单击该项目,然后选择“导出”->“ WAR文件”,但是导出的WAR文件也不包含所引用的工作区项目。 我假设问题同时影响了这两种情况。 这是非常烦人的问题
  • 原始服务器找不到目标资源的当前表示,或不愿意透露该资源的存在。 在部署到tomcat(The origin server did not find a current representation for the target resource or is not willing to disclose that one exists. on deploying to tomcat)
    问题 我已经在Eclipse IDE中使用Spring构建了一个应用程序。 当我从Eclipse IDE启动项目时,一切都很好,但是当我将maven项目打包为war文件并部署到单独的tomcat时,我遇到了这个问题 The origin server did not find a current representation for the target resource or is not willing to disclose that one exists. 这是我的xml文件中的配置代码段 <!-- View Resolver --> <beans:bean class="org.springframework.web.servlet.view.InternalResourceViewResolver"> <beans:property name="prefix" value="/WEB-INF/pages/" /> <beans:property name="suffix" value=".jsp" /> </beans:bean> 我正在尝试访问此控制器 @RequestMapping(value = {"/welcome", "/"}) public String defaultPage() { return "Web Service data successfuly
  • 如何使用maven tomcat插件将带有自动buildnumber的war部署到tomcat(How to deploy war with automatic buildnumber to tomcat using maven tomcat plugin)
    问题 我使用 maven3 作为构建工具并有一些插件。 这是我的 Maven 设置: <build> <finalName>${project.artifactId}-${project.version}-${buildNumber}</finalName> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-war-plugin</artifactId> <version>2.4</version> <configuration> <packagingExcludes>WEB-INF/lib/*.jar</packagingExcludes> <archive> <manifest> <addDefaultImplementationEntries>true</addDefaultImplementationEntries> </manifest> <manifestEntries> <Implementation-Build>${buildNumber}</Implementation-Build> </manifestEntries> </archive> </configuration> </plugin> <!-- Build number auto
  • 当我尝试将应用程序部署到tomcat7服务器时出错(Error when I try deploy application to tomcat7 server)
    问题 我正在尝试通过Eclipse Luna将Web应用程序部署到tomcat7,但出现此错误: Uploading: http://localhost:8080/manager/text/deploy?path=%2Floja [INFO] I/O exception (java.net.SocketException) caught when processing request: Connection reset [INFO] Retrying request Uploading: http://localhost:8080/manager/text/deploy?path=%2Floja [INFO] I/O exception (java.net.SocketException) caught when processing request: Connection reset [INFO] Retrying request Uploading: http://localhost:8080/manager/text/deploy?path=%2Floja [INFO] I/O exception (java.net.SocketException) caught when processing request: Connection reset [INFO]
  • Spring + Hibernate + Angular + Maven + Tomcat 项目文件夹结构问题(Spring + Hibernate + Angular + Maven + Tomcat Project folder structure issues)
    问题 好的,所以我一整天都在努力解决这个问题。 我的老板给我分配了一个新任务:拿这个模板:https://github.com/DavidKk/ngAdmin,弄清楚 AngularJS 是如何工作的,弄清楚 Spring 是如何工作的,Hibernate 是如何工作的,Maven 是如何进行项目构建的,测试等,在 MySQL 数据库上的模板中实现一个基本的 CRUD 示例,部署在 Tomcat 上。 所以,首先,这是一次性的很多东西,我从未使用过的东西,也许是 Hibernate 和 JPA,他希望在本周末之前整理所有这些东西,当我们将与客户多谈谈项目,这样我们就可以告诉他我们将在开发过程中采取什么方法。 看了一下Spring,用Spring Initializr:https://start.spring.io/做了一个基础项目,用jar命令工具制作了一个WAR文件,部署在tomcat上,成功了。 我已经使用了这两个,因为 IntelliJ 社区没有实现这些,除非您为 Ultimate 版付费。 我看了一下这个 CRUD 示例:http://www.concretepage.com/spring-4/spring-mvc-4-rest-angularjs-hibernate-4-integration-crud-tutorial-with-ngresource-example
  • 启动 Tomcat 时出现 ClassNotFoundException DispatcherServlet(Maven 依赖项未复制到 wtpwebapps)(ClassNotFoundException DispatcherServlet when launching Tomcat (Maven dependencies not copied to wtpwebapps))
    问题 我遇到过这个问题几次,只是偶然发现了一个(半)可靠的解决方案,所以我想我会把它贴在这里,以防它对其他人有帮助,或者如果我忘记了它,也问问是否有人知道根本原因是什么以及为什么我的修复有效。 问题 - 我有一个 spring 3 webapp,我想使用 Eclipse 中的 Run on Server 选项在 Tomcat 7 服务器上运行。 对于某些项目,这只是有效,但有些项目似乎处于损坏状态,每次服务器启动时,我都找不到一个类:org.springframework.web.servlet.DispatcherServlet。 经过一番调查,我发现该项目的 maven 依赖项尚未复制到${PROJECT_LOCATION}/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/ WEB-INF/lib 我尝试了很多事情,最后才注意到该项目在问题面板中出现了警告: Classpath entry org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER will not be exported or published. Runtime ClassNotFoundExceptions may result. 也许我应该早点注意到这一点。 无论如何,选择它并执行
  • Spring + Hibernate + Angular + Maven + Tomcat Project folder structure issues
    Okay, so I have been trying all day to sort this out. My boss has assigned me a new task: Take this template: https://github.com/DavidKk/ngAdmin , figure out how AngularJS works, figure out how Spring works, how does Hibernate work, how does Maven work for project builds, tests etc, implement a basic CRUD example inside that template on a MySQL database, deploy on Tomcat. So, first, this is a lot of stuff all at once, stuff that I have not ever worked with, maybe with Hibernate and a bit with JPA, and he wants all this stuff sorted out by the end of the week, when we will talk more about the
  • How to deploy war with automatic buildnumber to tomcat using maven tomcat plugin
    I am using maven3 as build tool and have some plugins. Here is my maven setting: <build> <finalName>${project.artifactId}-${project.version}-${buildNumber}</finalName> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-war-plugin</artifactId> <version>2.4</version> <configuration> <packagingExcludes>WEB-INF/lib/*.jar</packagingExcludes> <archive> <manifest> <addDefaultImplementationEntries>true</addDefaultImplementationEntries> </manifest> <manifestEntries> <Implementation-Build>${buildNumber}</Implementation-Build> </manifestEntries> </archive> </configuration> <
  • Tomcat 7.0版仅支持J2EE 1.2、1.3、1.4和Java EE 5和6 Web模块(Tomcat version 7.0 only supports J2EE 1.2, 1.3, 1.4, and Java EE 5 and 6 Web modules)
    问题 我试图从Eclipse J2EE角度使用Tomcat 7部署一个非常简单的HTTPServlet项目。 我收到错误消息:“ Tomcat 7.0版仅支持J2EE 1.2、1.3、1.4和Java EE 5和6 Web模块”。 我已经尝试按此处提到的文件修改org.eclipse.wst.common.project.facet.core.xml,但这似乎无法解决问题。 我可以直接使用file-> export->。war将其部署到已安装的tomcat服务器上。 有任何想法吗? 回答1 Tomcat不是兼容Java EE的应用程序服务器,因此这里没有现成的EJB或CDI。 相反,请使用构建在tomcat之上的JBoss Wildfly或TomEE。 或者,更改为完全不同的Java EE实现,例如GlassFish。 如果您直接部署到Tomcat中,则可能是另一种选择。 缺省情况下,Eclipse部署在其他文件夹上,并使用某种绕过方式将其部署在Tomcat上。 按着这些次序: 在您的Eclipse中,转到“服务器”视图(如果在IDE中不可见,请转到“窗口/显示视图/服务器”),它将显示您的tomcat服务器(和其他服务器),双击它。 在“ Tomcat概述”窗口中,检查“服务器位置”面板,将其展开并检查Webapp的部署位置。 如果选择的选项是“使用Tomcat安装”
  • 如何将带有Maven的WAR部署到Tomcat?(How to deploy WAR with Maven to Tomcat?)
    问题 我将Maven与Eclipse结合使用。 是否可以构建项目,然后将构建的WAR文件部署到Tomcat服务器? 我使用Windows。 我可以构建WAR文件,也可以手动将其部署在服务器上。 但是我想在构建操作后自动部署WAR文件,但是它不起作用。 我是Maven的新手。 我应该在运行配置中设置一些内容吗? 我设定的目标要install值。 pom.xml <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>HelloWorld</groupId> <artifactId>HelloWorld</artifactId> <version>0.0.1-SNAPSHOT</version> <packaging>war</packaging> <name>HelloWorld</name> <properties> <spring.version
  • 不能做 mvn tomcat:deploy 因为 http 响应 405(cant do mvn tomcat:deploy because of http response 405)
    问题 我正在运行 Tomcat 7 作为 Windows 服务。 我想在我的项目根目录中执行 mvn:tomcat deploy 。 但是一直出现这个错误,你能帮我解决这个问题吗? [INFO] Deploying war to http://localhost:8080/opendata [INFO] ------------------------------------------------------------------------ [INFO] BUILD FAILURE [INFO] ------------------------------------------------------------------------ [INFO] Total time: 2.493s [INFO] Finished at: Sun Jan 20 18:48:30 CET 2013 [INFO] Final Memory: 15M/39M [INFO] ------------------------------------------------------------------------ [ERROR] Failed to execute goal org.codehaus.mojo:tomcat-maven-plugin:1.1:deploy (default
  • 尝试将 maven 项目部署到 tomcat 时出现套接字写入错误(Socket write error when I try to deploy maven project to tomcat)
    问题 我有一个 Maven 项目,其中包括 4 个模块:新闻管理、新闻通用、新闻管理和新闻客户端。 新闻管理模块是一个父模块。 我输入mvn tomcat7.deploy -Dmaven.test.skip=true结果是: [INFO] Scanning for projects... [INFO] ------------------------------------------------------------------------ [INFO] Reactor Build Order: [INFO] [INFO] news-management [INFO] news-common [INFO] news-admin [INFO] news-client [INFO] [INFO] ------------------------------------------------------------------------ [INFO] Building news-management 1.0 [INFO] ------------------------------------------------------------------------ [INFO] [INFO] --- maven-install-plugin:2.4:install
  • Maven Tomcat Deploy Failed
    I want to deploy my java webapp into my tomcat server using tomcat:deploy goal. But I am stucked for few days to deal with this. POM.xml <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>tomcat-maven-plugin</artifactId> <configuration> <url>http://127.0.0.1:8080/manager/html</url> <server>mytomcat</server> <path>/test</path> </configuration> </plugin> settings.xml (user_home.m2\settings.xml - I created settings.xml manually) <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