Hi!

I am wanting to connect to two databases. In the past I've written Tapestry apps with just one DB and Spring and Hibernate - no problems. I see that (currently) there is no way to connect to multiple DBs with just tapestry-hibernate (although I read on the list archive that there is an untested patch - not really what I'm looking for).

So I have followed the route recommended which is to use Spring. However, I'm running into difficulties. As some of you have apparently done this kind of thing then perhaps you might point out where I am going wrong.

Firstly, I followed the instructions I have in the past for getting this going with a single DB. Then I began to modify my applicationContext.xml file so that I could have two Session Factories. However, I've fallen at the first hurdle. While I can change the name of the hibernate.cfg.xml file from it's default, if I do I get an error. Tapestry and Spring start as expected, and Hibernate starts too - I can see that in the logs and C3P0 is starting as expected. But as soon as I try to call:

Query query = sessionFactory.getCurrentSession()


it falls flat on its face with:


org.hibernate.HibernateException: /hibernate.cfg.xml not found
        at 
org.hibernate.util.ConfigHelper.getResourceAsStream(ConfigHelper.java:170)
at org.hibernate.cfg.Configuration.getConfigurationInputStream(Configuration.java:1453)
        at org.hibernate.cfg.Configuration.configure(Configuration.java:1475)
at org.hibernate.cfg.AnnotationConfiguration.configure(AnnotationConfiguration.java:1017) at org.hibernate.cfg.AnnotationConfiguration.configure(AnnotationConfiguration.java:64)
        at org.hibernate.cfg.Configuration.configure(Configuration.java:1462)
at org.hibernate.cfg.AnnotationConfiguration.configure(AnnotationConfiguration.java:1011) at org.hibernate.cfg.AnnotationConfiguration.configure(AnnotationConfiguration.java:64) at org.apache.tapestry5.internal.hibernate.DefaultHibernateConfigurer.configure(DefaultHibernateConfigurer.java:38) at $HibernateConfigurer_12cb1c6b24c.configure($HibernateConfigurer_12cb1c6b24c.java) at org.apache.tapestry5.internal.hibernate.HibernateSessionSourceImpl.(HibernateSessionSourceImpl.java:41) at org.apache.tapestry5.hibernate.HibernateCoreModule.buildHibernateSessionSource(HibernateCoreModule.java:123)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.tapestry5.ioc.internal.ServiceBuilderMethodInvoker.createObject(ServiceBuilderMethodInvoker.java:64)

...


My applicationcontext.xml looks like this:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans";
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
        xsi:schemaLocation="http://www.springframework.org/schema/beans
        http://www.springframework.org/schema/beans/spring-beans-2.5.xsd";>

        <!-- Hibernate session factory -->

        <bean id="sessionFactory"
                
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
                <property name="configLocation">
                        <value>classpath:hibernatedpl.cfg.xml</value>
                </property>
                <property name="configurationClass">
                        <value>org.hibernate.cfg.AnnotationConfiguration</value>
                </property>
        </bean>

<bean id="DPLRepository" class="org.digiatlas.dpl.entities.HibernateDPLRepository">
                <constructor-arg ref="sessionFactory" />
        </bean>

<bean id="userRepository" class="org.digiatlas.dpl.user.HibernateUserRepository">
                <constructor-arg ref="sessionFactory" />
        </bean>

....


and hibernatedpl.cfg.xml is obviously correct because it's connecting to the DB.

To me it looks like Tapestry-Hibernate expects the default config name. I did try adding:

<context-param>
        <param-name>tapestry.hibernate.default-configuration</param-name>
        <param-value>false</param-value>
    </context-param>

to my web.xml but this now requires me to set up Hibernate configs. I shouldn't have to do that as it should all be happening via Spring.

I'm out of ideas and have just spent a day on this and getting no further.

Any help would be greatly appreciated.

My next question will be how to set up the rest of the applicationcontext - I imagine I need two transaction managers, but I can't find an example of how to connect this up in the XML with the transaction interceptor. Anyway - one problem at a time...!

Thank you.




---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org

Reply via email to