Hello !
I've been developing a application using JSF + Hibernate + Spring, guidind some examples using direct acess to the database at persistence.xml, configuring the hibernate.connection.url, hibernate.connection.username and hibernate.connection.password.
I configured the applicationContext i was using the following code to inject the EntityManager:
The application was working right but now, because of client company specifications, we need to acess a datasource located at the server (they use Weblogic). I'm trying to do this since few days ago using the Tomcat (the container i've been using to run application locally) but i am having problems with the injection (i think). I've changed the LocalEntityManagerFactoryBean to LocalContainerEntityManagerFactoryBean and configured some other things and since i did this the tomcat gives me an error about the version of JPA descripted in persistence.xmlCode:<bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalEntityManagerFactoryBean"> <property name="persistenceUnitName" value="ADDOrca-Model" /> </bean> <context:component-scan base-package="br.uff.addlabs.orca.controller" /> <tx:annotation-driven transaction-manager="transactionManager" /> <context:annotation-config /> <bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager"> <property name="entityManagerFactory" ref="entityManagerFactory" /> </bean>
(Value '2.0' of attribute 'version' of element 'persistence' is not valid with respect to the corresponding attribute use. Attribute 'version' has a fixed value of '1.0'.)
I tried to found any reference to JPA1 at my classpath and i didn't found anything and i don't have any clue to solve this problem. The current code:
persistence.xml
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_2_0.xsd" version="2.0"> <persistence-unit name="ADDOrca-Model" transaction-type="JTA"> <provider>org.hibernate.ejb.HibernatePersistence</provider> <jta-data-source>java:comp/env/jdbc/addorca</jta-data-source> <properties> <property name="hibernate.dialect" value="org.hibernate.dialect.Oracle10gDialect"/> <property name="hibernate.transaction.factory_class" value="org.hibernate.transaction.JTATransactionFactory"/> <property name="hibernate.transaction.manager_lookup_class" value="org.hibernate.transaction.WeblogicTransactionManagerLookup"/> <property name="hibernate.connection.driver_class" value="oracle.jdbc.driver.OracleDriver"/> </properties> </persistence-unit> </persistence>
applicationContext.xml
Code:<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context" 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.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd"> <bean id="dataSource" class="org.springframework.jndi.JndiObjectFactoryBean"> <property name="resourceRef"> <value>false</value> </property> <property name="jndiName"> <value>java:comp/env/jdbc/addorca</value> </property> </bean> <bean id="jpaAdapter" class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter" p:databasePlatform="org.hibernate.dialect.Oracle10gDialect" /> <bean id="entityManagerFactory" p:dataSource-ref="dataSource" p:jpaVendorAdapter-ref="jpaAdapter" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"> <property name="persistenceUnitName" value="ADDOrca-Model" /> <property name="jpaProperties"> <value> hibernate.dialect=org.hibernate.dialect.Oracle10gDialect hibernate.show_sql=true hibernate.transaction.manager_lookup_class=org.hibernate.transaction.WeblogicTransactionManagerLookup hibernate.transaction.factory_class=org.hibernate.transaction.JTATransactionFactory </value> </property> <property name="loadTimeWeaver"> <bean class="org.springframework.instrument.classloading.SimpleLoadTimeWeaver" /> </property> </bean> <bean id="transactionManager" autowire="byName" class="org.springframework.transaction.jta.JtaTransactionManager"> <property name="entityManagerFactory" ref="entityManagerFactory" /> </bean> <context:component-scan base-package="br.uff.addlabs.orca.controller" /> <tx:annotation-driven transaction-manager="transactionManager" /> <context:annotation-config /> </beans>


Reply With Quote

