gpt4 book ai didi

java - Maven Tomcat插件-无法调用Tomcat管理器

转载 作者:行者123 更新时间:2023-11-28 22:49:21 25 4
gpt4 key购买 nike

我正在尝试使用Maven(版本3.3.3)在Tomcat 7上部署Web应用程序,但标题中列出了异常。

我尝试了许多解决方案,但没有人适合我。

我有:


编辑tomcat-users.xml($ CATALINA_HOME / conf / tomcat-user.xml):

<tomcat-users>
<role rolename="manager-gui"/>
<role rolename="manager-script"/>
<user username="user" password="pass" roles="manager-script"/>
<user username="user2" password="pass2" roles="manager-gui"/>
</tomcat-users>

编辑 settings.xml($ USER_HOME / .m2 / settings.xml):

<servers>
<server>
<id>RemoteServer</id>
<username>user</username>
<password>pass</password>
</server>
</servers>

配置的 pom.xml($ MY_PROJECT / pom.xml):

 <plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.2</version>
<configuration>
<server>RemoteServer</server>
<url>http://my.public.ip.address:8080/manager/text</url>
<username>user</username>
<password>pass</password>
</configuration>
</plugin>

编辑 context.xml($ CATALINA_HOME / webapps / manager / META-INF / context.xml)

 <Context antiResourceLocking="false" privileged="true" >
<!--
<Valve className="org.apache.catalina.valves.RemoteAddrValve"
allow="127\.\d+\.\d+\.\d+|::1|0:0:0:0:0:0:0:1" />
-->
<Manager sessionAttributeValueClassNameFilter="java\.lang\.(?:Boolean|Integer|Long|Number|String)|org\.apache\.catalina\.filters\.CsrfPreventionFilter\$LruCache(?:\$1)?|java\.util\.(?:Linked)?HashMap"/>
</Context>



补充说明:


我尝试将两者都部署到8.0.45和8.5.16(对于后者的服务器,context.xml中的配置是基本的)
我可以毫无问题地访问经理GUI
pom中的用户名/密码“应该”是一个过大的杀伤力,但是我读到这可能会有所帮助,无论如何我也尝试了不使用这些属性
如果我测试管理器/文本(例如浏览器中的管理器/文本/部署),则会收到响应(失败-为命令[/ deploy]提供了无效的参数,这很好)


我得到的错误是:

[错误]无法在项目ShareRideServer上执行目标org.apache.tomcat.maven:tomcat7-maven-plugin:2.2:deploy(default-cli):无法调用Tomcat管理器:连接被拒绝:connect-> [帮助1]
org.apache.maven.lifecycle.LifecycleExecutionException:无法在项目ShareRideServer上执行目标org.apache.tomcat.maven:tomcat7-maven-plugin:2.2:deploy(default-cli):无法调用Tomcat管理器
    在org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:216)
    在org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
    在org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
    在org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)
    在org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
    在org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
    在org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
    在org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:307)
    在org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193)
    在org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106)
    在org.apache.maven.cli.MavenCli.execute(MavenCli.java:862)
    在org.apache.maven.cli.MavenCli.doMain(MavenCli.java:286)
    在org.apache.maven.cli.MavenCli.main(MavenCli.java:197)
    在sun.reflect.NativeMethodAccessorImpl.invoke0(本机方法)处
    在sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    在sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    在java.lang.reflect.Method.invoke(Method.java:497)
    在org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
    在org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
    在org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
    在org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
造成原因:org.apache.maven.plugin.MojoExecutionException:无法调用Tomcat管理器
    在org.apache.tomcat.maven.plugin.tomcat7.AbstractCatalinaMojo.execute(AbstractCatalinaMojo.java:141)
    在org.apache.tomcat.maven.plugin.tomcat7.AbstractWarCatalinaMojo.execute(AbstractWarCatalinaMojo.java:68)
    在org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
    在org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
    ...另外20个
引起原因:java.net.ConnectException:连接被拒绝:connect
    在java.net.DualStackPlainSocketImpl.connect0(本机方法)
    在java.net.DualStackPlainSocketImpl.socketConnect(DualStackPlainSocketImpl.java:79)
    在java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350)
    在java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)
    在java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)
    在java.net.PlainSocketImpl.connect(PlainSocketImpl.java:172)
    在java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
    在java.net.Socket.connect(Socket.java:589)
    在org.apache.http.conn.scheme.PlainSocketFactory.connectSocket(PlainSocketFactory.java:117)
    在org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:178)
    在org.apache.http.impl.conn.ManagedClientConnectionImpl.open(ManagedClientConnectionImpl.java:304)
    在org.apache.http.impl.client.DefaultRequestDirector.tryConnect(DefaultRequestDirector.java:610)
    在org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:445)
    在org.apache.http.impl.client.AbstractHttpClient.doExecute(AbstractHttpClient.java:863)
    在org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:82)
    在org.apache.tomcat.maven.common.deployer.TomcatManager.invoke(TomcatManager.java:742)
    在org.apache.tomcat.maven.common.deployer.TomcatManager.deployImpl(TomcatManager.java:705)
    在org.apache.tomcat.maven.common.deployer.TomcatManager.deploy(TomcatManager.java:388)
    在org.apache.tomcat.maven.plugin.tomcat7.deploy.AbstractDeployWarMojo.deployWar(AbstractDeployWarMojo.java:85)
    在org.apache.tomcat.maven.plugin.tomcat7.deploy.AbstractDeployMojo.invokeManager(AbstractDeployMojo.java:82)
    在org.apache.tomcat.maven.plugin.tomcat7.AbstractCatalinaMojo.execute(AbstractCatalinaMojo.java:132)
    ...另外23个

最佳答案

答案是:配置正确。但是,请务必在工作时检查防火墙...我尝试使用其他连接,但没有问题。防火墙似乎无声地杀死了所有请求。

关于java - Maven Tomcat插件-无法调用Tomcat管理器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45637579/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com