This is the 2nd last piece to my puzzle and I will have our app fully ported
to Geronimo.  This piece is kinda critical to the sucess. It's a long
message.

- I have Geronimo 2.2 and Hibernate working great with a container managed
DB POOL
- When I add Spring Support to allow the injection of an Entity Manager, the
process breaks down
- In short, I get a stack trace that says Caused by:
javax.naming.NotContextException: jdbc/wakapeek
- jdbc/wakapeek is the jndi name to my geronimo managed datasource which is
connecting to an external postgres database
- again, every thing works without spring, even the injection of the Entity
Manager in a SLSB 3
- I've tried many different configs, all configs lead to the same exception.
- Seems that Spring is looking for jdbc/wakapeek using InitialContext() and
cannot resolve the JNDI name of the datasource

Here's the config and code.  I was hoping that someone out there is using
Spring + Hibernate + Geronimo with a CM database and could help me solve
this puzzle.
- note, I do not put a ref-resource in web.xml because a) I'm not running
any servlets (bootstrapping spring is done with a singleton spring factory)
and b) I dont think ref-resource is required with Geronimo with a container
managed DB Pool (but i could be wrong)

btw, please let me know if i am breaking rules with posting all my code and
configs.  honestly, i have not had time to read the lists etiquette rules
yet. apologies.

Here's my persistence.xml (it works without SPRING)

[code]
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="1.0"
        xmlns="http://java.sun.com/xml/ns/persistence";
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
        xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd";>
        
        <persistence-unit name="wakapeek-jpa" transaction-type="JTA">
                <provider>org.hibernate.ejb.HibernatePersistence</provider>
                <jta-data-source>jdbc/wakapeek</jta-data-source>
                <non-jta-data-source>jdbc/wakapeek</non-jta-data-source>
                <exclude-unlisted-classes>false</exclude-unlisted-classes>
                <properties>                    
                        <property 
name="hibernate.transaction.manager_lookup_class"
                                
value="org.hibernate.transaction.GeronimoTransactionManagerLookup" />
                </properties>
        </persistence-unit>
</persistence>
[/code]

spring config:
[code]
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans";
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
xmlns:aop="http://www.springframework.org/schema/aop";
        xmlns:tx="http://www.springframework.org/schema/tx";
        xmlns:jee="http://www.springframework.org/schema/jee";
        xsi:schemaLocation="http://www.springframework.org/schema/beans 
        http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
        http://www.springframework.org/schema/tx
        http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
        http://www.springframework.org/schema/aop
        http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
        http://www.springframework.org/schema/jee
        http://www.springframework.org/schema/jee/spring-jee-3.0.xsd";>

        <jee:jndi-lookup id="datasource" jndi-name="jdbc/wakapeek" />

        <bean id="persistenceUnitManager"
        
class="org.springframework.orm.jpa.persistenceunit.DefaultPersistenceUnitManager">
                <property name="persistenceXmlLocations">
                        <list>
                                <value>classpath*:META-INF/persistence.xml
                                </value>
                        </list>
                </property>
                <property name="defaultDataSource" ref="datasource" />
        </bean>

        <bean id="jpaVendorAdapter"
                
class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
                <property name="databasePlatform"
value="org.hibernate.dialect.PostgreSQLDialect" />
        </bean>

        <bean id="entityManagerFactory"
        
class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
                <property name="persistenceUnitName" value="wakapeek-jpa" />
                <property name="jpaVendorAdapter" ref="jpaVendorAdapter" />
                <property name="persistenceUnitManager" 
ref="persistenceUnitManager" />
        </bean>

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

        <bean id="transactionManager"
class="org.springframework.orm.jpa.JpaTransactionManager">
                <property name="entityManagerFactory" 
ref="entityManagerFactory" />
                <property name="datasource" ref="datasource" />
        </bean>

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

</beans>
[/code]

this awesome RA!
[code]
<resourceadapter>
        <outbound-resourceadapter>
            <connection-definition>
               
<connectionfactory-interface>javax.sql.DataSource</connectionfactory-interface>
                <connectiondefinition-instance>
                    <name>jdbc/wakapeek</name>
                    <config-property-setting
name="DatabaseName">wakapeek</config-property-setting>
                    <config-property-setting
name="Password">pass</config-property-setting>
                    <config-property-setting
name="UserName">user</config-property-setting>
                    <config-property-setting
name="ServerName">192.168.0.193</config-property-setting>
                    <config-property-setting name="PrepareThreshold"/>
                    <connectionmanager>
                        <xa-transaction>
                            <transaction-caching/>
                        </xa-transaction>
                        <single-pool>
                            <max-size>10</max-size>
                            <min-size>0</min-size>
                            <match-one/>
                        </single-pool>
                    </connectionmanager>
                </connectiondefinition-instance>
            </connection-definition>
        </outbound-resourceadapter>
    </resourceadapter>
[/code]

and the dump
[code]
Caused by: javax.naming.NotContextException: jdbc/wakapeek
        at
org.apache.xbean.naming.context.AbstractContext.lookup(AbstractContext.java:165)
        at
org.apache.xbean.naming.context.AbstractContext.lookup(AbstractContext.java:605)
        at javax.naming.InitialContext.lookup(InitialContext.java:392)
        at
org.springframework.jndi.JndiTemplate$1.doInContext(JndiTemplate.java:154)
        at org.springframework.jndi.JndiTemplate.execute(JndiTemplate.java:87)
        at org.springframework.jndi.JndiTemplate.lookup(JndiTemplate.java:152)
        at org.springframework.jndi.JndiTemplate.lookup(JndiTemplate.java:178)
        at
org.springframework.jndi.JndiLocatorSupport.lookup(JndiLocatorSupport.java:104)
        at
org.springframework.jndi.JndiObjectLocator.lookup(JndiObjectLocator.java:105)
        at
org.springframework.jndi.JndiObjectFactoryBean.lookupWithFallback(JndiObjectFactoryBean.java:201)
        at
org.springframework.jndi.JndiObjectFactoryBean.afterPropertiesSet(JndiObjectFactoryBean.java:187)
        at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1460)
        at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1400)
        ... 57 more
[/code]




-- 
View this message in context: 
http://apache-geronimo.328035.n3.nabble.com/Geronimo-2-2-Spring-Hibernate-and-a-Geronimo-managed-DB-Pool-with-XA-driver-tp874759p874759.html
Sent from the Users mailing list archive at Nabble.com.

Reply via email to