Your data source bean loading is not really a JNDI lookup. The JNDI look up 
should be like this (Here i assume you have done the JNDI DS setup in app 
server):

<jee:jndi-lookup id="dataSource"
    jndi-name="jdbc/casDs"
    cache="true"
    resource-ref="true"
    lookup-on-startup="false"
    proxy-interface="javax.sql.DataSource"/>

So we have defined a data source with name "dataSource". But, the jpa 
ticket registry and service registry needs DS with names dataSourceTicket 
and dataSourceService. So we define alias like this:

<alias name="dataSource" alias="dataSourceTicket"/>
<alias name="dataSource" alias="dataSourceService"/>

So the default data source names of them can be overriden.


On Monday, December 26, 2016 at 8:38:25 PM UTC+8, Gokhan Mansuroglu wrote:
>
> Hello,
>
> I am trying to configure jpa ticket registry. Firstly I added the 
> following dependency :
>
>         <dependency>
>             <groupId>org.apereo.cas</groupId>
>             <artifactId>cas-server-support-jpa-ticket-registry
> </artifactId>
>             <version>${cas.version}</version>
>         </dependency>
>
>
>
> Then I checked the documentation at 
> https://apereo.github.io/cas/5.0.x/installation/JPA-Ticket-Registry.html. 
> Since I don't want to use the pooled connection and prefer a predefined 
> jndi datasource, the configuration parameters seem to be useless. I need to 
> define the datasource. First I tried to declare an alias in 
> deployerConfigContext.xml :
>
> <alias name="myDS" alias="dataSourceTicket" />
>
> But I get the following error at startup : 
> org.springframework.beans.factory.BeanCreationException: Error creating 
> bean with name 'ticketEntityManagerFactory' defined in class path 
> resource [org/apereo/cas/config/JpaTicketRegistryConfiguration.class]: 
> Bean instantiation via factory method failed; nested exception is org.
> springframework.beans.BeanInstantiationException: Failed to instantiate [
> org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean]: 
> Factory method 'ticketEntityManagerFactory' threw exception; nested 
> exception is java.lang.ClassCastException: org.springframework.jndi.
> JndiObjectFactoryBean$$EnhancerBySpringCGLIB$$ceb3620f cannot be cast to 
> javax.sql.DataSource
>
>
>
>
> Then tried another solution :
>
> <bean id="dataSourceTicket" class="com.zaxxer.hikari.HikariDataSource" 
> p:dataSource-ref="myDS"/>
>
> and get the following error :
>
> ***************************
> APPLICATION FAILED TO START
> ***************************
>
> Description:
>
> Parameter 0 of method init xxx.myDao required a single bean, but 2 were 
> found:
>     - dataSourceTicket: defined in class path resource [
> deployerConfigContext.xml]
>     - myDS: defined in class path resource [myApplicationContext.xml]
>
>
> Action:
>
> Consider marking one of the beans as @Primary, updating the consumer to 
> accept multiple beans, or using @Qualifier to identify the bean that 
> should be consumed
>
>
> What do you suggest me, how I can solve this issue ?
>
> Thanks.
>

-- 
- 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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/a/apereo.org/d/msgid/cas-user/434c7e54-3b72-4dee-8606-69bebf602d27%40apereo.org.

Reply via email to