Tomcat startup script not working when invoked from jenkins - bash

There are two tomcat instances. One for jenkins(tomcat8-jenkins) and one for the application(tomcat-mc). They are in the same server.
When I execute the shell script in build setup from jenkins it seems like the jenkins is trying to start it's own tomcat instance. following is the script and the error.
cd $TOMCAT_PATH/bin
./shutdown.sh
./startup.sh
ERROR
+ cd /usr/local/tomcat-mc/bin
+ ./shutdown.sh
java.lang.ClassNotFoundException: org.apache.catalina.startup.Catalina
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at org.apache.catalina.startup.Bootstrap.init(Bootstrap.java:216)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:391)
+ ./startup.sh
PID file (/usr/local/tomcat8-jenkins/logs/tomcat.pid) found. Is Tomcat still running? Start aborted.
Build step 'Execute shell' marked build as failure
Finished: FAILURE
I've tried unsettling BUILD_ID= and changing CATALINA_HOME=$TOMCAT_PATH . But still the error comes.

This might be helpful to you..
https://stackoverflow.com/a/28938556/4595123

The reason here was jenkins tomcat has set the CATALINA_BASE. After resetting that to desired tomcat base issue was resolved. Hope it may help somebody in need.
In my case added this to build shell script in jenkins which overides the jenkins tomcat CATALINA_BASE
export CATALINA_BASE=/usr/local/tomcat-mc

Related

Jenkins container: Groovy script fails with jbdc exception

I have a job in Jenkins (Jenkins is running from a container) which uses a groovy script with the line:
import groovy.sql.Sql;
def driver = "oracle.jdbc.pool.OracleDataSource"
when running it, I'm getting the exception:
java.lang.ClassNotFoundException: oracle.jdbc.pool.OracleDataSource
I know what is the root cause, but don't know how to fix it.
The root cause is that all our Jenkins containers are installed without Oracle, and ojdbc7.jar can be found in the java classpath under Oracle:
classpath /oravl01/oracle/12.1.0.1/jdbc/lib/ojdbc7.jar
in regular Jenkins server, it runs without any issues.
any idea how to fix it?
I did 2 things:
1. copied the file ojdbc7.jar to the path mentioned in java.ext.dirs (in illinXXX:XXX/systemInfo)
2. Ran the docker run command with --env classpath=[path of ojdbc7-12.1.0.2.jar]

Jenkins tomcat7 deploying error

I have a jenkins job named 'SampleMavenDeploy1' which copies artifacts(war file,pom.xml) from upstream project('SampleMavenBuild1') successfully to this project.
I have following configuration for this project:
"
Build Steps:
Copy artifacts from another project
Project Name:SampleMavenBuild1
Post-build Actions:
War/Ear files:MavenWebAppV14/target/*.war
Context Path:webapps
Containers:
Tomcat7.x
Manager username:tomcat
Manager Password:tomcat
Tomcat Url:http://localhost:8080/manager/text
"
The build of SampleMavenBuild1(make war file of a maven project) has succeeded. In workspace of this job (SampleMavenDeploy1), there is war file (MavenWebAppV14/target/MavenWebAppV14.war). I have also configured tomcat-users.xml to add user of username 'tomcat' , password 'tomcat' and roles as 'manager-gui' and 'manager-script' .
I am facing following errors in a jenkins build of a job. This job is designed for deploying war file on tomcat7 via CI server. I have also 'deploy to tomcat' plugin installed in jenkins.
Started by user vikas
Building in workspace C:\Users\vikachou\.jenkins\jobs\SampleMavenDeploy1\workspace
Copied 2 artifacts from "SampleMavenBuild1" build number 4
Deploying C:\Users\vikachou\.jenkins\jobs\SampleMavenDeploy1\workspace\MavenWebAppV14\target\MavenWebAppV14.war to container Tomcat 7.x Remote
ERROR: Publisher hudson.plugins.deploy.DeployPublisher aborted due to exception
org.codehaus.cargo.container.ContainerException: Failed to redeploy [C:\Users\vikachou\.jenkins\jobs\SampleMavenDeploy1\workspace\MavenWebAppV14\target\MavenWebAppV14.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:918)
at hudson.FilePath.act(FilePath.java:896)
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:770)
at hudson.model.AbstractBuild$AbstractBuildExecution.performAllBuildSteps(AbstractBuild.java:734)
at hudson.model.Build$BuildExecution.post2(Build.java:183)
at hudson.model.AbstractBuild$AbstractBuildExecution.post(AbstractBuild.java:683)
at hudson.model.Run.execute(Run.java:1770)
at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
at hudson.model.ResourceController.execute(ResourceController.java:89)
at hudson.model.Executor.run(Executor.java:240)
Caused by: org.codehaus.cargo.container.tomcat.internal.TomcatManagerException: FAIL - Unknown command /manager/text/list
at org.codehaus.cargo.container.tomcat.internal.TomcatManager.invoke(TomcatManager.java:566)
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
org.codehaus.cargo.container.tomcat.internal.TomcatManagerException: FAIL - Unknown command /manager/text/list
at org.codehaus.cargo.container.tomcat.internal.TomcatManager.invoke(TomcatManager.java:566)
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:918)
at hudson.FilePath.act(FilePath.java:896)
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:770)
at hudson.model.AbstractBuild$AbstractBuildExecution.performAllBuildSteps(AbstractBuild.java:734)
at hudson.model.Build$BuildExecution.post2(Build.java:183)
at hudson.model.AbstractBuild$AbstractBuildExecution.post(AbstractBuild.java:683)
at hudson.model.Run.execute(Run.java:1770)
at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
at hudson.model.ResourceController.execute(ResourceController.java:89)
at hudson.model.Executor.run(Executor.java:240)
Finished: FAILURE
Anyone who can figure out is most welcomed .
Thanks in advance!!!
You need to give permissions to the text-manager to be able to deploy.
Just go to tomcat-users.xml and add this:
<user username="tomcat" password="password" roles="manager-script"/>
Or just give the manager-script permission to your existing tomcat-manager user
You need to set the base URL to localhost:8080/ in the deploy URL, not the manager URL which is localhost:8080/manager/text (which is what happened in my case).
I have the same problem as you. But I had the tomcat users refresh like the first answer of this question and the problem still persists on Jenkins.
When I tried to connect to tomcat admin zone using my navigator, tomcat didn't display the page to me, because the tomcat-admin package was not installed. So I've installed the tomcat7-admin package and restarted tomcat :
sudo apt-get install tomcat7-admin
sudo service tomcat7 restart
Then the problem was fixed. It was because Jenkins couldn't connect with the program. So easy!
All you have to do is add the users and and assign the manager-gui (for GUI access) and manager-script (for access like Jenkins deployment ). Also, make sure to edit the file /webapps/manager/META-INF/context.xml, either to comment out valve or define appropriate reg ex for allow attribute
If it shows a connection error or fails to load when you deploy jenkins.war file on tomcat, then follow the steps below.
Paste the jenkins folder inside tomcat/webapps.
Restart the tomcat (localhost or ip:8080/jenkins)
Jenkins will load and may asks for password.
To get the jenkins admin password then run
{cat /opt/tomcat/.jenkins/secrets/initialAdminPassword}
If the permission is denied to access the password then
sudo chmod 0777 /opt/tomcat/.jenkins/secrets/initialAdminPassword
or else run ls -a there you will see .jenkins folder.

Jenkins Plugin with proxy

I am have a Jenkins CI with the following configuration:
Tomcat on Open SUSE [openSUSE 13.1 (x86_64)] [Jenkins v1.532.3]
Java version "1.7.0_51" [OpenJDK Runtime Environment (IcedTea 2.4.4) (suse-24.13.5-x86_64)].
I am positive that I have my proxy configured correctly. But when I try to download a plugin or update a plugin on Jenkins. I get this error
Git Client Plugin
Failure -
hudson.util.IOException2: Failed to download from http://updates.jenkins-ci.org/download/plugins/git-client/1.8.1/git-client.hpi
at hudson.model.UpdateCenter$UpdateCenterConfiguration.download(UpdateCenter.java:794)
.
.
Caused by: java.net.ProtocolException: Server redirected too many times (20)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
.
.
.
at hudson.model.UpdateCenter$UpdateCenterConfiguration.download(UpdateCenter.java:764)
... 7 more
Caused by: java.net.ProtocolException: Server redirected too many times (20)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1636)
But I am able to do a Curl or a wget to the actual URL/URI to download the plugin
Thanks for your help and feedback
I don't think, that this is still relevant, but may be could help to someone else..
I had a similar issue after I changed my password. I checked different proxies and each time had the same issue. Now that I have changed the password again to have more standard symbols, the issues is immediately gone.
So it seems, that sometimes there can be just some problem with some special characters in the password.
Hope that could help someone.
Best Regards,
Viacheslav

Unable to delete pom.xml in Jenkins under Tomcat/Windows

I've been struggling with an annoying "Jenkins/Tomcat/Windows" problem for a while now without reaching any solution.
I've installed Tomcat version 7.0.25 in a Windows 7 Enterprise machine and Jenkins 1.451 as a webapplication
running under Tomcat. I have just 4 jobs configured right now and all of then are using the "Always chekout a fresh copy" checkout strategy,
so everytime a job runs the content in /jobs//workspace gets deleted. But, there are situations in which the job fails to run because
it is unable to delete the /jobs//workspace/pom.xml file like you can see in this (edited) stacktrace:
Building in workspace C:\.hudson\jobs\<task name>\workspace
Cleaning local Directory .
java.io.IOException: Unable to delete C:\.hudson\jobs\<task name>\workspace\.\pom.xml
at hudson.Util.deleteFile(Util.java:237)
at hudson.Util.deleteRecursive(Util.java:287)
at hudson.Util.deleteContentsRecursive(Util.java:198)
at hudson.scm.subversion.CheckoutUpdater$1.perform(CheckoutUpdater.java:73)
at hudson.scm.subversion.WorkspaceUpdater$UpdateTask.delegateTo(WorkspaceUpdater.java:136)
at hudson.scm.SubversionSCM$CheckOutTask.perform(SubversionSCM.java:780)
at hudson.scm.SubversionSCM$CheckOutTask.invoke(SubversionSCM.java:761)
at hudson.scm.SubversionSCM$CheckOutTask.invoke(SubversionSCM.java:745)
at hudson.FilePath.act(FilePath.java:788)
at hudson.FilePath.act(FilePath.java:770)
at hudson.scm.SubversionSCM.checkout(SubversionSCM.java:735)
at hudson.scm.SubversionSCM.checkout(SubversionSCM.java:677)
at hudson.model.AbstractProject.checkout(AbstractProject.java:1195)
at hudson.model.AbstractBuild$AbstractRunner.checkout(AbstractBuild.java:576)
at hudson.model.AbstractBuild$AbstractRunner.run(AbstractBuild.java:465)
at hudson.model.Run.run(Run.java:1409)
at hudson.maven.MavenModuleSetBuild.run(MavenModuleSetBuild.java:481)
at hudson.model.ResourceController.execute(ResourceController.java:88)
at hudson.model.Executor.run(Executor.java:238)
Retrying after 10 seconds
Here you can see Tomcat locking the file as I told:
After some time Jenkins/Tomcat releases the lock on the pom.xml and i can execute the job again without any problem.
Does anyone know how to get around this ? Am i missing something ? Thanks in advance!
I changed to Windows Service installation, and the pom.xml never gets locked anymore.
Seems that this caused by Tomcat that somehow locks the pom.xml, although the build has finished.

javax.security.auth.login.LoginException: Login failed

I'm trying to run a hadoop job (version 18.3) on my windows machine but I get the following error:
Caused by: javax.security.auth.login.LoginException: Login failed: CreateProcess: bash -c groups error=2
at org.apache.hadoop.security.UnixUserGroupInformation.login(UnixUserGroupInformation.java:250)
at org.apache.hadoop.security.UnixUserGroupInformation.login(UnixUserGroupInformation.java:275)
at org.apache.hadoop.mapred.JobClient.configureCommandLineOptions(JobClient.java:557)
... 3 more
The same job works fine in an another windows machine. Do I have may be something wrong in the settings variabls? How can I fix this problem?
Maybe bash is not available on your PATH?
Do you have Cygwin installed correctly?
I really like this tutorial by Vlad Korolev to set up Hadoop on Windows.

Resources