[cas-user] Error configuring CAS 4.0.0 services registry with JpaServiceRegistryDaoImpl

159 views
Skip to first unread message

Adam Franco

unread,
Oct 6, 2014, 11:59:50 AM10/6/14
to cas-...@lists.jasig.org
Hello all,

We've been running CAS 3.x on the machine with no problems and are now trying to upgrade to CAS-4.0.0.

We've tried following the instructions at https://jasig.github.io/cas/4.0.0/installation/Service-Management.html to the letter, but cannot get the CAS to start as it always fails with an error like this:

Oct 06, 2014 11:06:06 AM org.apache.catalina.core.ApplicationContext log
INFO: Initializing Spring root WebApplicationContext
Oct 06, 2014 11:06:10 AM org.apache.catalina.core.ApplicationContext log
SEVERE: SafeContextLoaderListener:
The Spring ContextLoaderListener we wrap threw on contextInitialized.
But for our having caught this error, the web application context would not have initialized.
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in ServletContext resource [/WEB-INF/deployerConfigContext.xml]: Invocation of init method failed; nested exception is java.lang.IncompatibleClassChangeError: Implementing class
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1512)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:521)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:458)


Below are our additions to our maven overlay. Is there some other critical piece that we are missing? The documentation doesn't seem to mention any additional requirements and the error seems like a pretty generic one that I'm having trouble using as a helpful search term.

Here is our pom.xml (additions in bold):

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd ">
    <modelVersion>4.0.0</modelVersion>
    <groupId>net.unicon</groupId>
    <artifactId>cas4-overlay</artifactId>
    <packaging>war</packaging>
    <version>1.0</version>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-war-plugin</artifactId>
                <version>2.3</version>
                <configuration>
                    <warName>cas</warName>
                    <overlays>
                        <overlay>
                            <groupId>org.jasig.cas</groupId>
                            <artifactId>cas-server-webapp</artifactId>
                            <excludes>
                                <exclude>WEB-INF/cas.properties</exclude>
                                <exclude>WEB-INF/classes/log4j.xml</exclude>
                            </excludes>
                        </overlay>
                    </overlays>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.1</version>
                <configuration>
                    <source>1.7</source>
                    <target>1.7</target>
                </configuration>
            </plugin>

        </plugins>
        <finalName>cas</finalName>
    </build>

    <dependencies>
        <dependency>
            <groupId>org.jasig.cas</groupId>
            <artifactId>cas-server-webapp</artifactId>
            <version>${cas.version}</version>
            <type>war</type>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>org.jasig.cas</groupId>
            <artifactId>cas-server-integration-restlet</artifactId>
            <version>${cas.version}</version>
            <scope>runtime</scope>
        </dependency>
        <dependency>
                <groupId>org.jasig.cas</groupId>
                <artifactId>cas-server-support-ldap</artifactId>
                <version>${cas.version}</version>
        </dependency>
        <dependency>
                <groupId>commons-dbcp</groupId>
                <artifactId>commons-dbcp</artifactId>
                <version>${commons.dbcp.version}</version>
                <scope>runtime</scope>
        </dependency>
        <dependency>
                <groupId>org.hibernate</groupId>
                <artifactId>hibernate-core</artifactId>
                <version>${hibernate.version}</version>
                <scope>compile</scope>
        </dependency>
        <dependency>
                <groupId>org.hibernate</groupId>
                <artifactId>hibernate-entitymanager</artifactId>
                <version>${hibernate.entitymgmr.version}</version>
        </dependency>
        <dependency>
                <groupId>mysql</groupId>
                <artifactId>mysql-connector-java</artifactId>
                <version>${mysql.connector.version}</version>
        </dependency>

    </dependencies>

    <properties>
        <cas.version>4.0.0</cas.version>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <commons.dbcp.version>20030825.184428</commons.dbcp.version>
        <hibernate.version>4.3.5.Final</hibernate.version>
        <hibernate.entitymgmr.version>4.3.5.Final</hibernate.entitymgmr.version>
        <mysql.connector.version>3.1.11</mysql.connector.version>

    </properties>

    <repositories>
        <repository>
            <id>sonatype-releases</id>
            <url>http://oss.sonatype.org/content/repositories/releases/</url>
        </repository>
        <repository>
            <id>sonatype-snapshots</id>
            <url>https://oss.sonatype.org/content/repositories/snapshots/</url>
        </repository>
    </repositories>
</project>


and the deployerConfigContext.xml additions:

        <!-- Service Management Storage -->

        <tx:annotation-driven transaction-manager="transactionManager" />

        <util:list id="packagesToScan">
                <value>org.jasig.cas.services</value>
        </util:list>

        <bean id="entityManagerFactory"
                class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"
                p:dataSource-ref="dataSource"
                p:jpaVendorAdapter-ref="jpaVendorAdapter"
                p:packagesToScan-ref="packagesToScan">
                <property name="jpaProperties">
                        <props>
                                <prop key="hibernate.dialect">${database.dialect}</prop>
                                <prop key="hibernate.hbm2ddl.auto">update</prop>
                                <prop key="hibernate.jdbc.batch_size">
${database.batchSize}</prop>
                        </props>
               </property>
        </bean>

        <bean id="jpaVendorAdapter"
                class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter"
                p:generateDdl="true"
                p:showSql="true" />

        <bean id="serviceRegistryDao"
                 class="org.jasig.cas.services.JpaServiceRegistryDaoImpl" />

        <bean id="transactionManager"
                class="org.springframework.orm.jpa.JpaTransactionManager"
                p:entityManagerFactory-ref="entityManagerFactory" />

        <!--
           | Injects EntityManager/Factory instances into beans with
           | @PersistenceUnit and @PersistenceContext
         -->

        <bean class="org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor" />

        <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"
                p:driverClassName="com.mysql.jdbc.Driver"
                p:url="${database.url}"
                p:password="${database.password}"
                p:username="${database.username}" />


And we added the following to our /etc/cas/cas.properties

#=========================================
# Service Storage
#=========================================
database.dialect=org.hibernate.dialect.MySQLDialect
database.batchSize=20
database.url=jdbc:mysql://host.domain.edu:3306/databasename?autoReconnect=true
database.password=password
database.username=username


Thanks for any assistance you can provide!
Adam

--

Adam Franco
Senior Software Developer
Information Technology Services
Middlebury College
Middlebury, VT 05753
afr...@middlebury.edu
802.443.2244
-- 
You are currently subscribed to cas-...@lists.jasig.org as: jasig-cas-user...@googlegroups.com
To unsubscribe, change settings or access archives, see http://www.ja-sig.org/wiki/display/JSG/cas-user

Misagh Moayyed

unread,
Oct 6, 2014, 1:31:02 PM10/6/14
to cas-...@lists.jasig.org

Point to a new database instance and rerun the tests. It’s possible that service entries are not correctly loaded  because there have been made changes to the service model; that are incompatible with CAS 3.5 and 4.

 

You could possibly start fresh and then manually move the existing data over.

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

Adam Franco

unread,
Oct 6, 2014, 4:44:21 PM10/6/14
to cas-...@lists.jasig.org
Thanks for replying, Misagh. We are trying to connect to an empty database, but can't get the CAS server to even start. As I mentioned, we are seeing an error of:

Error creating bean with name 'entityManagerFactory' defined in ServletContext resource [/WEB-INF/deployerConfigContext.xml]: Invocation of init method failed; nested exception is java.lang.IncompatibleClassChangeError

Is this something that could be caused by a database connection error or does it point is some other direction such as some other missing pom.xml entry or other missing/invalid configuration?


Adam

--

Adam Franco
Senior Software Developer
Information Technology Services
Middlebury College
Middlebury, VT 05753
afr...@middlebury.edu
802.443.2244

On Mon, Oct 6, 2014 at 12:54 PM, Misagh Moayyed <mmoa...@unicon.net> wrote:
Point to a new database instance and rerun the tests. It’s possible that service entries are not correctly loaded  because there have been made changes to the service model; that are incompatible with CAS 3.5 and 4.

You could possibly start fresh and then manually move the existing data over.

From: Adam Franco [mailto:afr...@middlebury.edu]
Sent: Monday, October 6, 2014 8:55 AM
To: cas-...@lists.jasig.org
Subject: [cas-user] Error configuring CAS 4.0.0 services registry with JpaServiceRegistryDaoImpl
Hello all,
We've been running CAS 3.x on the machine with no problems and are now trying to upgrade to CAS-4.0.0.
We've tried following the instructions at https://jasig.github.io/cas/4.0.0/installation/Service-Management.html to the letter, but cannot get the CAS to start as it always fails with an error like this:
Oct 06, 2014 11:06:06 AM org.apache.catalina.core.ApplicationContext log
INFO: Initializing Spring root WebApplicationContext
Oct 06, 2014 11:06:10 AM org.apache.catalina.core.ApplicationContext log
SEVERE: SafeContextLoaderListener:
The Spring ContextLoaderListener we wrap threw on contextInitialized.
But for our having caught this error, the web application context would not have initialized.
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in ServletContext resource [/WEB-INF/deployerConfigContext.xml]: Invocation of init method failed; nested exception is java.lang.IncompatibleClassChangeError: Implementing class
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1512)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:521)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:458)

database.password=password
database.username=username
Thanks for any assistance you can provide!
Adam

--

Adam Franco
Senior Software Developer
Information Technology Services
Middlebury College
Middlebury, VT 05753

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: afr...@middlebury.edu

To unsubscribe, change settings or access archives, see http://www.ja-sig.org/wiki/display/JSG/cas-user

Misagh Moayyed

unread,
Oct 7, 2014, 2:24:09 AM10/7/14
to cas-...@lists.jasig.org

Check your lib directory. I think someone did post something close to the issue you’re having and there were a lot of conflicting JARs in the lib directory. Chances are those are the root cause.

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

Adam Franco

unread,
Oct 7, 2014, 12:50:05 PM10/7/14
to cas-...@lists.jasig.org
Thanks for your help, Misagh. The lib/ directory showed the problem: duplicate hibernate jars. I'd originally copied the hibernate version out of one of the cas branch's pom.xml:

<hibernate.version>4.3.5.Final</hibernate.version>

but looking in target/cas/WEB-INF/lib/ revealed that a duplicate hibernate jar was being included. I resolved this by looking at the pom.xml for the cas 4.0.0 tag and using its hibernate version in my pom.xml:

<hibernate.version>4.1.0.Final</hibernate.version>

This got rid of the duplicate hibernate jars as well as the error I was encountering.


Adam

--

Adam Franco
Senior Software Engineer - Web Applications
Library and Information Services

Middlebury College
Middlebury, VT 05753
afr...@middlebury.edu
802.443.2244
On Tue, Oct 7, 2014 at 2:23 AM, Misagh Moayyed <mmoa...@unicon.net> wrote:
Check your lib directory. I think someone did post something close to the issue you’re having and there were a lot of conflicting JARs in the lib directory. Chances are those are the root cause.
From: Adam Franco [mailto:afr...@middlebury.edu]
Sent: Monday, October 6, 2014 1:43 PM
To: cas-...@lists.jasig.org
Subject: Re: [cas-user] Error configuring CAS 4.0.0 services registry with JpaServiceRegistryDaoImpl

Thanks for replying, Misagh. We are trying to connect to an empty database, but can't get the CAS server to even start. As I mentioned, we are seeing an error of:
Error creating bean with name 'entityManagerFactory' defined in ServletContext resource [/WEB-INF/deployerConfigContext.xml]: Invocation of init method failed; nested exception is java.lang.IncompatibleClassChangeError
Is this something that could be caused by a database connection error or does it point is some other direction such as some other missing pom.xml entry or other missing/invalid configuration?


Adam

--

Adam Franco
Senior Software Developer
Information Technology Services
Middlebury College
Middlebury, VT 05753


On Mon, Oct 6, 2014 at 12:54 PM, Misagh Moayyed <mmoa...@unicon.net<mailto:mmoa...@unicon.net>> wrote:
Point to a new database instance and rerun the tests. It’s possible that service entries are not correctly loaded  because there have been made changes to the service model; that are incompatible with CAS 3.5 and 4.

You could possibly start fresh and then manually move the existing data over.


database.password=password
database.username=username
Thanks for any assistance you can provide!
Adam

--

Adam Franco
Senior Software Developer
Information Technology Services
Middlebury College
Middlebury, VT 05753


To unsubscribe, change settings or access archives, see http://www.ja-sig.org/wiki/display/JSG/cas-user


--

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<mailto:cas-...@lists.jasig.org> as: mmoa...@unicon.net<mailto: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: afr...@middlebury.edu
To unsubscribe, change settings or access archives, see http://www.ja-sig.org/wiki/display/JSG/cas-user
Reply all
Reply to author
Forward
0 new messages