Building cas-server with mysql as a backend

176 views
Skip to first unread message

Bricoleur

unread,
Nov 18, 2014, 5:35:32 PM11/18/14
to jasig-c...@googlegroups.com
Hello,

I am attempting to get cas-server set up to use mysql as a backend. I have Tomcat running successfully, Maven installed, downloaded the mysql-connector and am now trying to build the .war file this way: 'mvn package install'. This is the result:

[ERROR] Failed to execute goal on project cas-server-webapp: Could not resolve dependencies for project org.jasig.cas:cas-server-webapp:war:4.0.0: Failure to find mysql:mysql-connector-java:jar:5.1.9-bin in http://developer.ja-sig.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of jasig-repository has elapsed or updates are forced -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/DependencyResolutionException
[ERROR]
[ERROR] After correcting the problems, you can resume the build with the command
[ERROR]   mvn <goals> -rf :cas-server-webapp


I would appreciate any help with this. I can post my pom.xml file or whatever else might be useful.

Many thanks.

Andy Turner

unread,
Jan 6, 2015, 5:35:23 PM1/6/15
to cas-...@lists.jasig.org
same problem, wasted a week googling and trying things, no solution.
-- 
You are currently subscribed to cas-...@lists.jasig.org as: cas-user-ga...@googlegroups.com
To unsubscribe, change settings or access archives, see http://www.ja-sig.org/wiki/display/JSG/cas-user

Misagh Moayyed

unread,
Jan 6, 2015, 6:35:07 PM1/6/15
to cas-...@lists.jasig.org
Can you paste the part in your pom.xml that references the mysql connector dependency?

-- 
You are currently subscribed to cas-...@lists.jasig.org as: mmoa...@unicon.net
To unsubscribe, change settings or access archives, see http://www.ja-sig.org/wiki/display/JSG/cas-user

-- 
You are currently subscribed to cas-...@lists.jasig.org as: jasig-cas-user...@googlegroups.com

Chris Adams

unread,
Jan 6, 2015, 7:11:53 PM1/6/15
to cas-...@lists.jasig.org

Andy,

 

I just saw your message. I don’t claim to know much here, as I am slogging my through this on my own, but here is the part of my setup that got me on the road to authenticating with mysql. I believe that the original out of the box war that I used already had the mysql connector included, so no build necessary.

 

The relevant part of my deployerConfigContext.xml is here:

 

<!--

        Adding the JDBC authentication related configuration

        -->

        <bean id="primaryAuthenticationHandler" class="org.jasig.cas.adaptors.jdbc.SearchModeSearchDatabaseAuthenticationHandler"

         abstract="false" lazy-init="default" autowire="default" >

                <property name="tableUsers"><value>main</value></property>

                <property name="fieldUser"><value>userid</value></property>

                <property name="fieldPassword"><value>ssn</value></property>

                <!--<property name="passwordEncoder" ref="defaultPasswordEncoder"/>-->

                <property name="dataSource" ref="dataSource"/>

        </bean>

 

        <!-- Data source definition -->

          <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource">

                <property name="driverClassName">

                  <value>com.mysql.jdbc.Driver</value>

                </property>

                <property name="url">

                  <value>jdbc:mysql://address.of.mysqlserver:3306/mydatabasename</value>

                </property>

                <property name="username"><value>mysqlrootusername</value></property>

                <property name="password"><value>mysqlrootuserpassword</value></property>

          </bean>

 

 

Regards,

 

Christopher Adams

You are currently subscribed to cas-...@lists.jasig.org as: chris....@state.or.us
To unsubscribe, change settings or access archives, see http://www.ja-sig.org/wiki/display/JSG/cas-user
-- 
You are currently subscribed to cas-...@lists.jasig.org as: jasig-cas-user...@googlegroups.com

Andy Turner

unread,
Jan 7, 2015, 3:09:57 PM1/7/15
to cas-...@lists.jasig.org
hi, the pom.xml is here, i can't get maven to "find" the jars that it downloads, so i can't do "build clean package" because it keeps failing, but if i do "build clean package -DskipTests=true, it builds the war file, but i get error 404 when navigating to /cas/login in the browser.   The jars are in the right place pulled down by the dependencies /cas/target/WEB-INF/lib i think.    I think my classpath isn't right, i don't know what it is supposed to be set to.   I'm on centos, with ~/.bash_profile having an entry for classpath=/usr/lib/jvm/<jdk version for java 7>/jre/lib/ext/ <all the jars maven pulled down>


POM.XML
<!--
~ Licensed to Apereo under one or more contributor license ~ agreements. See the NOTICE file distributed with this work ~ for additional information regarding copyright ownership. ~ Apereo licenses this file to you under the Apache License, ~ Version 2.0 (the "License"); you may not use this file ~ except in compliance with the License. You may obtain a ~ copy of the License at the following location: ~ ~ http://www.apache.org/licenses/LICENSE-2.0 ~ ~ Unless required by applicable law or agreed to in writing, ~ software distributed under the License is distributed on an ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY ~ KIND, either express or implied. See the License for the ~ specific language governing permissions and limitations ~ under the License.
-->
<parent>
<groupId>org.jasig.cas</groupId>
<artifactId>cas-server</artifactId>
<version>4.1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>cas-server-webapp</artifactId>
<packaging>war</packaging>
<name>Apereo CAS Web Application</name>
<dependencies>
<dependency>
<groupId>org.jasig.cas</groupId>
<artifactId>cas-server-webapp-support</artifactId>
<version>${project.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-expression</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<type>jar</type>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>taglibs</groupId>
<artifactId>standard</artifactId>
<version>1.1.2</version>
<type>jar</type>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.jasig.cas</groupId>
<artifactId>cas-server-security-filter</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.jasig.cas</groupId>
<artifactId>cas-server-core</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-orm</artifactId>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.apache.shiro</groupId>
<artifactId>shiro-core</artifactId>
<scope>compile</scope>
</dependency>
<!-- Test Dependencies -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-validator</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.hsqldb</groupId>
<artifactId>hsqldb</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.webflow</groupId>
<artifactId>spring-webflow</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jasig.cas</groupId>
<artifactId>cas-server-core</artifactId>
<version>${project.version}</version>
<type>test-jar</type>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<warName>cas</warName>
<webResources>
<resource>
<directory>${basedir}/src/main/webapp/WEB-INF</directory>
<filtering>true</filtering>
<targetPath>WEB-INF</targetPath>
<includes>
<include>**/web.xml</include>
</includes>
</resource>
</webResources>
</configuration>
</plugin>
</plugins>
</build>
<properties>
<cs.dir>${project.parent.basedir}</cs.dir>
</properties>
</project>

-- 
You are currently subscribed to cas-...@lists.jasig.org as: andy....@mail.ic.edu
To unsubscribe, change settings or access archives, see http://www.ja-sig.org/wiki/display/JSG/cas-user




--
Respectfully,
Andy Turner '05
Education Technologist
Illinois College 
Crispin Hall 302
1101 W. College Ave.
Jacksonville, IL 62650

Please email help...@ic.edu to generate a work order.  We are happy to help!

"An ocean refuses no river."- Sheila Chandra



Chris Adams

unread,
Jan 7, 2015, 3:17:46 PM1/7/15
to cas-...@lists.jasig.org

Andy,

 

If it helps, here is the section in my pom.xml that indicates the mysql dependency:

 

<dependency>

      <groupId>commons-dbcp</groupId>

      <artifactId>commons-dbcp</artifactId>

      <version>1.4</version>

      <scope>runtime</scope>

    </dependency>

    <dependency>

      <groupId>mysql</groupId>

      <artifactId>mysql-connector-java</artifactId>

      <version>5.1.13</version>

      <scope>runtime</scope>

    </dependency>

 

From: Andy Turner [mailto:andy....@mail.ic.edu]
Sent: Wednesday, January 07, 2015 12:09 PM
To: cas-...@lists.jasig.org
Subject: Re: [cas-user] Building cas-server with mysql as a backend

 

hi, the pom.xml is here, i can't get maven to "find" the jars that it downloads, so i can't do "build clean package" because it keeps failing, but if i do "build clean package -DskipTests=true, it builds the war file, but i get error 404 when navigating to /cas/login in the browser.   The jars are in the right place pulled down by the dependencies /cas/target/WEB-INF/lib i think.    I think my classpath isn't right, i don't know what it is supposed to be set to.   I'm on centos, with ~/.bash_profile having an entry for classpath=/usr/lib/jvm/<jdk version for java 7>/jre/lib/ext/ <all the jars maven pulled down>

You are currently subscribed to cas-...@lists.jasig.org as: chris....@state.or.us
To unsubscribe, change settings or access archives, see http://www.ja-sig.org/wiki/display/JSG/cas-user
-- 
You are currently subscribed to cas-...@lists.jasig.org as: jasig-cas-user...@googlegroups.com

Andy Turner

unread,
Jan 7, 2015, 4:00:42 PM1/7/15
to cas-...@lists.jasig.org
Thanks Chris.  I updated pom.xml with your dependencies but "mvn clean package" won't build successfully, and if i do "mvn clean package -DskipTests=true" it builds cas.war and when i deploy it to tomcat (and copy all the jars to tomcat's classpath (directory) i still get error 404 at https://localhost:443/cas/login

No idea.

Chris Adams

unread,
Jan 7, 2015, 4:30:23 PM1/7/15
to cas-...@lists.jasig.org

Andy,

 

It seems that I had the same problem when I was first trying to build a war using the maven overlay. I was trying to build from source instead of letting maven pull in the dependencies as needed. I still have not completely wrapped my head around it, but I am making small steps in one direction now. :>)

 

I utilized this:  https://github.com/UniconLabs/simple-cas4-overlay-template

 

Create a directory and copy the template data and build from there using ‘mvn clean package’.

 

Then move your war file to the /tomcat/webapps directory. You can then add the mysql authentication information as I mentioned in a previous post.

 

Regards,

 

Chris

Andy Turner

unread,
Jan 7, 2015, 4:31:51 PM1/7/15
to cas-...@lists.jasig.org

Chris,
Thanks a lot! I will try it.

sent via mobile
- please email help...@ic.edu to generate a work order
my availability: http://www.google.com/calendar/embed?src=andy.turner%40mail.ic.edu&ctz=America/Chicago
   

Andy Turner

unread,
Jan 7, 2015, 5:14:46 PM1/7/15
to cas-...@lists.jasig.org
Chris,
I tried it, updated pom.xml and deployerConfigContext.xml in the resulting deployed cas.war and still get http status 404.    Any ideas at all would be greatly appreciated.

Chris Adams

unread,
Jan 7, 2015, 6:24:08 PM1/7/15
to cas-...@lists.jasig.org

Have you done this?  Create a /etc/cas directory and copy the two files to it. Then restart Tomcat. I found evidence of a problem in the tomcat logs and then realized that, other than modifying paths in the code, this was the easiest way to just get it done. Hope this helps.

 

If that is not the problem, do check the logs for some other reason that the page is not being found.

 

Make sure that your URL has the actual name of the deployed war, like https://myserfer.com:8443/cas, where cas.war is the deployed war file.

 

The etc directory contains the sample configuration files that would need to be copied to an external file system location (/etc/cas by default) and configured to satisfy local CAS installation needs. Current files are:

  • cas.properties
  • log4j.xml

Andy Turner

unread,
Jan 8, 2015, 10:57:30 AM1/8/15
to cas-...@lists.jasig.org
Chris,
Yes, i discovered that path issue with log4j.xml (i corrected the path in cas.properties to the right path), and cas.properties location (in spring-configuration/propertyConfigWhatever.xml to the right path) from the logs so that is not the issue. 
I do however have an issue that has been here since the beginning of this 2 weeks ago, the jars cannot be found is what i think, i have the classpath set correctly i think, who knows what it is supposed to be set to.   I have tried 2 different windows servers, ubuntu, and centos (so blaming the OS is no longer viable, lol).   Here is the error from the tomcat log (below), but first, the output of mvn -version, java -version, echo $JAVA_HOME, and echo $CLASSPATH, beneath that is the error from the tomcat log:
[root@localhost lib]# mvn -version
Apache Maven 3.2.5 (12a6b3acb947671f09b81f49094c53f426d8cea1; 2014-12-14T11:29:23-06:00)
Maven home: /opt/maven
Java version: 1.7.0_65, vendor: Oracle Corporation
Java home: /usr/lib/jvm/java-1.7.0-openjdk-1.7.0.65/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "2.6.32-504.el6.i686", arch: "i386", family: "unix"


[root@localhost lib]# java -version
java version "1.7.0_65"
OpenJDK Runtime Environment (rhel-2.5.1.2.el6_5-i386 u65-b17)
OpenJDK Client VM (build 24.65-b04, mixed mode, sharing)


[root@localhost lib]# java -version
java version "1.7.0_65"
OpenJDK Runtime Environment (rhel-2.5.1.2.el6_5-i386 u65-b17)
OpenJDK Client VM (build 24.65-b04, mixed mode, sharing)

[root@localhost lib]# echo $JAVA_HOME
/usr/lib/jvm/java-1.7.0-openjdk-1.7.0.65

when i echo classpath nothing is output, and i don't know why, it had output yesterday with no change, that keeps happening.

Here is the relevant content of /etc/profile.d/java.sh:
export JRE_HOME=/usr/lib/jvm/java-1.7.0-openjdk-1.7.0.65/jre
export PATH=$PATH:$JRE_HOME/bin

export JAVA_HOME=/usr/lib/jvm/java-1.7.0-openjdk-1.7.0.65
export JAVA_PATH=$JAVA_HOME

export PATH=$PATH:$JAVA_HOME/bin

export CLASSPATH=/usr/lib/jvm/java-1.7.0-openjdk-1.7.0.65/jre/lib/ext

M2_HOME=/opt/maven
M2=$M2_HOME/bin
MAVEN_OPTS=-Xms256m-Xmx512m

export PATH=$M2:$PATH


here is the content of /etc/profile

PATH=$PATH:$HOME/bin
export PATH
export JAVA_HOME=/usr/lib/jvm/java-1.7.0-openjdk-1.7.0.65

export PATH=/usr/lib/jvm/java-1.7.0-openjdk-1.7.0.65/bin:$PATH
export CLASSPATH=$JAVA_HOME/jre/lib/ext:$JAVA_HOME/lib/tools.jar


i don't know why i have or think i should have both of these files, i think it is because i think one is for my own account, and one is for all accounts, 2 being root and my own account, because i don't know which account is being used by tomcat to access the mysql database via the cas application :/



07-Jan-2015 17:16:32.357 SEVERE [localhost-startStop-1] org.apache.catalina.core.StandardContext.filterStart Exception starting filter springSecurityFilterChain
 org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'centralAuthenticationService' defined in ServletContext resource [/WEB-INF/spring-configuration/applicationContext.xml]: Cannot resolve reference to bean 'authenticationManager' while setting constructor argument; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'authenticationManager' defined in ServletContext resource [/WEB-INF/deployerConfigContext.xml]: Cannot resolve reference to bean 'primaryAuthenticationHandler' while setting constructor argument; nested exception is org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [org.jasig.cas.adaptors.jdbc.SearchModeSearchDatabaseAuthenticationHandler] for bean with name 'primaryAuthenticationHandler' defined in ServletContext resource [/WEB-INF/deployerConfigContext.xml]; nested exception is java.lang.ClassNotFoundException: org.jasig.cas.adaptors.jdbc.SearchModeSearchDatabaseAuthenticationHandler
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:326)


Andy Turner

unread,
Jan 8, 2015, 11:16:25 AM1/8/15
to cas-...@lists.jasig.org
Chris,
i got it to work, thank you so much for your help!  The problem was that cas-server-support-jdbc-x.y.z.jar was not in tomcat's /cas/WEB-INF/lib directory, and that contained the jdbc functionality.

So for anyone reading this, the classpath seems to always be tomcat's /WEB-INF/lib despite what the context is for java, maven, the O.S. in terms of the classpath for jars.

SOLVED!!! 52 hours it took me for mysql database backend authentication!

Chris Adams

unread,
Jan 8, 2015, 11:22:53 AM1/8/15
to cas-...@lists.jasig.org

Andy,

 

Good deal ! I was just going to comment that maybe you needed to set the classpath to the java directory. I don’t have a CLASSPATH set on my CentOS environment. Apparently, the default CLASSPATH is the “working directory”, so I guess in this situation it is as you found out.

 

I will be interested to see where you take it from here, since I am now not much farther along than you.

Dmitriy Kopylenko

unread,
Jan 8, 2015, 11:29:05 AM1/8/15
to cas-...@lists.jasig.org
Folks,

this should give a good overview of Tomcat’s handling of classpaths and hopefully resolve this mystery: http://www.mulesoft.com/tcat/tomcat-classpath

Best,
Dmitriy.

 
 
POM.XML
-- 
You are currently subscribed to cas-...@lists.jasig.org as: dkopy...@unicon.net
To unsubscribe, change settings or access archives, see http://www.ja-sig.org/wiki/display/JSG/cas-user

Andy Turner

unread,
Jan 8, 2015, 12:02:46 PM1/8/15
to cas-...@lists.jasig.org, Alex Ortiz, Patrick Brown
Thanks Chris and Dmitriy!
The next step for Illinois College will be to implement uPortal, and federate gmail, moodle, and JICS into one portal page we hope, with a managed password policy for revoking existing service tickets/session cookies/cached logins on remote machines so that authorization and authentication are centralized.

One example of this SSO implementation is at 
uPortal info:

Primarily the first goal is self-password-reset, to reduce the number of helpdesk calls from disparate systems, implemented with smtp functionality within tomcat/AD/sql/JICS' SAML/msql/gmail , such as is described in Chapter 7 of http://shop.oreilly.com/product/0636920025368.do
Reply all
Reply to author
Forward
0 new messages