由“my_website_pakaging”生成的WAR文件(这是在没有错误的情况下执行的上游项目),但是在下游项目中我想将此war文件部署到Tomcat容器 配置如下
tomcat-user.xml具有以下配置:
但是,我收到了以下错误
Tomcat服务器运行正常
有人可以帮我解决这个问题吗?
下面的是完整的控制台输出:
用于上游项目" my_website_packaging"
Started by user Sanju000
Building in workspace /var/lib/jenkins/workspace/my_website_packaging
> git rev-parse --is-inside-work-tree # timeout=10
Fetching changes from the remote Git repository
> git config remote.origin.url https://github.com/sandeep000/maven-project.git # timeout=10
Fetching upstream changes from https://github.com/sandeep000/maven-project.git
> git --version # timeout=10
> git fetch --tags --progress https://github.com/sandeep000/maven-project.git +refs/heads/*:refs/remotes/origin/*
> git rev-parse refs/remotes/origin/master^{commit} # timeout=10
> git rev-parse refs/remotes/origin/origin/master^{commit} # timeout=10
Checking out Revision 746f48a40a46370c0fa3609127f7ececab47f2f4 (refs/remotes/origin/master)
> git config core.sparsecheckout # timeout=10
> git checkout -f 746f48a40a46370c0fa3609127f7ececab47f2f4
Commit message: "updates from checksum"
> git rev-list 746f48a40a46370c0fa3609127f7ececab47f2f4 # timeout=10
[my_website_packaging] $ /home/jenkins/apache-maven-3.5.2/bin/mvn clean package checkstyle:checkstyle
[INFO] Scanning for projects...
[WARNING]
[WARNING] Some problems were encountered while building the effective model for com.example.maven-project:server:jar:1.0-SNAPSHOT
[WARNING] Reporting configuration should be done in <reporting> section, not in maven-site-plugin <configuration> as reportPlugins parameter.
[WARNING]
[WARNING] Some problems were encountered while building the effective model for com.example.maven-project:webapp:war:1.0-SNAPSHOT
[WARNING] Reporting configuration should be done in <reporting> section, not in maven-site-plugin <configuration> as reportPlugins parameter.
[WARNING]
[WARNING] Some problems were encountered while building the effective model for com.example.maven-project:maven-project:pom:1.0-SNAPSHOT
[WARNING] Reporting configuration should be done in <reporting> section, not in maven-site-plugin <configuration> as reportPlugins parameter. @ line 51, column 24
[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 support building such malformed projects.
[WARNING]
[WARNING] The project com.example.maven-project:maven-project:pom:1.0-SNAPSHOT uses prerequisites which is only intended for maven-plugin projects but not for non maven-plugin projects. For such purposes you should use the maven-enforcer-plugin. See https://maven.apache.org/enforcer/enforcer- rules/requireMavenVersion.html
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Build Order:
[INFO]
[INFO] Maven Project
[INFO] Server
[INFO] Webapp
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Maven Project 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ maven-project ---
[INFO]
[INFO] --- maven-checkstyle-plugin:2.8:checkstyle (default-cli) @ maven-project ---
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Server 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ server ---
[INFO] Deleting /var/lib/jenkins/workspace/my_website_packaging/server/target
[ INFO]
[INFO] --- maven-resources-plugin:2.5:resources (default-resources) @ server ---
[debug] execute contextualize
[INFO] Using 'utf-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /var/lib/jenkins/workspace/my_website_packaging/server/src/main/resources
[INFO]
[INFO] --- maven-compiler-plugin:2.3.2:compile (default-compile) @ server ---
[INFO] Compiling 2 source files to /var/lib/jenkins/workspace/my_website_packaging/server/target/classes
[INFO]
[INFO] --- maven-resources-plugin:2.5:testResources (default-testResources) @ server ---
[debug] execute contextualize
[INFO] Using 'utf-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /var/lib/jenkins/workspace/my_website_packaging/server/src/test/resources
[INFO]
[INFO] --- maven-compiler-plugin:2.3.2:testCompile (default-testCompile) @ server ---
[INFO] Compiling 1 source file to /var/lib/jenkins/workspace/my_website_packaging/server/target/test-classes
[INFO]
[INFO] --- maven-surefire-plugin:2.11:test (default-test) @ server ---
[INFO] Surefire report directory: /var/lib/jenkins/workspace/my_website_packaging/server/target/surefire-reports
-------------------------------------------------------
T E S T S
-------------------------------------------------------
Running com.example.TestGreeter
Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.592 sec
Results :
Tests run: 2, Failures: 0, Errors: 0, Skipped: 0
[INFO]
[INFO] --- maven-jar-plugin:2.4:jar (default-jar) @ server ---
[INFO] Building jar:
/var/lib/jenkins/workspace/my_website_packaging/server/target/server.jar
[INFO]
[INFO] --- maven-checkstyle-plugin:2.8:checkstyle (default-cli) @ server ---
[INFO]
[WARNING] Unable to locate Source XRef to link to - DISABLED
[INFO]
[INFO] ---------------------------------------------------------------------
---
[INFO] Building Webapp 1.0-SNAPSHOT
[INFO] ---------------------------------------------------------------------
---
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ webapp ---
[INFO] Deleting
/var/lib/jenkins/workspace/my_website_packaging/webapp/target
[INFO]
[INFO] --- maven-resources-plugin:2.5:resources (default-resources) @ webapp
---
[debug] execute contextualize
[INFO] Using 'utf-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory
/var/lib/jenkins/workspace/my_website_packaging/webapp/src/main/resources
[INFO]
[INFO] --- maven-compiler-plugin:2.3.2:compile (default-compile) @ webapp --
-
[INFO] No sources to compile
[INFO]
[INFO] --- maven-resources-plugin:2.5:testResources (default-testResources)
@ webapp ---
[debug] execute contextualize
[INFO] Using 'utf-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory
/var/lib/jenkins/workspace/my_website_packaging/webapp/src/test/resources
[INFO]
[INFO] --- maven-compiler-plugin:2.3.2:testCompile (default-testCompile) @
webapp ---
[INFO] No sources to compile
[INFO]
[INFO] --- maven-surefire-plugin:2.11:test (default-test) @ webapp ---
[INFO] No tests to run.
[INFO] Surefire report directory:
/var/lib/jenkins/workspace/my_website_packaging/webapp/target/surefire-
reports
-------------------------------------------------------
T E S T S
-------------------------------------------------------
Results :
Tests run: 0, Failures: 0, Errors: 0, Skipped: 0
[INFO]
[INFO] --- maven-war-plugin:2.2:war (default-war) @ webapp ---
[INFO] Packaging webapp
[INFO] Assembling webapp [webapp] in
[/var/lib/jenkins/workspace/my_website_packaging/webapp/target/webapp]
[INFO] Processing war project
[INFO] Copying webapp resources
[/var/lib/jenkins/workspace/my_website_packaging/webapp/src/main/webapp]
[INFO] Webapp assembled in [206 msecs]
[INFO] Building war:
/var/lib/jenkins/workspace/my_website_packaging/webapp/target/webapp.war
[INFO] WEB-INF/web.xml already added, skipping
[INFO]
[INFO] --- maven-checkstyle-plugin:2.8:checkstyle (default-cli) @ webapp ---
[INFO] ---------------------------------------------------------------------
---
[INFO] Reactor Summary:
[INFO]
[INFO] Maven Project ...................................... SUCCESS [ 9.377
s]
[INFO] Server ............................................. SUCCESS [ 26.852
s]
[INFO] Webapp ............................................. SUCCESS [ 5.206
s]
[INFO] ---------------------------------------------------------------------
---
[INFO] BUILD SUCCESS
[INFO] ---------------------------------------------------------------------
---
[INFO] Total time: 46.936 s
[INFO] Finished at: 2017-11-08T15:55:25Z
[INFO] Final Memory: 32M/77M
[INFO] ---------------------------------------------------------------------
---
[CHECKSTYLE] Collecting checkstyle analysis files...
[CHECKSTYLE] Searching for all files in
/var/lib/jenkins/workspace/my_website_packaging that match the pattern
**/checkstyle-result.xml
[CHECKSTYLE] Parsing 1 file in
/var/lib/jenkins/workspace/my_website_packaging
[CHECKSTYLE] Successfully parsed file
/var/lib/jenkins/workspace/my_website_packaging/server/target/checkstyle-
result.xml with 0 unique warnings and 0 duplicates.
<Git Blamer> Using GitBlamer to create author and commit information for all
warnings.
<Git Blamer> GIT_COMMIT=746f48a40a46370c0fa3609127f7ececab47f2f4,
workspace=/var/lib/jenkins/workspace/my_website_packaging
[CHECKSTYLE] Computing warning deltas based on reference build #62
Archiving artifacts
Triggering a new build of my_website_deploy_to_staging
Finished: SUCCESS
现在为下游项目&#34; my_website_deploy_to_staging&#34;
Started by upstream project "my_website_packaging" build number 63
originally caused by:
Started by user Sanju000
Building in workspace
/var/lib/jenkins/workspace/my_website_deploy_to_staging
Copied 1 artifact from "my_website_packaging" build number 63
Deploying /var/lib/jenkins/workspace/my_website_deploy_to_staging/webapp/target/webapp.war to container Tomcat 7.x Remote with context
ERROR: Build step failed with exception
org.codehaus.cargo.container.ContainerException: Failed to redeploy [/var/lib/jenkins/workspace/my_website_deploy_to_staging/webapp/target/webapp.war]
at org.codehaus.cargo.container.tomcat.internal.AbstractTomcatManagerDeployer.redeploy(AbstractTomcatManagerDeployer.java:192)
at hudson.plugins.deploy.CargoContainerAdapter.deploy(CargoContainerAdapter.java:77)
at hudson.plugins.deploy.CargoContainerAdapter$DeployCallable.invoke(CargoContainerAdapter.java:147)
at hudson.plugins.deploy.CargoContainerAdapter$DeployCallable.invoke(CargoContainerAdapter.java:117)
at hudson.FilePath.act(FilePath.java:998)
at hudson.FilePath.act(FilePath.java:976)
at hudson.plugins.deploy.CargoContainerAdapter.redeploy(CargoContainerAdapter.java:114)
at hudson.plugins.deploy.PasswordProtectedAdapterCargo.redeploy(PasswordProtectedAdapterCargo.java:93)
at hudson.plugins.deploy.DeployPublisher.perform(DeployPublisher.java:64)
at hudson.tasks.BuildStepMonitor$3.perform(BuildStepMonitor.java:45)
at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:736)
at hudson.model.AbstractBuild$AbstractBuildExecution.performAllBuildSteps(AbstractBuild.java:682)
at hudson.model.Build$BuildExecution.post2(Build.java:186)
at hudson.model.AbstractBuild$AbstractBuildExecution.post(AbstractBuild.java:627)
at hudson.model.Run.execute(Run.java:1762)
at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
at hudson.model.ResourceController.execute(ResourceController.java:97)
at hudson.model.Executor.run(Executor.java:421)
Caused by: java.net.ConnectException: Connection timed out (Connection timed out)
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350)
at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)
at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
at java.net.Socket.connect(Socket.java:589)
at java.net.Socket.connect(Socket.java:538)
at sun.net.NetworkClient.doConnect(NetworkClient.java:180)
at sun.net.www.http.HttpClient.openServer(HttpClient.java:463)
at sun.net.www.http.HttpClient.openServer(HttpClient.java:558)
at sun.net.www.http.HttpClient.<init>(HttpClient.java:242)
at sun.net.www.http.HttpClient.New(HttpClient.java:339)
at sun.net.www.http.HttpClient.New(HttpClient.java:357)
at sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(HttpURLConnection.java:1220)
at sun.net.www.protocol.http.HttpURLConnection.plainConnect0(HttpURLConnection.java:1156)
at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:1050)
at sun.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection.java:984)
at org.codehaus.cargo.container.tomcat.internal.TomcatManager.invoke(TomcatManager.java:561)
at org.codehaus.cargo.container.tomcat.internal.TomcatManager.list(TomcatManager.java:876)
at org.codehaus.cargo.container.tomcat.internal.TomcatManager.getStatus(TomcatManager.java:889)
at org.codehaus.cargo.container.tomcat.internal.AbstractTomcatManagerDeployer.redeploy(AbstractTomcatManagerDeployer.java:173)
... 17 more
java.net.ConnectException: Connection timed out (Connection timed out)
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350)
at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)
at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
at java.net.Socket.connect(Socket.java:589)
at java.net.Socket.connect(Socket.java:538)
at sun.net.NetworkClient.doConnect(NetworkClient.java:180)
at sun.net.www.http.HttpClient.openServer(HttpClient.java:463)
at sun.net.www.http.HttpClient.openServer(HttpClient.java:558)
at sun.net.www.http.HttpClient.<init>(HttpClient.java:242)
at sun.net.www.http.HttpClient.New(HttpClient.java:339)
at sun.net.www.http.HttpClient.New(HttpClient.java:357)
at sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(HttpURLConnection.java:1220)
at sun.net.www.protocol.http.HttpURLConnection.plainConnect0(HttpURLConnection.java:1156)
at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:1050)
at sun.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection.java:984)
at org.codehaus.cargo.container.tomcat.internal.TomcatManager.invoke(TomcatManager.java:561)
at org.codehaus.cargo.container.tomcat.internal.TomcatManager.list(TomcatManager.java:876)
at org.codehaus.cargo.container.tomcat.internal.TomcatManager.getStatus(TomcatManager.java:889)
at org.codehaus.cargo.container.tomcat.internal.AbstractTomcatManagerDeployer.redeploy(AbstractTomcatManagerDeployer.java:173)
at hudson.plugins.deploy.CargoContainerAdapter.deploy(CargoContainerAdapter.java:77)
at hudson.plugins.deploy.CargoContainerAdapter$DeployCallable.invoke(CargoContainerAdapter.java:147)
at hudson.plugins.deploy.CargoContainerAdapter$DeployCallable.invoke(CargoContainerAdapter.java:117)
at hudson.FilePath.act(FilePath.java:998)
at hudson.FilePath.act(FilePath.java:976)
at hudson.plugins.deploy.CargoContainerAdapter.redeploy(CargoContainerAdapter.java:114)
at hudson.plugins.deploy.PasswordProtectedAdapterCargo.redeploy(PasswordProtectedAdapterCargo.java:93)
at hudson.plugins.deploy.DeployPublisher.perform(DeployPublisher.java:64)
at hudson.tasks.BuildStepMonitor$3.perform(BuildStepMonitor.java:45)
at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:736)
at hudson.model.AbstractBuild$AbstractBuildExecution.performAllBuildSteps(AbstractBuild.java:682)
at hudson.model.Build$BuildExecution.post2(Build.java:186)
at hudson.model.AbstractBuild$AbstractBuildExecution.post(AbstractBuild.java:627)
at hudson.model.Run.execute(Run.java:1762)
at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
at hudson.model.ResourceController.execute(ResourceController.java:97)
at hudson.model.Executor.run(Executor.java:421)
Build step 'Deploy war/ear to a container' marked build as failure
Finished: FAILURE
答案 0 :(得分:0)
谢谢,ThorbjørnRavnAndersen指出“货物试图用来到达Tomcat的地址是错误的”。当你的Jenkins和Tomcat托管在同一台机器上时,然后在war / ear下部署容器,输入Tomcat URL为“http://localhost:tomcat_port”,例如“http://localhost:8090”,而不是某些花哨的主机名(sanju0001.mylabserver。 COM:8090)。这样可以防止出现连接错误(由于本地DNS配置不正确)
答案 1 :(得分:0)
您尚未正确配置Cargo - 连接超时表示您正在尝试访问由于某种原因无法从当前主机完全访问的IP号码。这可能有很多原因 - 网络路由很复杂,尤其是涉及NAT路由器时 - 但通常通过配置Cargo来使用可到达的网络地址来修复。在这种特殊情况下,请改用localhost:8090
。
一个好的诊断工具是
telnet host port
可让您轻松查看是否可以对特定端口建立网络连接。如果telnet不可用,netcat可能是:
nc -v host port
(见https://scottlinux.com/2013/12/19/stop-using-telnet-and-start-using-netcat/)