Tag Archives: Tomcat7

[Solved] Jenkins deployed the war package to tomcat7 and reported an error

[JENKINS] Archiving/opt/.jenkins/jobs/qxpt -jx-deploy/workspace/pom.xml to com.ichangyan.tsp/qxpt -u jx/2.0/qxpt

[JENKINS] Archiving /opt/.jenkins/jobs/qxpt_jx-deploy/workspace/target/qxpt_jx.war to com.ichangyan.tsp/qxpt_jx/2.0/qxpt_jx-2.0.war
channel stopped
Deploying /opt/.jenkins/jobs/qxpt_jx-deploy/workspace/target/qxpt_jx.war to container Tomcat 7.x Remote
ERROR: Build step failed with exception
org.codehaus.cargo.container.ContainerException: Failed to redeploy [/opt/.jenkins/jobs/qxpt_jx-deploy/workspace/target/qxpt_jx.war]
	at org.codehaus.cargo.container.tomcat.internal.AbstractTomcatManagerDeployer.redeploy(AbstractTomcatManagerDeployer.java:189)
	at hudson.plugins.deploy.CargoContainerAdapter.deploy(CargoContainerAdapter.java:73)
	at hudson.plugins.deploy.CargoContainerAdapter$1.invoke(CargoContainerAdapter.java:116)
	at hudson.plugins.deploy.CargoContainerAdapter$1.invoke(CargoContainerAdapter.java:103)
	at hudson.FilePath.act(FilePath.java:990)
	at hudson.FilePath.act(FilePath.java:968)
	at hudson.plugins.deploy.CargoContainerAdapter.redeploy(CargoContainerAdapter.java:103)
	at hudson.plugins.deploy.DeployPublisher.perform(DeployPublisher.java:61)
	at hudson.tasks.BuildStepMonitor$3.perform(BuildStepMonitor.java:45)
	at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:782)
	at hudson.model.AbstractBuild$AbstractBuildExecution.performAllBuildSteps(AbstractBuild.java:723)
	at hudson.maven.MavenModuleSetBuild$MavenModuleSetBuildExecution.post2(MavenModuleSetBuild.java:1037)
	at hudson.model.AbstractBuild$AbstractBuildExecution.post(AbstractBuild.java:668)
	at hudson.model.Run.execute(Run.java:1763)
	at hudson.maven.MavenModuleSetBuild.run(MavenModuleSetBuild.java:529)
	at hudson.model.ResourceController.execute(ResourceController.java:98)
	at hudson.model.Executor.run(Executor.java:410)
Caused by: org.codehaus.cargo.container.tomcat.internal.TomcatManagerException: The username you provided is not allowed to use the text-based Tomcat Manager (error 403)
	at org.codehaus.cargo.container.tomcat.internal.TomcatManager.invoke(TomcatManager.java:555)
	at org.codehaus.cargo.container.tomcat.internal.TomcatManager.list(TomcatManager.java:686)
	at org.codehaus.cargo.container.tomcat.internal.TomcatManager.getStatus(TomcatManager.java:699)
	at org.codehaus.cargo.container.tomcat.internal.AbstractTomcatManagerDeployer.redeploy(AbstractTomcatManagerDeployer.java:174)
	... 16 more
Caused by: java.io.IOException: Server returned HTTP response code: 403 for URL: http://172.16.xx.xx:8080//manager/text/list
	at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1626)
	at org.codehaus.cargo.container.tomcat.internal.TomcatManager.invoke(TomcatManager.java:544)
	... 19 more
org.codehaus.cargo.container.tomcat.internal.TomcatManagerException: The username you provided is not allowed to use the text-based Tomcat Manager (error 403)
	at org.codehaus.cargo.container.tomcat.internal.TomcatManager.invoke(TomcatManager.java:555)
	at org.codehaus.cargo.container.tomcat.internal.TomcatManager.list(TomcatManager.java:686)
	at org.codehaus.cargo.container.tomcat.internal.TomcatManager.getStatus(TomcatManager.java:699)
	at org.codehaus.cargo.container.tomcat.internal.AbstractTomcatManagerDeployer.redeploy(AbstractTomcatManagerDeployer.java:174)
	at hudson.plugins.deploy.CargoContainerAdapter.deploy(CargoContainerAdapter.java:73)
	at hudson.plugins.deploy.CargoContainerAdapter$1.invoke(CargoContainerAdapter.java:116)
	at hudson.plugins.deploy.CargoContainerAdapter$1.invoke(CargoContainerAdapter.java:103)
	at hudson.FilePath.act(FilePath.java:990)
	at hudson.FilePath.act(FilePath.java:968)
	at hudson.plugins.deploy.CargoContainerAdapter.redeploy(CargoContainerAdapter.java:103)
	at hudson.plugins.deploy.DeployPublisher.perform(DeployPublisher.java:61)
	at hudson.tasks.BuildStepMonitor$3.perform(BuildStepMonitor.java:45)
	at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:782)
	at hudson.model.AbstractBuild$AbstractBuildExecution.performAllBuildSteps(AbstractBuild.java:723)
	at hudson.maven.MavenModuleSetBuild$MavenModuleSetBuildExecution.post2(MavenModuleSetBuild.java:1037)
	at hudson.model.AbstractBuild$AbstractBuildExecution.post(AbstractBuild.java:668)
	at hudson.model.Run.execute(Run.java:1763)
	at hudson.maven.MavenModuleSetBuild.run(MavenModuleSetBuild.java:529)
	at hudson.model.ResourceController.execute(ResourceController.java:98)
	at hudson.model.Executor.run(Executor.java:410)
Caused by: java.io.IOException: Server returned HTTP response code: 403 for URL: http://172.16.XX.XX:8080//manager/text/list
	at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1626)
	at org.codehaus.cargo.container.tomcat.internal.TomcatManager.invoke(TomcatManager.java:544)
	... 19 more
Build step 'Deploy war/ear to a container' marked build as failure
Finished: FAILURE

 

Analysis:

This problem is caused by the definition of user permissions for tomcat 7, as follows

manager-gui — Access to the HTML interface.

manager-status — Access to the “Server Status” page only.

manager-script — Access to the tools-friendly plain text interface that is described in this document, and to the “Server Status” page.

manager-jmx — Access to JMX proxy interface and to the “Server Status” page.

You must define the permissions of the deployment user as “manager-script” for the deployment to succeed.

Solution:

1. You need to modify the tomcat-users.xml file in the conf folder of tomcat

<role rolename=”manager-gui”/>

<role rolename=”manager-script”/>

<user username=”admin” password=”admin” roles=”manager-gui,manager-script”/>

2, restart the service can be (under linux)

./shutdown.sh

./startup.sh

 

Tomcat7 starts with error listener start

Error message:
0

Jul14,20153:47:56PMorg.apache.coyote.AbstractProtocolinit
INFO:InitializingProtocolHandler["http-bio-8080"]
Jul14,20153:47:56PMorg.apache.coyote.AbstractProtocolinit
INFO:InitializingProtocolHandler["ajp-bio-8009"]
Jul14,20153:47:56PMorg.apache.catalina.startup.Catalinaload
INFO:Initializationprocessedin684ms
Jul14,20153:47:56PMorg.apache.catalina.core.StandardServicestartInternal
INFO:StartingserviceCatalina
Jul14,20153:47:56PMorg.apache.catalina.core.StandardEnginestartInternal
INFO:StartingServletEngine:ApacheTomcat/7.0.59
Jul14,20153:47:56PMorg.apache.catalina.startup.HostConfigdeployWAR
INFO:Deployingwebapplicationarchive/data/tomcat/webapps/app.war
Jul14,20153:47:56PMorg.apache.catalina.loader.WebappClassLoadervalidateJarFile
INFO:validateJarFile(/data/tomcat/webapps/app/WEB-INF/lib/javax.servlet-api-3.1.0.jar)-jarnotloaded.SeeServletSpec3.0,section10.7.2.Offendingclass:javax/servlet/Servlet.class
SLF4J:Failedtoloadclass"org.slf4j.impl.StaticLoggerBinder".
SLF4J:Defaultingtono-operation(NOP)loggerimplementation
SLF4J:Seehttp://www.slf4j.org/codes.html#StaticLoggerBinderforfurtherdetails.
Jul14,20153:48:08PMorg.apache.catalina.core.StandardContextstartInternal
SEVERE:ErrorlistenerStart
Jul14,20153:48:08PMorg.apache.catalina.core.StandardContextstartInternal
SEVERE:Context[/app]startupfailedduetopreviouserrors
Jul14,20153:48:08PMorg.apache.catalina.loader.WebappClassLoaderclearReferencesThreads
SEVERE:Thewebapplication[/app]appearstohavestartedathreadnamed[Timer-0]buthasfailedtostopit.Thisisverylikelytocreateamemoryleak.
Jul14,20153:48:08PMorg.apache.catalina.loader.WebappClassLoaderclearReferencesThreads
SEVERE:Thewebapplication[/app]appearstohavestartedathreadnamed[DubboRegistryFailedRetryTimer-thread-1]buthasfailedtostopit.Thisisverylikelytocreateamemoryleak.
Jul14,20153:48:08PMorg.apache.catalina.loader.WebappClassLoaderclearReferencesThreads
SEVERE:Thewebapplication[/app]appearstohavestartedathreadnamed[ZkClient-EventThread-16-192.168.1.20:2181]buthasfailedtostopit.Thisisverylikelytocreateamemoryleak.
Jul14,20153:48:08PMorg.apache.catalina.loader.WebappClassLoaderclearReferencesThreads
SEVERE:Thewebapplication[/app]appearstohavestartedathreadnamed[localhost-startStop-1-SendThread(192.168.1.20:2181)]buthasfailedtostopit.Thisisverylikelytocreateamemoryleak.
Jul14,20153:48:08PMorg.apache.catalina.loader.WebappClassLoaderclearReferencesThreads
SEVERE:Thewebapplication[/app]appearstohavestartedathreadnamed[localhost-startStop-1-EventThread]buthasfailedtostopit.Thisisverylikelytocreateamemoryleak.
Jul14,20153:48:08PMorg.apache.catalina.loader.WebappClassLoaderclearReferencesThreads
SEVERE:Thewebapplication[/app]appearstohavestartedathreadnamed[DubboSaveRegistryCache-thread-1]buthasfailedtostopit.Thisisverylikelytocreateamemoryleak.
Jul14,20153:48:08PMorg.apache.catalina.loader.WebappClassLoaderclearReferencesThreads
SEVERE:Thewebapplication[/app]appearstohavestartedathreadnamed[DubboClientReconnectTimer-thread-1]buthasfailedtostopit.Thisisverylikelytocreateamemoryleak.
Jul14,20153:48:08PMorg.apache.catalina.loader.WebappClassLoaderclearReferencesThreads
SEVERE:Thewebapplication[/app]appearstohavestartedathreadnamed[NewI/Oclientboss#1]buthasfailedtostopit.Thisisverylikelytocreateamemoryleak.
Jul14,20153:48:08PMorg.apache.catalina.loader.WebappClassLoaderclearReferencesThreads
SEVERE:Thewebapplication[/app]appearstohavestartedathreadnamed[NewI/Oclientworker#1-1]buthasfailedtostopit.Thisisverylikelytocreateamemoryleak.
Jul14,20153:48:08PMorg.apache.catalina.loader.WebappClassLoaderclearReferencesThreads
SEVERE:Thewebapplication[/app]appearstohavestartedathreadnamed[dubbo-remoting-client-heartbeat-thread-1]buthasfailedtostopit.Thisisverylikelytocreateamemoryleak.
Jul14,20153:48:08PMorg.apache.catalina.loader.WebappClassLoaderclearReferencesThreads
SEVERE:Thewebapplication[/app]appearstohavestartedathreadnamed[DubboClientReconnectTimer-thread-2]buthasfailedtostopit.Thisisverylikelytocreateamemoryleak.
Jul14,20153:48:08PMorg.apache.catalina.loader.WebappClassLoaderclearReferencesThreads
SEVERE:Thewebapplication[/app]appearstohavestartedathreadnamed[NewI/Oclientworker#1-2]buthasfailedtostopit.Thisisverylikelytocreateamemoryleak.
Jul14,20153:48:08PMorg.apache.catalina.loader.WebappClassLoaderclearReferencesThreads
SEVERE:Thewebapplication[/app]appearstohavestartedathreadnamed[dubbo-remoting-client-heartbeat-thread-2]buthasfailedtostopit.Thisisverylikelytocreateamemoryleak.
Jul14,20153:48:08PMorg.apache.catalina.loader.WebappClassLoaderclearReferencesThreads

The error reported by Tomcat is too vague. No error was reported, only error listener start was prompted. For debugging, we need to get more detailed logs. You can create a new file called logging. Properties in the WEB-INF/classes directory. The content is as follows

handlers=org.apache.juli.FileHandler,java.util.logging.ConsoleHandler

############################################################
#Handlerspecificproperties.
#DescribesspecificconfigurationinfoforHandlers.
############################################################

org.apache.juli.FileHandler.level=FINE
org.apache.juli.FileHandler.directory=${catalina.base}/logs
org.apache.juli.FileHandler.prefix=error-debug.

java.util.logging.ConsoleHandler.level=FINE
java.util.logging.ConsoleHandler.formatter=java.util.logging.SimpleFormatter

In this way, when we start Tomcat again, we will generate a more detailed log error-debug.2012-05-31.log in the logs directory

let’s go in and see what’s wrong
the mistake I encountered is FileNotFoundException. There should be all kinds of mistakes, so we need to analyze the specific problems