MySQL Persistance and LDAP
Scott Battaglia
scott.battaglia at gmail.com
Tue Dec 11 14:52:26 EST 2007
The initial <beans> definition always needs to appear at the top of the XML
document (its the root). It would replace any existing beans definition.
If you've moved all of that into a file separate from the
deployerConfigContext.xml then you need to include that file in the list of
XML configuration files in the web.xml
-Scott
On Dec 11, 2007 2:22 PM, Earnest Berry III <earnest.berry at gmail.com> wrote:
> My aplogies, bad paste. Please reference this one as it encapsulates the
> bens correclytin the bean namespace:
>
> <!--
>
> Sample, in-memory data store for the ServiceRegistry. A real
> implementation
> would probably want to replace this with the JPA-backed
> ServiceRegistry DAO
> The name of this bean should remain "serviceRegistryDao".
> -->
>
> <beans xmlns="http://www.springframework.org/schema/beans "
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xmlns:tx="http://www.springframework.org/schema/tx "
> xmlns:p="http://www.springframework.org/schema/p"
> xsi:schemaLocation=" http://www.springframework.org/schema/beans
> http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
> http://www.springframework.org/schema/tx
> http://www.springframework.org/schema/tx/spring-tx-2.0.xsd">
>
> <bean id="serviceRegistryDao" class="
> org.jasig.cas.services.JpaServiceRegistryDaoImpl"
> p:entityManagerFactory-ref="entityManagerFactory" />
>
> <!-- This is the EntityManagerFactory configuration for Hibernate
> -->
> <bean id="entityManagerFactory" class="
> org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
> <property name="dataSource" ref="dataSource"/>
> <property name="jpaVendorAdapter">
> <bean class="
> org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
> <property name="generateDdl" value="true"/>
> <property name="showSql" value="true" />
> </bean>
> </property>
> <property name="jpaProperties">
> <props>
> <prop key="hibernate.dialect">
> org.hibernate.dialect.MySQLDialect</prop>
> <prop key="hibernate.hbm2ddl.auto">create-drop</prop>
> </props>
> </property>
> </bean>
>
> <bean id="transactionManager" class="
> org.springframework.orm.jpa.JpaTransactionManager">
> <property name="entityManagerFactory"
> ref="entityManagerFactory"/>
> </bean>
>
> <tx:annotation-driven transaction-manager="transactionManager"/>
>
> <bean
> id="dataSource"
> class="org.apache.commons.dbcp.BasicDataSource"
> p:driverClassName="com.mysql.jdbc.Driver"
>
> p:url="jdbc:mysql://localhost:3306/cas_service_registry?autoReconnect=true"
> p:password="*********"
> p:username="webapp" />
> </beans>
>
>
>
> On Dec 11, 2007 2:06 PM, Earnest Berry III < earnest.berry at gmail.com>
> wrote:
>
> > Scott,
> > Thanks for the reply. I left everything in my deployerConfig, I just
> > didn't want to post the entire file to the thread. What I posted all
> > appears below the:
> > <!--
> > Sample, in-memory data store for the ServiceRegistry. A real
> > implementation
> > would probably want to replace this with the JPA-backed
> > ServiceRegistry DAO
> > The name of this bean should remain "serviceRegistryDao".
> > -->
> > Comment. The reason I moved things around was because in another note
> > from this thread, when I was getting the "tx not bound" error, it was
> > because things were out of order. In the directions from the wiki, it
> > mentioned addnig the namespace last, thus it appears afterwards.
> > I've updated my deploymentConfig...yhet still getting the previous
> > "invaid bean" error I posted a bit before ( no longer the tx not bound
> > error". I'll try and do a bit more research, but i'm at a loss. It seems
> > the error I am getting is with the namespace part..like it doesn't like
> > the namespace, as the error line number is the line that has the
> > xsi:schemaLocation for the spring transaction (tx) namespace.
> >
> > ====== My deploymentConfig snippet BELOW the "Sample, in-memory data"
> > comment secion ========
> > <!--
> > Sample, in-memory data store for the ServiceRegistry. A real
> > implementation
> > would probably want to replace this with the JPA-backed
> > ServiceRegistry DAO
> > The name of this bean should remain "serviceRegistryDao".
> > -->
> > <beans xmlns="http://www.springframework.org/schema/beans
> > "
> > xmlns:xsi=" http://www.w3.org/2001/XMLSchema-instance"
> > xmlns:tx="http://www.springframework.org/schema/tx"
> > xmlns:p=" http://www.springframework.org/schema/p"
> >
> > xsi:schemaLocation="http://www.springframework.org/schema/beans
> > http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
> > http://www.springframework.org/schema/tx
> > http://www.springframework.org/schema/tx/spring-tx-2.0.xsd" />
> >
> > <bean id="serviceRegistryDao"
> > class="org.jasig.cas.services.JpaServiceRegistryDaoImpl"
> > p:entityManagerFactory-ref="entityManagerFactory" />
> >
> > <!-- This is the EntityManagerFactory configuration for
> > Hibernate -->
> > <bean id="entityManagerFactory"
> > class="
> > org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
> > <property name="dataSource" ref="dataSource"/>
> > <property name="jpaVendorAdapter">
> > <bean
> > class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
> > <property name="generateDdl"
> > value="true"/>
> > <property name="showSql" value="true" />
> > </bean>
> > </property>
> > <property name="jpaProperties">
> > <props>
> > <prop
> > key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
> > <prop
> > key="hibernate.hbm2ddl.auto">create-drop</prop>
> > </props>
> > </property>
> > </bean>
> >
> > <bean id="transactionManager"
> > class="org.springframework.orm.jpa.JpaTransactionManager">
> > <property name="entityManagerFactory"
> > ref="entityManagerFactory"/>
> > </bean>
> >
> > <tx:annotation-driven transaction-manager="transactionManager"/>
> >
> > <bean
> > id="dataSource"
> > class="org.apache.commons.dbcp.BasicDataSource "
> > p:driverClassName="com.mysql.jdbc.Driver"
> >
> >
> > p:url="jdbc:mysql://localhost:3306/cas_service_registry?autoReconnect=true"
> > p:password="******"
> > p:username="webapp" />
> >
> >
> >
> >
> > Scott Battaglia wrote:
> > > It looks like you deleted just about everything in the
> > > deployerConfigContext.xml, and you have things in the wrong order.
> > > There's a reason most of those things exist in there.
> > >
> > > Also, if you plan on using mySQL, you can't configure your dialect for
> > > HSQL, as you did: <prop
> > > key="hibernate.dialect ">org.hibernate.dialect.HSQLDialectect</prop>
> > >
> > > Finally, this is all detailed right here:
> > > http://www.ja-sig.org/wiki/display/CASUM/Configuring
> > > <http://www.ja-sig.org/wiki/display/CASUM/Configuring>
> > >
> > > -Scott
> > >
> > > On Dec 11, 2007 3:40 AM, Earnest Berry III < earnest.berry at gmail.com
> > > <mailto:earnest.berry at gmail.com>> wrote:
> > >
> > > Hello,
> > >
> > > Ok, I am becoming completly lost as to how to setup my CAS
> > instance. I
> > > was really excited when I first got it working with the demo with
> > the
> > > default WAR file; but since then, I have had 0 luck in connecting
> > > it to
> > > LDAP auth, OR connecting it to my MySQL database so that my
> > services
> > > persists.
> > >
> > > My setup:
> > > Glassfish V2, Latest JDK
> > >
> > > So, the WAR file is deployed. I edited the deployerConfig.xml as
> > > follows
> > > ( please see the end of the post). But to no avail. I was getting
> > > a lot
> > > of dependancy errors. So I then downloaded all the hibernate jars,
> > > and I
> > > then also downloaded some apache-commons jars that I thought I
> > needed,
> > > and I'm still getting the following error:
> > >
> > > Exception starting filter Acegi Filter Chain Proxy
> > > org.springframework.beans.factory.BeanCreationException: Error
> > > creating
> > > bean with name 'servicesManager' defined in ServletContext
> > resource
> > > [/WEB-INF/applicationContext.xml]: Cannot resolve reference to
> > bean
> > > 'serviceRegistryDao' while setting constructor argument with index
> > 0
> > >
> > > I also tried the maven build stuff, but I'm a bit lost on those
> > > too. Do
> > > I just drop the jars created into my WEB-INF/lib ? Also, there's
> > no
> > > build for building for MySQL persistance for services, I thought I
> > > could
> > > at least get that working, but to now avail. I've looked for
> > > tutorials,
> > > explinations, etc. Pehraps I'm missing something big time in the
> > > docs,
> > > but I'vebeen through those a few times. Anyhelp would be much
> > > appreciated. I'm also looking to post a step-by-step blog post
> > about
> > > setting this thing up once I can get it running myself. Thanks.
> > >
> > > ===== BELOW IS MY deploymentConfig.xml ================
> > >
> > > <bean id="entityManagerFactory"
> > > class="
> > org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean ">
> > > <property name="dataSource" ref="dataSource"/>
> > > <property name="jpaVendorAdapter">
> > > <bean
> > > class="
> > org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
> > > <property name="generateDdl" value="true"/>
> > > <property name="showSql" value="true" />
> > > </bean>
> > > </property>
> > > <property name="jpaProperties">
> > > <props>
> > > <prop
> > > key="hibernate.dialect">org.hibernate.dialect.HSQLDialect</prop>
> > > <prop key="hibernate.hbm2ddl.auto
> > ">create-drop</prop>
> > > </props>
> > > </property>
> > > </bean>
> > >
> > > <bean id="transactionManager"
> > > class="org.springframework.orm.jpa.JpaTransactionManager ">
> > > <property name="entityManagerFactory"
> > > ref="entityManagerFactory"/>
> > > </bean>
> > >
> > > <beans xmlns=" http://www.springframework.org/schema/beans"
> > > xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> > > xmlns:tx=" http://www.springframework.org/schema/tx"
> > > xmlns:p="http://www.springframework.org/schema/p "
> > > xsi:schemaLocation=" http://www.springframework.org/schema/beans
> > > http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
> > > http://www.springframework.org/schema/tx
> > > http://www.springframework.org/schema/tx/spring-tx-2.0.xsd" />
> > >
> > > <tx:annotation-driven transaction-manager="transactionManager"/>
> > >
> > >
> > > <bean
> > > id="dataSource"
> > > class="org.apache.commons.dbcp.BasicDataSource"
> > > p:driverClassName="com.mysql.jdbc.Driver"
> > >
> > >
> > p:url="jdbc:mysql://localhost:3306/cas_service_registry?autoReconnect=true"
> > > p:password="*******"
> > > p:username="webapp" />
> > >
> > > _______________________________________________
> > > Yale CAS mailing list
> > > cas at tp.its.yale.edu <mailto: cas at tp.its.yale.edu>
> > > http://tp.its.yale.edu/mailman/listinfo/cas
> > >
> > >
> > >
> > >
> > > --
> > > -Scott Battaglia
> > >
> > > LinkedIn: http://www.linkedin.com/in/scottbattaglia
> > >
> > ------------------------------------------------------------------------
> > >
> > > _______________________________________________
> > > Yale CAS mailing list
> > > cas at tp.its.yale.edu
> > > http://tp.its.yale.edu/mailman/listinfo/cas
> > >
> >
> >
>
> _______________________________________________
> Yale CAS mailing list
> cas at tp.its.yale.edu
> http://tp.its.yale.edu/mailman/listinfo/cas
>
>
--
-Scott Battaglia
LinkedIn: http://www.linkedin.com/in/scottbattaglia
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://tp.its.yale.edu/pipermail/cas/attachments/20071211/5e73b753/attachment.html
More information about the cas
mailing list