Can't get Jenkins to start using Tomcat

2020-08-12 17:56发布

问题:

I'm having a problem trying to deploy Jenkins war to Tomcat. I'm using CentOS with Java 1.6.0_28, Tomcat 6.0.24 and last version of jenkins as of January 21, 2014.

I think the problem is more related to Jenkins because of the log but not sure. When I google the error only find the classes that fire the exception but no solution. Here is the log. Any help is appreciated.

Jan 21, 2014 9:30:26 PM hudson.util.BootFailure publish
SEVERE: Failed to initialize Jenkins
hudson.util.NoHomeDir
    at hudson.WebAppMain.contextInitialized(WebAppMain.java:126)
    at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3972)
    at org.apache.catalina.core.StandardContext.start(StandardContext.java:4467)
    at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:791)
    at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:771)
    at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:526)
    at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:905)
    at org.apache.catalina.startup.HostConfig.deployWARs(HostConfig.java:740)
    at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:500)
    at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1277)
    at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:321)
    at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
    at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053)
    at org.apache.catalina.core.StandardHost.start(StandardHost.java:722)
    at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
    at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
    at org.apache.catalina.core.StandardService.start(StandardService.java:516)
    at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
    at org.apache.catalina.startup.Catalina.start(Catalina.java:593)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:622)
    at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289)
    at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)

回答1:

Jenkins tries to create /usr/share/tomcat7/.jenkins to store its data, but the directory isnt created, so it throws NoHome Exception.

To fix this, create the .jenkins manually (with correct own/grp permissions to tomcat) and restart tomcat.



回答2:

I was facing exactly the same problem. In my case it all started with a Jenkins/Git error:

"error: could not lock config file /usr/share/tomcat6/.gitconfig: Permission denied".

Apparently all permissions were OK and .gitconfig was not locked. I've executed a chown for tomcat user and everything was just fine again after a service restart:

sudo chown -R tomcat6:tomcat6 /var/lib/tomcat6/
sudo chown -R tomcat6:tomcat6 /etc/tomcat6/
sudo chown -R tomcat6:tomcat6 /usr/share/tomcat6/

(My Linux is Debian based)



回答3:

I am not sure what user you are running tomcat as, but it looks like jenkins can't create it's home directory. Look into the JENKINS_HOME parameter.



回答4:

Try to inspect some directories like /var/lib/ to detect if the permissions are correctly made, maybe it's a "denied permission" that block the creation of jenkins home on "/var/lib/jenkins"



回答5:

Finally I had to go through the hard way. I got ride of the Tomcat6 package from repo and reinstalled manually. It solved the problem. I really hate when Linux "official" packages don't work.

Thanks anyway.



回答6:

Check which is the user running tomcat. And check which is the home directory of that user in /etc/passwd The home folder is probably missing. Create the folder and give ownership to the running tomcat user



回答7:

Jenkins Configuration Issue

I was trying to setup Jenkins web app inside the Tomcat server and it continuously gave me this error:

SEVERE: Failed to initialize Jenkins hudson.util.NoHomeDir

This I fixed by creating the folder as follows:

mkdir /usr/share/tomcat7/.jenkins

On redeploying Jenkins I again noticed the following error:

WARNING: Failed to record boot attempts java.io.FileNotFoundException: /usr/share/tomcat7/.jenkins/failed-boot-attempts.txt (Permission denied)

I fixed this issue by giving full access to this folder.

sudo chmod 777 /usr/share/tomcat7/.jenkins

I believe 777 is not a good approach in a production environment, but for development perspective it looks ok.

Credits to: http://www.cyberaka.com/?p=422