Problem deploying CAS 4.2.2 with MySQL Service Registry

247 views
Skip to first unread message

Aaron Eidt

unread,
Nov 9, 2016, 12:07:40 PM11/9/16
to cas-...@apereo.org

I wondered if someone can help us with a CAS 4.2.2 deployment problem.

 

For the past 2 weeks, we tried to deploy CAS 4.2.2 with mysql for

serviceRegistry without success. It failed with "Unable to acquire JDBC

Connection" error.

 

We searched the Unicon github. Only found a simple samle using json.

There was not much info out there in the CAS-user or CAS-community either.

 

Here's our config

 

deployercontext.xml

 

  <bean        id="dataSource"

        class="com.mchange.v2.c3p0.ComboPooledDataSource"

p:driverClassName="org.hibernate.dialect.MySQL5InnoDBDialect"

p:url="jdbc:mysql://localhost:3306/serviceregistry?autoReconnect=true"

p:password="...."

        p:username="webxxxx" />

 

The pom.xml

 

   <dependency>

    <groupId>com.mchange</groupId>

    <artifactId>c3p0</artifactId>

    <version>0.9.2.1</version>

  </dependency>

 

 

<dependency>

            <groupId>org.hibernate</groupId>

            <artifactId>hibernate-core</artifactId>

            <version>5.1.0.Final</version>

        </dependency>

 

 

  <dependency>

    <groupId>org.hibernate</groupId>

   <artifactId>hibernate-entitymanager</artifactId>

    <version>5.1.0.Final</version>

</dependency>

 

 

<!--

    MySQL Connector

-->

<dependency>

    <groupId>mysql</groupId>

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

    <version>5.1.26</version>

</dependency>

 

Error in the tomcat log

 

Caused by:

org.springframework.transaction.CannotCreateTransactionException: Could

not open JPA EntityManager for transaction; nested exception is

javax.persistence.PersistenceException:

org.hibernate.exception.GenericJDBCException: Unable to acquire JDBC

Connection

 

 

Are we missing anything in pom.xml?

 

Any help is appreciated!

 

Thanks in advance!

 

 

Aaron Eidt

unread,
Nov 9, 2016, 4:03:21 PM11/9/16
to s...@jonez.info, jasig-cas-user, cas-...@apereo.org

Thanks Sam.

 

I thought the dataSource bean was needed based on the statement in the documentation “The configuration assumes a dataSource bean is defined in the context.”

 

I have tried what you suggested and I am still getting the same error.

 

Thanks,
Aaron

 

From: s...@jonez.info [mailto:s...@jonez.info]
Sent: Wednesday, November 09, 2016 12:33 PM
To: jasig-cas-user <jasig-c...@googlegroups.com>
Cc: cas-...@apereo.org; Aaron Eidt <aei...@uwo.ca>
Subject: Re: [cas-user] Problem deploying CAS 4.2.2 with MySQL Service Registry

 

Hi Aaron,

 

I struggled for a while with this as well. In the end I added the mysql-connector dependency you already found (I don't have the hibernate or mchange ones), and also:

<dependency>

    <groupId>org.jasig.cas</groupId>

    <artifactId>cas-server-support-jpa-service-registry</artifactId>

    <version>${cas.version}</version>

</dependency>

 

In deployerConfigContext.xml I have a line like this

 

    <alias name="jpaServiceRegistryDao" alias="serviceRegistryDao" />

 

but not your datasource bean.

 

The in the cas.properties file (which'll need to be somewhere on the classpath) you can configure the database with lines like the following:

 

# JPA Service Registry Database Configuration

svcreg.database.ddl.auto=create-drop

svcreg.database.dialect=org.hibernate.dialect.OracleDialect|MySQLInnoDBDialect|HSQLDialect

svcreg.database.hibernate.batchSize=10

svcreg.database.driverClass=org.hsqldb.jdbcDriver

svcreg.database.url=jdbc:hsqldb:mem:cas-ticket-registry

svcreg.database.user=sa

svcreg.database.password=

svcreg.database.pool.minSize=6

svcreg.database.pool.maxSize=18

svcreg.database.pool.maxWait=10000

svcreg.database.pool.maxIdleTime=120

svcreg.database.pool.acquireIncrement=6

svcreg.database.pool.idleConnectionTestPeriod=30

svcreg.database.pool.connectionHealthQuery=select 1

svcreg.database.pool.acquireRetryAttempts=5

svcreg.database.pool.acquireRetryDelay=2000

svcreg.database.pool.connectionHealthQuery=select 1

 

 

All the best,

 

Sam Jones.

--
- CAS gitter chatroom: https://gitter.im/apereo/cas
- CAS mailing list guidelines: https://apereo.github.io/cas/Mailing-Lists.html
- CAS documentation website: https://apereo.github.io/cas
- CAS project website: https://github.com/apereo/cas
---
You received this message because you are subscribed to the Google Groups "CAS Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cas-user+u...@apereo.org.
To view this discussion on the web visit https://groups.google.com/a/apereo.org/d/msgid/cas-user/DM5PR11MB1289AEADCB84AC7AFC8D5B01F2B90%40DM5PR11MB1289.namprd11.prod.outlook.com.

Aaron Eidt

unread,
Nov 9, 2016, 4:03:21 PM11/9/16
to s...@jonez.info, cas-...@apereo.org

--

Aaron Eidt

unread,
Nov 11, 2016, 4:50:39 PM11/11/16
to s...@jonez.info, jasig-cas-user, cas-...@apereo.org

Yes, I have tried removing the entire datasource bean definition and still no luck.

 

Thanks,
Aaron

 

From: s...@jonez.info [mailto:s...@jonez.info]
Sent: Friday, November 11, 2016 10:22 AM
To: jasig-cas-user <jasig-c...@googlegroups.com>
Cc: s...@jonez.info; cas-...@apereo.org; Aaron Eidt <aei...@uwo.ca>
Subject: Re: [cas-user] Problem deploying CAS 4.2.2 with MySQL Service Registry

 

Hi Aaron,

 

Looking at the documentation it does indeed say that. When I look at the config I have there isn't a dataSource bean but it does appear to load. I'm trying to avoid an assertion here about what the right thing to do is because I don't feel I am in a place to be authoritative on that matter.

 

Did you try commenting out the entire dataSource bean definition, I think that would get what you have closer to what I have.

 

All the best,

 

Sam

Ralf Haug

unread,
Jul 12, 2017, 6:24:51 AM7/12/17
to CAS Community, s...@jonez.info, jasig-c...@googlegroups.com, aei...@uwo.ca
Hi Aaaron,

looking at your datasource definition in the spring configuration i found something
that might be wrong.

The property "driverClassName" should point to JDBC driver class (like for example com.mysql.jdbc.Driver)
instead of hibernate dialect class

Regards

Ralf
Reply all
Reply to author
Forward
0 new messages