Hi everyone,
I have a problem using the following combination of frameworks:
Spring 2.5.2
Hibernate 3.2.5
JPA
I've tried Tomcat 4.0.4, 4.0.5 and 4.2.2.
The problem is due a NameNotFoundException when using a jndi provided datasource. It all works fine with a jdbc direct connection configuration. I've tried all possibilities but no success.
Here is my configuration:
String config:
My persistence.xml: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:p="http://www.springframework.org/schema/p" xmlns:aop="http://www.springframework.org/schema/aop" xmlns:context="http://www.springframework.org/schema/context" xmlns:jee="http://www.springframework.org/schema/jee" xmlns:tx="http://www.springframework.org/schema/tx" xsi:schemaLocation=" http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-2.5.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd "> <!-- Datasource: s'usa directament per desenvolupar en Tomcat. En test real s'ha d'usar el datasource del servidor d'aplicacions --> <!-- <bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource"> <property name="driverClassName" value="oracle.jdbc.driver.OracleDriver" /> <property name="url" value="jdbc:oracle:thin:@uxorades:1521:orades" /> <property name="username" value="dtmweb00" /> <property name="password" value="zdtmweb00" /> </bean> --> <!-- <jee:jndi-lookup id="dataSource" jndi-name="OracleDS" cache="true" resource-ref="true" lookup-on-startup="false" expected-type="javax.sql.DataSource" /> --> <bean id="dataSource" class="org.springframework.jndi.JndiObjectFactoryBean"> <property name="jndiName"><value>OracleDS</value></property> <property name="resourceRef"><value>true</value></property> </bean> <bean class="org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor" /> <!-- Definició de la Persistence Unit Manager per a JPA --> <bean id="persistenceUnitManager" class="org.springframework.orm.jpa.persistenceunit.DefaultPersistenceUnitManager"> <property name="persistenceXmlLocations"> <list> <value>classpath:/META-INF/persistence.xml</value> </list> </property> </bean> <!-- Configuració de la EntityManager Factory --> <!-- Es configura per a usar Hibernate com a implementació de la JPA --> <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="database" value="ORACLE" /> <property name="generateDdl" value="false" /> <property name="databasePlatform" value="org.hibernate.dialect.Oracle10gDialect" /> <property name="showSql" value="true" /> </bean> </property> <property name="jpaPropertyMap"> <map> <entry key="hibernate.show_sql" value="false" /> <entry key="hibernate.format_sql" value="true" /> <entry key="hibernate.connection.driver_class" value="oracle.jdbc.driver.OracleDriver" /> </map> </property> <property name="persistenceUnitManager" ref="persistenceUnitManager" /> </bean> <!-- <property name="userTransactionName"><value>UserTransaction</value></property> --> <!-- Definició de Transaction Manager --> <bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager"> <property name="entityManagerFactory" ref="entityManagerFactory" /> </bean> <tx:annotation-driven transaction-manager="transactionManager" /> <!-- Generic DAO to use from BOs --> <bean id="universalDao" class="net.tmb.framework.services.persistence.impl.UniversalDAOImpl"> </bean> </beans>
Code:<persistence 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" version="1.0"> <persistence-unit name="persistenceUnit" transaction-type="RESOURCE_LOCAL" > <non-jta-data-source>OracleDS</non-jta-data-source> <properties> <property name="hibernate.show_sql" value="false" /> <property name="hibernate.format_sql" value="false" /> <property name="hibernate.connection.driver_class" value="oracle.jdbc.driver.OracleDriver" /> <property name="hibernate.dialect" value="org.hibernate.dialect.Oracle10gDialect" /> <property name="hibernate.hbm2ddl.auto" value="false" /> </properties> </persistence-unit> </persistence>
Any help please??
Thanks a lot.


Reply With Quote