我想用Maven(版本3.3.3)在Tomcat 7上部署我的web應用程序,但我得到了標題中列出的例外。Maven tomcat插件 - 無法調用Tomcat管理器
我試過很多解決方案,但沒有人爲我工作。
我:
編輯
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/PO m.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 /目錄經理/ 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中的配置是基本的)
我可以毫無問題
的用戶名/密碼在POM訪問管理器GUI「應該」是矯枉過正,但我看周圍,可以幫助,在任何情況下,我也試過沒有這些屬性
如果我測試管理器/文本(例如管理器/文本/從瀏覽器部署)我得到一個響應(FAIL - 用於命令提供了無效的參數[/部署]這很好)
我得到的錯誤是:
無法執行目標org.apache.tomcat.maven:項目ShareRideServer上的tomcat7-maven-plugin:2.2:deploy(default-cli):無法調用Tomcat管理器:Connection refused:connect - > [幫助1] org.apache.maven.lifecycle.LifecycleExecutionException:未能執行目標org.apache.tomcat.maven:tomcat7-maven-plugin:2.2:在項目上部署(default-cli)ShareRideServer:無法調用Tomcat管理器 at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:216) 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:116) at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80) at org.apache.maven。 lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51) at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128) at org.apache。maven.DefaultMaven.doExecute(DefaultMaven.java:307) at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193) at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106) at org.apache.maven.cli.MavenCli.execute(MavenCli.java:862) at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:286) at org.apache.maven.cli.MavenCli。主(MavenCli.java:197) 在sun.reflect.NativeMethodAccessorImpl.invoke0(本機方法) 在sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) 在sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java :43) at java.lang.reflect.Method.invoke(Method.java:497) at org.codehaus.plexus.clas sworg.launcher.Launcher.launchEnhanced(Launcher.java:289) at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229) at 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:連接被拒絕:在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) at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188) at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:172) at j ava.net.SocksSocketImpl.connect(SocksSocketImpl.java:392) at java.net.Socket.connect(Socket.java:589) at 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) 在有機apache.http.impl.client.DefaultRequestDirector.tryConnect(DefaultRequestDirector.java:610) at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:445) at org.apache.http.impl。 client.AbstractHttpClient.doExecute(AbstractHttpClient.java:863) at org.apache.http.impl.client.CloseableH ttpClient.execute(CloseableHttpClient.java:82) at org.apache.tomcat.maven.common.deployer.TomcatManager.invoke(TomcatManager.java:742) at org.apache.tomcat.maven.common.deployer.TomcatManager。 deployImpl(TomcatManager.java:705) at org.apache.tomcat.maven.common.deployer.TomcatManager.deploy(TomcatManager.java:388) at org.apache.tomcat.maven.plugin.tomcat7.deploy.AbstractDeployWarMojo。 deployWar(AbstractDeployWarMojo.java:85) at org.apache.tomcat.maven.plugin.tomcat7.deploy.AbstractDeployMojo.invokeManager(AbstractDeployMojo.java:82) at org.apache.tomcat.maven.plugin.tomcat7.AbstractCatalinaMojo。執行(AbstractCatalinaMojo.java:132) ...23更多
http://tomcat.apache.org/maven-plugin-trunk/tomcat7-maven-plugin/usage.html據此,用戶名和密碼進入服務器塊 – rohanagarwal
是的,正如我在第三個項目符號中所寫的點,我也嘗試沒有用戶名和密碼在pom.xml中,但只在服務器塊:) –