Cannot invoke tomcat error reportmanager: Error writing to server

1727人阅读
转自:/html/94/177.html
在Maven与Tomcat配合部署过程中,最常见的错误有三种,折腾了半天,终于找到三种错误产生的原因,以及相应的完美解决办法
1.Connection refused错误
报错信息如下:
[ERROR]Failed to execute goal org.apache.tomcat.maven: tomcat7-maven-plugin: 2.0- SNAPSHOT: deploy (default-cli) on project helloworld: Cannot invoke Tomcat manager: Connection refused: connect -& [Help 1]
原因:未启动Tomcat服务器
解决办法:先启动Tomcat服务器再选择Run
2. 401错误
报错信息如下:
[ERROR] Failed to execute goal org.apache.tomcat.maven:tomcat7-maven-plugin: 2.0-SNAPSHOT:deploy (default-cli) on project helloworld: Cannot invoke Tomcat manager: Server returned HTTP response code: 401 for URL: http://localhost:8080/manager/text/deploy?path=%2Fhelloworld
-& [Help 1]
原因:权限问题
解决办法在$CATALINA_BASE/conf/tomcat-users.xml,
如D:\apache-tomcat-7.0.34\conf\tomcat-users.xml文件中添加权限
&role rolename=”manager”/&
&user username=”admin” password=”admin” roles=”manager”/&
修改pom.xml文件,在&configuration&& &/configuration&中添加
&username&admin&/username&& &password&admin&/password&
报错信息如下:
[ERROR] Failed to execute goal org.apache.tomcat.maven:tomcat7-maven-plugin: 2.0-SNAPSHOT:deploy (default-cli) on project helloworld: Cannot invoke Tomcat manager: Server returned HTTP response code: 403 for URL: http://localhost:8080/manager/html/deploy?path=%2Fhelloworld
-& [Help 1]
原因:产生该问题有可能因为两个原因,具体参见解决办法
解决办法:
1)如果使用的是Tomcat 7,需要修改pom.xml中部署的url地址,将&url&http://localhost:8080/manager&/url&改&url&http://localhost:8080/manager/text&/url&
2)给tomcat用户权限分配上,需要同时具备manager-gui和manager-script权限,我在遇到该问题时,就是忘了分配manager-script权限。
正确的conf/tomcat-users.xml配置应为:
&tomcat-users&
&role rolename=&manager-gui&/&
&role rolename=&manager-script&/&
&user username=&admin” password=&admin& roles=&manager-gui, manager-script&/&
&/tomcat-users&
相关资料链接:
/blog/1561664
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
访问:94934次
积分:1552
积分:1552
排名:第12490名
原创:45篇
转载:171篇
(9)(9)(5)(3)(6)(10)(4)(13)(4)(43)(12)(11)(83)(4)1、环境如下
  eclipse、apache-maven-3.0.5、apache-tomcat-7.0.39
2、配置如下
  apache-tomcat-7.0.39配置C:\Program Files\apache-tomcat-7.0.39\conf\tomcat-users.xml,因为tomcat7默认情况下没有配置manager访问权限,所以这里需要在tomcat-users.xml加入用户以及权限
&tomcat-users&
&role rolename="admin-gui"/&
&role rolename="admin-script"/&
&role rolename="manager-gui"/&
&role rolename="manager-script"/&
&role rolename="manager-jmx"/&
&role rolename="manager-status"/&
&user username="admin" password="admin" roles="manager-gui,manager-script,manager-jmx,manager-status,admin-script,admin-gui"/&
&/tomcat-users&
  apache-maven-3.0.5配置C:\Program Files\apache-maven-3.0.5\conf\settings.xml,为了让maven可以访问tomcat的权限,所以需要把如上创建的用户添加到settings.xml中,如下
&!-- 配置tomcat-/manager/text 访问权限 --&
&id&tomcat&/id&
&username&admin&/username&
&password&admin&/password&
&/servers&
  工程目录下的pom.xml文件,加入build,并配置tomcat7的maven插件,如下配置
&finalName&myApp&/finalName&
&!-- directory缺省情况下指向target --&
&!--&directory&${basedir}/target&/directory&--&
&groupId&org.apache.tomcat.maven&/groupId&
&artifactId&tomcat7-maven-plugin&/artifactId&
&version&2.2&/version&
&configuration&
&url&http://localhost:8080/manager/text&/url&
&!-- server、username、password对应maven的setting下的配置 --&
&server&tomcat&/server&
&username&admin&/username&
&password&admin&/password&
&path&/${project.build.finalName}&/path&
&!-- war文件路径缺省情况下指向target --&
&!--&warFile&${basedir}/target/${project.build.finalName}.war&/warFile&--&
&/configuration&
&/plugins&
  ${project.build.finalName}这个是根据xml的路径来标记的
3、命令部署
  在部署之前,必须先启动tomcat7服务,C:\Program Files\apache-tomcat-7.0.39\bin\startup.bat
  找到要部署的工程文件根目录下,执行如下maven命令
  & mvn clean:install & & & & &   //clean是清理输出文件,install编译打包,在每次打包之前必须执行clean,才能保证发布为最新文件
  & mvn tomcat7:redeploy &  //第一次发布&tomcat7:deploy,再次发布&tomcat7:redeploy
  Cannot invoke Tomcat manager: Server returned HTTP response code: 403 for URL: http://localhost:8080/manager/deploy?path=%2FmyApp&war=
  如上问题,有如下两个原因:
  A、由于maven没有权限访问http://localhost:8080/manager/text,所以需要在apache-tomcat下的tomcat-users.xml增加用户权限,并配置于maven的setting文件中
  B、由于maven-tomcat插件问题,通过http://search.maven.org/搜索tomcat-maven-plugin,发现最新版本之后,最后执行& mvn tomcat:redeploy,一直都会显示上面这个报错,这里如果是tomcat7,建议直接通过http://search.maven.org/搜索tomcat7-maven-plugin插件,执行& mvn tomcat7:redeploy,这样就部署成功了;如果tomcat6就直接通过http://search.maven.org/搜索tomcat6-maven-plugin
  所以这里需要注意tomcat7-maven-plugin插件的引入,正确引入将解决以上问题
  &groupId&org.apache.tomcat.maven&/groupId&
&artifactId&tomcat7-maven-plugin&/artifactId&
&version&2.2&/version&  & &mvn tomcat7:redeploy  即可完成部署
阅读(...) 评论()带你认识更牛的人下载即送20张免费照片冲印
扫码下载App
温馨提示!由于新浪微博认证机制调整,您的新浪微博帐号绑定已过期,请重新绑定!&&|&&
LOFTER精选
网易考拉推荐
&id&test&/id&
&username&tomcat&/username&
&password&tomcat&/password&
其中id的test和1中的server保持一致,username和password和3中的用户名密码一致3、确定tomcat的具有写权限,配置tomcat的tomcat-users.xml
&role rolename="tomcat"/&
&role rolename="role1"/&
&role rolename="manager-gui"/&
&role rolename="manager"/&
&role rolename="admin-gui"/&
&role rolename="manager-script"/&
&user password="tomcat" roles="tomcat,role1" username="both"/&
&user password="tomcat" roles="role1" username="role1"/&
&user password="tomcat" roles="manager-gui,manager,admin-gui,manager-script" username="tomcat"/&4、eclipse中配置部署&部署时出现的问题:1、web.xml which will be ignored&[WARNING]
Warning: selected war files include a WEB-INF/web.xml which will be
ignored (webxml attribute is missing from war task, or ignoreWebxml
attribute is specified as 'true') &&
在使用Maven 编译项目的时候会出现 &
[WARNING] Warning: selected war files include a WEB-INF/web.xml which will be ignored &
解决方法: &pom.xml增加&plugin&
&groupId&org.apache.maven.plugins&/groupId&
&artifactId&maven-war-plugin&/artifactId&
&version&2.1.1&/version&
&configuration&
&packagingExcludes&WEB-INF/web.xml&/packagingExcludes&
&/configuration&
&/plugin& 2、内存溢出[ERROR] Java heap space -& [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] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/OutOfMemoryError解决方法:调整java的堆大小的值。a、在maven中设置Windows环境中 找到文件%M2_HOME%\bin\mvn.bat,这就是启动Maven的脚本文件,在该文件中你能看到有一行注释为:& @REM set MAVEN_OPTS=-Xdebug -Xnoagent -piler=NONE...它的意思是你可以设置一些Maven参数,我们就在注释下面加入一行: set MAVEN_OPTS= -Xms128m -Xmx512m之后,当你运行Maven命令如 mvn -version 的时候,你会看到如下的输出:E:\test&mvn -versionE:\test&set MAVEN_OPTS= -Xms128m -Xmx512mMaven version: 2.0.9Java version: 1.6.0_07OS name: "windows 2003" version: "5.2" arch: "x86" Family: "windows"我们看到,配置的Maven选项生效了,b、m2eclipse中类似以上的方法都会失效,所幸m2eclipse提供了配置点。步骤如下:项目上右击 -& Run As -& Run Configurations -& Maven Build 上右击 -& New这时会看到一个maven运行配置对话框,这里面其它的配置我不多解释了,为了解决内存溢出的问题,我们可以选择第二个TAB: JRE,然后在VM arguments中输入配置如:-Xms128m -Xmx512m。3、403错误maven&403&No&server&username&specified&-&using&default&&Cannot&invoke&Tomcat&manager:&Server&rened&HTTP&response&code:&403&for&URL&[ERROR]&Failed&to&execute&goal&org.codehaus.mojo:tomcat-maven-plugin:1.1:deploy(default-cli)&on&project&my_struts:&Cannot&invoke&Tomcat&manager:&Server&returned&HTTP&response&code:&403&for&URL:&http://localhost:8080/manager/deploy?path=%2Fframework&war=INFO]&Deploying&war&to&http://localhost:8080/report[DEBUG]&No&server&username&specified&-&using&default解决方法:这个问题是因为你的tomcat里面没有写权限。见步骤3中tomcat-user.xml的配置4、 Application already exists这是因为已经存在同名的war包。[ERROR] Failed to execute goal org.codehaus.mojo:tomcat-maven-plugin:1.1:deploy (default-cli) on project componentlibrary: Cannot invoke Tomcat manager: FAIL - Application already exists at path /comlib -& [Help 1]org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.codehaus.mojo:tomcat-maven-plugin:1.1:deploy (default-cli) on project componentlibrary: Cannot invoke Tomcat manager: FAIL - Application already exists at path /comlib at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:217) at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153) at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145) at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84) at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59) at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183) at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161) at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:320)解决方法:a、更换&path&/comlib&/path&
中的路径b、增加&update&true&/update&
&groupId&org.apache.maven.plugins&/groupId&&
&artifactId&maven-war-plugin&/artifactId&&
&version&2.1.1&/version&&
&configuration&&
&packagingExcludes&WEB-INF/web.xml&/packagingExcludes&&
&/configuration&&&/plugin&&
阅读(1008)|
用微信&&“扫一扫”
将文章分享到朋友圈。
用易信&&“扫一扫”
将文章分享到朋友圈。
历史上的今天
在LOFTER的更多文章
loftPermalink:'',
id:'fks_081064',
blogTitle:'Maven远程部署tomcat7下',
blogAbstract:'1、在项目的pom.xml中增加\n&plugin&
\t&groupId&org.codehaus.mojo&/groupId&
\t&artifactId&tomcat-maven-plugin&/artifactId&
\t&configuration&
\t\t&url&http://192.168.9.32:8080/manager/text&/url&
\t\t&server&test&/server&
\t\t&update&true&/update&
\t\t&path&/comlib&/path&
\t&/configuration&
&/plugin& 2、在maven的配置文件settings.xml中增加',
blogTag:'',
blogUrl:'blog/static/',
isPublished:1,
istop:false,
modifyTime:7,
publishTime:6,
permalink:'blog/static/',
commentCount:0,
mainCommentCount:0,
recommendCount:0,
bsrk:-100,
publisherId:0,
recomBlogHome:false,
currentRecomBlog:false,
attachmentsFileIds:[],
groupInfo:{},
friendstatus:'none',
followstatus:'unFollow',
pubSucc:'',
visitorProvince:'',
visitorCity:'',
visitorNewUser:false,
postAddInfo:{},
mset:'000',
remindgoodnightblog:false,
isBlackVisitor:false,
isShowYodaoAd:false,
hostIntro:'',
hmcon:'1',
selfRecomBlogCount:'0',
lofter_single:''
{list a as x}
{if x.moveFrom=='wap'}
{elseif x.moveFrom=='iphone'}
{elseif x.moveFrom=='android'}
{elseif x.moveFrom=='mobile'}
${a.selfIntro|escape}{if great260}${suplement}{/if}
{list a as x}
推荐过这篇日志的人:
{list a as x}
{if !!b&&b.length>0}
他们还推荐了:
{list b as y}
转载记录:
{list d as x}
{list a as x}
{list a as x}
{list a as x}
{list a as x}
{if x_index>4}{break}{/if}
${fn2(x.publishTime,'yyyy-MM-dd HH:mm:ss')}
{list a as x}
{if !!(blogDetail.preBlogPermalink)}
{if !!(blogDetail.nextBlogPermalink)}
{list a as x}
{if defined('newslist')&&newslist.length>0}
{list newslist as x}
{if x_index>7}{break}{/if}
{list a as x}
{var first_option =}
{list x.voteDetailList as voteToOption}
{if voteToOption==1}
{if first_option==false},{/if}&&“${b[voteToOption_index]}”&&
{if (x.role!="-1") },“我是${c[x.role]}”&&{/if}
&&&&&&&&${fn1(x.voteTime)}
{if x.userName==''}{/if}
网易公司版权所有&&
{list x.l as y}
{if defined('wl')}
{list wl as x}{/list}当前位置: >
> Eclipse支配maven工程到tomcat服务器
Eclipse支配maven工程到tomcat服务器
sasasasa & at
Eclipse部署maven工程到tomcat服务器
  现有工程my_struts,它是通过maven archetype生成的项目框架。把Maven工程项目发布到tomcat服务器,需要配置tomcat插件,如在pom.xml中添加如下内容:&plugin&&groupId&org.codehaus.mojo&/groupId&&artifactId&tomcat-maven-plugin&/artifactId&&version&1.1&/version&&configuration&
&/configuration&&/plugin&
  选择pom.xml文件,单击右键,选择-,在打开的窗口中的Goals输入tomcat:deploy,然后,此时如果你尚未启动tomcat服务器,将会报错,如下所示:[ERROR] Failed to execute goal org.codehaus.mojo:tomcat-maven-plugin:1.1:exploded (default-cli) on project my_struts: Cannot invoke Tomcat manager: Connection refused: connect -& [Help 1]
  先启动tomcat服务器,再选择 -,此时会报另外一个错误:[ERROR] Failed to execute goal org.codehaus.mojo:tomcat-maven-plugin:1.1:deploy(default-cli) on project my_struts: Cannot invoke Tomcat manager: Server returned HTTP response code: 401 for URL: http://localhost:8080/manager/deploy path=%2Fmy_struts&war= -& [Help 1]401:是权限问题。
  解决401的问题:在$CATALINA_BASE/conf/tomcat-users.xml,如D:\apache-tomcat-6.0.24\conf\tomcat-users.xml文件中添加权限&role rolename=”manager”/&&user username=”ricki” password=”cheung” roles=”manager”/&修改pom.xml文件,在&configuration&
&/configuration&中添加&username&ricki&/username&
&password&cheung&/password&再次 -就可以在D:\apache-tomcat-6.0.24\webapps看到my_struts工程和my_struts.war包了。
本问题标题:
本问题地址:
温馨提示:本问答中心的任何言论仅代表发言者个人的观点,与希赛网立场无关。请对您的言论负责,遵守中华人民共和国有关法律、法规。如果您的言论违反希赛网问答中心的规则,将会被删除。
暂无合适的专家
&&&&&&&&&&&&&&&
希赛网 版权所有 & &&&&湘教QS2-164&&增值电信业务经营许可证湘B2-maven自动部署war包到tomcat
- ITeye技术网站
博客分类:
在tomcat安装目录下找到tomcat-users.xml文件。该文件路径为【tomcat安装根目录】 /conf/
修改文件内容,增加下列内容:
&role rolename="manager"/&
&user username="tomcat" password="123456" roles="manager"/&
&role rolename="manager"/&
&user username="tomcat" password="123456" roles="manager"/&
在你的项目的pom.xml文件中,增加下列&plugin&&/plugin&中内容:
。。。。。
。。。。。
&groupId&org.codehaus.mojo&/groupId&
&artifactId&tomcat-maven-plugin&/artifactId&
&configuration&
&url&http:
&username&tomcat&/username&
&password&123456&/password&
&path&/${finalName}&/path&
&/configuration&
&/plugins&
。。。。。
。。。。。
&groupId&org.codehaus.mojo&/groupId&
&artifactId&tomcat-maven-plugin&/artifactId&
&configuration&
&url&http://localhost:8080/manager&/url&
&username&tomcat&/username&
&password&123456&/password&
&path&/${finalName}&/path&
&/configuration&
&/plugins&
其中username和password就是tomcat中配置的username和password。
当然在pom.xml的&properties&标签中,还需要定义war包的名字。假如只写成&path&/&/path&,则部署的war包名字为ROOT.war。
在pom.xml的&properties&标签中,定义war包名字内容如下:
&properties&
&finalName&SSHMJ-FRANK&/finalName&
&/properties&
&properties&
&finalName&SSHMJ-FRANK&/finalName&
&/properties&
然后运行maven命令:
mvn:tomcat:redeploy
或是直接在eclipse里面点 “run as”运行maven命令,如下图:
命令运行完成后,在tomcat的webapps目录下可见已经自动部署过去的war包,如下图:
开始运行自动部署命令时,一定要先启动tomcat。否则会报下列错误:
[INFO] --- tomcat-maven-plugin:1.0:redeploy (default-cli) @ SSHMJ-FRANK ---
[INFO] Deploying war to http://localhost:8080/SSHMJ-FRANK
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 9.630s
[INFO] Finished at: Tue Aug 31 16:35:52 CST 2010
[INFO] Final Memory: 6M/15M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.codehaus.mojo:tomcat-maven-plugin:1.0:redeploy (default-cli) on project SSHMJ-FRANK: Cannot invoke Tomcat manager: Connection refused: connect -& [Help 1]
[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] 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
完整的pom.xml
&project xmlns="" xmlns:xsi=""
xsi:schemaLocation=" "&
&modelVersion&4.0.0&/modelVersion&
&groupId&com.eastcom.maven&/groupId&
&artifactId&MV_TEST&/artifactId&
&packaging&war&/packaging&
&version&0.0.1-SNAPSHOT&/version&
&name&MV_TEST Maven Webapp&/name&
&url&http://maven.apache.org&/url&
&dependencies&
&dependency&
&groupId&junit&/groupId&
&artifactId&junit&/artifactId&
&version&3.8.1&/version&
&scope&test&/scope&
&/dependency&
&dependency&
&groupId&org.springframework&/groupId&
&artifactId&spring-core&/artifactId&
&version&2.5.6&/version& &/dependency& &dependency&
&groupId&javax.servlet&/groupId&
&artifactId&servlet-api&/artifactId&
&version&2.5&/version&
&scope&provided&/scope& &/dependency&
&/dependencies&
&properties&
&finalName&MVTEST&/finalName&
&/properties&
&finalName&MV_TEST&/finalName&
&groupId&org.codehaus.mojo&/groupId&
&artifactId&tomcat-maven-plugin&/artifactId&
&configuration&
&url&http://localhost:8080/manager&/url&
&username&tomcat&/username&
&password&123456&/password&
&path&/${finalName}&/path&
&/configuration&
&/plugins&
&/build&&/project&
浏览: 218758 次
来自: 宁波
在实体类中加上@Transient 注解后,为什么还会在数据库 ...
如何控制地图显示范围?以及没有下载的tiles不要显示在地图上 ...
[color=red][/color]
标题党!!

我要回帖

更多关于 tomcat error page 的文章

 

随机推荐