Jenkins - j_acegi_security_check

AuthenticationTomcatContinuous IntegrationInstallationJenkins

Authentication Problem Overview


I am trying to setup jenkins, but I cant get the authentication to work. I am running jenkins on Tomcat6 on CentOS 6.2. I enable logging in, and everything goes fine until I try to log in. After giving my credential and pressing login, tomcat gives me a error:

"HTTP Status 404 - The requested resource () is not available." on http://myserver:8080/jenkins/j_acegi_security_check

By googling I can find this: [https://issues.jenkins-ci.org/browse/JENKINS-3761][1]

Two suggested fixes I have found:

  • Run jenkins on tomcat instead of running the standalone version - I am already doing so.
  • Edit a file: WEB-INF/security/SecurityFilters.groovy - I tried to edit, but I can't get it to change anything

Is there something I could do to make this work?

[1]: https://issues.jenkins-ci.org/browse/JENKINS-3761 "Jenkins Issue tracker"

Authentication Solutions


Solution 1 - Authentication

Spent ages wrestling with this one, make sure a Security Realm is set when you are choosing your Authorization method in Jenkins.

That is, in Manage Jenkins → Configure Global Security select an option in the Security Realm list.

For example:

enter image description here

Solution 2 - Authentication

You may have forgotten to select a Security Realm as specified below

<https://wiki.jenkins-ci.org/display/JENKINS/Standard+Security+Setup>

In case you have locked yourself out, you can revert the Jenkins config.xml file to set <useSecurity>true</useSecurity> node value to false by following instructions here

<https://wiki.jenkins-ci.org/display/JENKINS/Disable+security>

Solution 3 - Authentication

As mentioned on the bug page:

> The error was caused by a proxy pass rule "/jenkins http://localhost:9080/jenkins/" which led to the incomming (jenkins) request "/jenkins//j_acegi_security_check" (double //). So the login page was rejected with 404 (while all other pages where served).

Make sure your /jenkins ProxyPass does not end with a trailing slash in the destination URL.

Solution 4 - Authentication

I was facing the same issue on Ubuntu as well as on AIX, where I desperately needed it to work in production settings. I even tried Tomcat and Apache web servers, still the same issue.

Finally changing the class loader as follows made it work in stand-alone mode:

java -jar jenkins.war --httpPort=79802 --preferredClassLoader=java.net.URLClassLoader & 

By the way, this is default settings in standard Jenkins distribution for Ubuntu, from where I got the clue.

Probably the issue is related with packaging, but for now this solution works. Check if this resolves similar issues.

Solution 5 - Authentication

I had the same HTTP 404 on the "/jenkins/j_acegi_security_check" URI problem .

And the same issue as pointed out by pga above: Tomcat was being started as user root.

This was because I had setup tomcat to restart automatically by creating a startup tomcat script at "/etc/init.d/".

Fixed the issue with:

su - tomcatuser - c /cde/pkgs/../tomcat/start.sh

Solution 6 - Authentication

I had the same problem with 404 on the "/jenkins/j_acegi_security_check" page.

Using Jenkins with Tomcat, after a lot of tries to solve it, I came to following solution - I´m using 18080 as default port without SSL-redirection. It´s related to the redirection, but in that case (as using Tomcat) it has to be changed in the tomcat-server-configuration:

Look in /conf/server.xml for the following entry:

<Connector port="18080" protocol="HTTP/1.1"
    connectionTimeout="20000"
    redirectPort="8443" /> 

Just commenting out the redirectPort helped for me:

<Connector port="18080" protocol="HTTP/1.1"
    connectionTimeout="20000" />

Solution 7 - Authentication

My bookmarked jenkins login url was: https://jenkins.foo.com/login?from=%2F

If security is disabled and you hit that url with any credentials or blank ones, it brings up the j_acegi error.

Instead, use https://jenkins.foo.com/ and it will take you straight to the dashboard.

Solution 8 - Authentication

I had the same HTTP 404 on the "/jenkins/j_acegi_security_check" URI.

In my case, Jenkins was running on a Tomcat started by user 'root'. Stopped Tomcat, and started it again by the proper separate application user. Problem solved.

Solution 9 - Authentication

Seeing vote down: I did the steps again on fresh server. There were ** characters and I removed that

There were missing $sign for tomcat like this $TOMCAT_VERSION (Both corrected and it is working) (updated on 28.03.2016)

Disable the security as given below:

http://markunsworth.com/2012/02/13/locked-yourself-out-of-jenkins/

Unable to login jenkins, and can't disable login option either Or Locked in login with Jenkins on Tomcat.

http://xx.xxx.xxx.xxx:8080/jenkins/login?from=/jenkins/ and after filling the userId Password, which was not set up at all, will always take to this page

http://xx.xxx.xxx.xxx:8080/jenkins/j_acegi_security_check

HTTP Status 404 - description The requested resource is not available.

I had .war file installed in tomcat It took me long to fix this issue. I had many times completely removed Tomcat, Jenkins all folders .jenkins etc reinstalled and what not...

Remove both Tomcat and Jenkins completely once again...

The solution is proper use of user and group, let us see how to it by running the following commands one by one.

You are logged in with user(e.g. vimal) with sudo permission.

 vimal@h123:~$ sudo apt-get update
 vimal@h123:~$ BASE_USER=vimal
 vimal@h123:~$ sudo chown -Rf $BASE_USER:$BASE_USER /opt/
 
 vimal@h123:~$ USER=apache-tomcat
 vimal@h123:~$ GROUP=myjenkins
 vimal@h123:~$ TOMCAT_INSTALL_DIR=/opt
 vimal@h123:~$ TOMCAT_VERSION=apache-tomcat-8.0.23
 vimal@h123:~$ TOMCAT_URL=http://archive.apache.org/dist/tomcat/tomcat-8/v8.0.23/bin/apache-tomcat-8.0.23.zip

For TOMCAT_URL, copy the link that you need from archive/src (.zip) of tomcat download site

vimal@h123:~$ mkdir -p $TOMCAT_INSTALL_DIR
vimal@h123:~$ cd $TOMCAT_INSTALL_DIR
vimal@h123:~$ wget $TOMCAT_URL
vimal@h123:~$ unzip -q $TOMCAT_VERSION.zip
vimal@h123:~$ rm $TOMCAT_VERSION.zip

Before running command below you need to have JAVA_HOME set up in like JAVA_HOME="/usr/lib/jvm/java-8-oracle/" by adding this into sudo nano /etc/environment

vimal@h123:~$ sudo chmod +x  $TOMCAT_INSTALL_DIR/$TOMCAT_VERSION/bin/*.sh
vimal@h123:~$ $TOMCAT_INSTALL_DIR/$TOMCAT_VERSION/bin/catalina.sh start
vimal@h123:~$
vimal@h123:~$ cd $TOMCAT_INSTALL_DIR/$TOMCAT_VERSION/webapps/
vimal@h123:~$ wget http://mirrors.jenkins-ci.org/war-stable/latest/jenkins.war

Wait for a couple of minutes till Jenkins is fully loaded. Needs 2GB memory. Try going to the browser on http://xx.xxx.xxx.xxx:8080/jenkins/ and it will work...

Took me one day to find the solution.

Solution 10 - Authentication

Here is how I resolved this issue:

# service tomcat status
tomcat start/running, process 996

# service tomcat stop
tomcat stop/waiting

# service jenkins status
Jenkins Continuous Integration Server is not running

# service jenkins restart
 * Restarting Jenkins Continuous Integration Server jenkins                [ OK ]
# service tomcat start
tomcat start/running, process 3839

# service jenkins status
Jenkins Continuous Integration Server is running with the pid 3694

Refresh your browser and Jenkins should be up and running. Hope this helps!

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionvaresaView Question on Stackoverflow
Solution 1 - AuthenticationOliView Answer on Stackoverflow
Solution 2 - AuthenticationRansomView Answer on Stackoverflow
Solution 3 - AuthenticationjevonView Answer on Stackoverflow
Solution 4 - AuthenticationSohel KhanView Answer on Stackoverflow
Solution 5 - AuthenticationTaherView Answer on Stackoverflow
Solution 6 - AuthenticationOliver DomeischelView Answer on Stackoverflow
Solution 7 - AuthenticationJim NathlichView Answer on Stackoverflow
Solution 8 - AuthenticationpgaView Answer on Stackoverflow
Solution 9 - Authenticationvimal krishnaView Answer on Stackoverflow
Solution 10 - AuthenticationDayo UdianiView Answer on Stackoverflow