[젠킨스&톰켓 설정 오류 해결] Caused by: java.io.IOException: Server returned HTTP response code: 403 for URL: xxx
젠킨스로 소스 배포하는데 오류가 발생하였다.
아래와 같은 오류가 발생한다면 manager.xml 파일 설정을 다시 한번 살펴보자
- Caused by: java.io.IOException: Server returned HTTP response code: 403 for URL
- org.codehaus.cargo.container.tomcat.internal.TomcatManagerException: The username you provided is not allowed to use the text-based Tomcat Manager (error 403)
오류 전체 내용은 다음과 같다.
org.codehaus.cargo.container.ContainerException: Failed to redeploy [D:Bitnamijenkins-2.89.4-1appsjenkinsjenkins_homejobsworkspaceadmintargetadmain_2021.12.31.war]
at org.codehaus.cargo.container.tomcat.internal.AbstractTomcatManagerDeployer.redeploy(AbstractTomcatManagerDeployer.java:176)
at hudson.plugins.deploy.CargoContainerAdapter.deploy(CargoContainerAdapter.java:81)
at hudson.plugins.deploy.CargoContainerAdapter$DeployCallable.invoke(CargoContainerAdapter.java:167)
at hudson.plugins.deploy.CargoContainerAdapter$DeployCallable.invoke(CargoContainerAdapter.java:136)
at hudson.FilePath.act(FilePath.java:1164)
at hudson.FilePath.act(FilePath.java:1147)
at hudson.plugins.deploy.CargoContainerAdapter.redeployFile(CargoContainerAdapter.java:133)
at hudson.plugins.deploy.PasswordProtectedAdapterCargo.redeployFile(PasswordProtectedAdapterCargo.java:95)
at hudson.plugins.deploy.DeployPublisher.perform(DeployPublisher.java:113)
at jenkins.tasks.SimpleBuildStep.perform(SimpleBuildStep.java:123)
at hudson.tasks.BuildStepCompatibilityLayer.perform(BuildStepCompatibilityLayer.java:80)
at hudson.tasks.BuildStepMonitor$3.perform(BuildStepMonitor.java:45)
at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:803)
at hudson.model.AbstractBuild$AbstractBuildExecution.performAllBuildSteps(AbstractBuild.java:752)
at hudson.model.Build$BuildExecution.post2(Build.java:177)
at hudson.model.AbstractBuild$AbstractBuildExecution.post(AbstractBuild.java:697)
at hudson.model.Run.execute(Run.java:1932)
at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
at hudson.model.ResourceController.execute(ResourceController.java:97)
at hudson.model.Executor.run(Executor.java:429)
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:710)
at org.codehaus.cargo.container.tomcat.internal.TomcatManager.list(TomcatManager.java:882)
at org.codehaus.cargo.container.tomcat.internal.TomcatManager.getStatus(TomcatManager.java:895)
at org.codehaus.cargo.container.tomcat.internal.AbstractTomcatManagerDeployer.redeploy(AbstractTomcatManagerDeployer.java:161)
... 19 more
Caused by: java.io.IOException: Server returned HTTP response code: 403 for URL: http://127.0.0.1:8080/manager/text/list
at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)
at org.codehaus.cargo.container.tomcat.internal.TomcatManager.invoke(TomcatManager.java:577)
... 22 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:710)
at org.codehaus.cargo.container.tomcat.internal.TomcatManager.list(TomcatManager.java:882)
at org.codehaus.cargo.container.tomcat.internal.TomcatManager.getStatus(TomcatManager.java:895)
at org.codehaus.cargo.container.tomcat.internal.AbstractTomcatManagerDeployer.redeploy(AbstractTomcatManagerDeployer.java:161)
at hudson.plugins.deploy.CargoContainerAdapter.deploy(CargoContainerAdapter.java:81)
at hudson.plugins.deploy.CargoContainerAdapter$DeployCallable.invoke(CargoContainerAdapter.java:167)
at hudson.plugins.deploy.CargoContainerAdapter$DeployCallable.invoke(CargoContainerAdapter.java:136)
at hudson.FilePath.act(FilePath.java:1164)
at hudson.FilePath.act(FilePath.java:1147)
at hudson.plugins.deploy.CargoContainerAdapter.redeployFile(CargoContainerAdapter.java:133)
at hudson.plugins.deploy.PasswordProtectedAdapterCargo.redeployFile(PasswordProtectedAdapterCargo.java:95)
at hudson.plugins.deploy.DeployPublisher.perform(DeployPublisher.java:113)
at jenkins.tasks.SimpleBuildStep.perform(SimpleBuildStep.java:123)
at hudson.tasks.BuildStepCompatibilityLayer.perform(BuildStepCompatibilityLayer.java:80)
at hudson.tasks.BuildStepMonitor$3.perform(BuildStepMonitor.java:45)
at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:803)
at hudson.model.AbstractBuild$AbstractBuildExecution.performAllBuildSteps(AbstractBuild.java:752)
at hudson.model.Build$BuildExecution.post2(Build.java:177)
at hudson.model.AbstractBuild$AbstractBuildExecution.post(AbstractBuild.java:697)
at hudson.model.Run.execute(Run.java:1932)
at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
at hudson.model.ResourceController.execute(ResourceController.java:97)
at hudson.model.Executor.run(Executor.java:429)
Caused by: java.io.IOException: Server returned HTTP response code: 403 for URL: http://127.0.0.1:8080/manager/text/list
at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)
다음은 정상적으로 동작할때 manager.xml 파일 설정 정보이다. 특정아이피 허용관련해서 설정이 진행중이다.
<Context privileged="true" antiResourceLocking="false" docBase="${catalina.home}/webapps/manager">
<Valve className="org.apache.catalina.valves.RemoteAddrValve" allow="192.168.120.100" />
</Context>
manager.xml 파일에 org.apache.catalina.valves.RemoteAddrValve 설정을 하였고, 기존IP에 또다른 IP를 추가하였고 위와 같은 오류가 발생되었다.
<Context privileged="true" antiResourceLocking="false" docBase="${catalina.home}/webapps/manager">
<Valve className="org.apache.catalina.valves.RemoteAddrValve" allow="192.168.120.100,192.168.120.36" />
</Context>
구글링을 통해 좀더 알아보니 아이피 추가시 구분자를 변경해보라는 내용이 있어 다음과 같이 “d+|” 구분자를 넣은 후 아파치 톰켓 서버를 재시작해보았으나 동일한 오류가 발생하였다.
<Context privileged="true" antiResourceLocking="false" docBase="${catalina.home}/webapps/manager">
<Valve className="org.apache.catalina.valves.RemoteAddrValve" allow="192.168.120.100d+|192.168.120.36" />
</Context>
오류 해결방법은 다음과 같다. 아이사이에 구분자 “|”만 넣고 큰따옴표로만 묶어주었다. 그런다음 다시 배포를 시도한결과 정상적으로 배포되었다.
<Context privileged="true" antiResourceLocking="false" docBase="${catalina.home}/webapps/manager">
<Valve className="org.apache.catalina.valves.RemoteAddrValve"
llow="192.168.120.100|192.168.120.36" />
</Context>
Remote_Address_Valve 가이드
https://tomcat.apache.org/tomcat-9.0-doc/config/valve.html#Remote_Address_Valve
[REFERENCE]
- https://sarc.io/index.php/tomcat/25-tomcat
- https://stackoverflow.com/questions/41675813/the-username-you-provided-is-not-allowed-to-use-the-text-based-tomcat-manager-e