我正在尝试在网络上另一台计算机上运行的 Tomcat 7 上构建和部署 Struts2“教程”示例项目。该项目在本地计算机上构建和部署良好,但在远程计算机上部署时出现错误(如下所示)。
pom.xml 文件中的设置是:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>tomcat-maven-plugin</artifactId>
<version>1.1</version>
<configuration>
<url>http://10.0.0.220:8080/manager</url>
<server>myserver</server>
</configuration>
</plugin>
其中,10.0.0.220:8080 是我尝试部署 WAR 文件的计算机的地址。
我本地机器上 Maven 的 settings.xml 中的代码是:
<server>
<id>myserver</id>
<username>travel</username>
<password>travel</password>
</server>
我尝试部署的计算机上的 Tomcat 7.0/conf/tomcat-users.xml 文件中的代码是:
<user name = "travel" password = "travel" roles = "manager-gui,admin-gui" />
此外,我可以http://10.0.0.220:8080/manager
从本地计算机上的 Web 浏览器访问并手动部署我的 WAR 文件。
但是,当我mvn tomcat:deploy
在本地机器上使用时,它说 BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.codehaus.mojo:tomcat-maven-plugin:1.1:deploy
(default-cli) on project tutorial: Cannot invoke Tomcat manager: Server returned
HTTP response code: 403 for URL: http://10.0.0.220:8080/manager/deploy?path=%2F
tutorial&war= -> [Help 1]
当我使用时,mvn tomcat:run
我得到以下信息:
INFO: ... initialized Struts-Spring integration successfully
Apr 21, 2011 3:39:22 PM org.apache.coyote.http11.Http11Protocol init
SEVERE: Error initializing endpoint
java.net.SocketException: Unrecognized Windows Sockets error: 0: JVM_Bind
at java.net.PlainSocketImpl.socketBind(Native Method)
at java.net.PlainSocketImpl.bind(PlainSocketImpl.java:365)
at java.net.ServerSocket.bind(ServerSocket.java:319)
at java.net.ServerSocket.<init>(ServerSocket.java:185)
at java.net.ServerSocket.<init>(ServerSocket.java:141)
at org.apache.tomcat.util.net.DefaultServerSocketFactory.createSocket(De
faultServerSocketFactory.java:50)
at org.apache.tomcat.util.net.JIoEndpoint.init(JIoEndpoint.java:538)
at org.apache.coyote.http11.Http11Protocol.init(Http11Protocol.java:176)
at org.apache.catalina.connector.Connector.initialize(Connector.java:101
4)
at org.apache.catalina.startup.Embedded.start(Embedded.java:830)
at org.codehaus.mojo.tomcat.AbstractRunMojo.startContainer(AbstractRunMo
jo.java:558)
at org.codehaus.mojo.tomcat.AbstractRunMojo.execute(AbstractRunMojo.java
:255)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(Default
BuildPluginManager.java:101)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor
.java:209)
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.buildProje
ct(LifecycleModuleBuilder.java:84)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProje
ct(LifecycleModuleBuilder.java:59)
at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBu
ild(LifecycleStarter.java:183)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(Lifecycl
eStarter.java:161)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:319)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:537)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:141)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Laun
cher.java:290)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.jav
a:230)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(La
uncher.java:409)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:
352)
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 6.330s
[INFO] Finished at: Thu Apr 21 15:39:23 IST 2011
[INFO] Final Memory: 5M/10M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.codehaus.mojo:tomcat-maven-plugin:1.1:run (de
fault-cli) on project tutorial: Could not start Tomcat: Protocol handler initial
ization failed: java.net.SocketException: Unrecognized Windows Sockets error: 0:
JVM_Bind -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e swit
ch.
什么可能导致这个问题?我已关闭 Windows 防火墙并将 UAC 设置为“从不通知”。
此外,如果我mvn tomcat:deploy
在我的本地机器(运行 tomcat 5)上使用它,它部署得很好。