gcarl
Jan 13th, 2011, 08:57 AM
Hi, I'm trying to configure Spring, JPA and DB2 in order to have the entity manager instance to be used in my spring controllers but according how I have configured Spring this not happens. This is my attempt of configure spring:
<?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:context="http://www.springframework.org/schema/context"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="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/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd">
<bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalEntityManagerFact oryBean">
<property name="persistenceUnitName" value="default"/>
</bean>
<bean id="entityManager" factory-bean="entityManagerFactory" factory-method="createEntityManager"/>
<bean id="securityManager" class="utilities.services.auth.impl.SecurityManagerImpl" init-method="checkInitialization">
<property name="entityManager" ref="entityManager"/>
</bean>
</beans>
and this is the configuration for the controller in the springweb-servlet.xml file:
<bean id="loginController" parent="baseController" class="utilities.controllers.LoginController">
<property name="formView" value="LoginView"/>
<property name="successView" value="LoginSuccessView"/>
<property name="commandName" value="login"/>
<property name="commandClass" value="utilities.controllers.pojo.UserCredentials"/>
<property name="validator" ref="validator"/>
<property name="securityManager" ref="securityManager"/>
</bean>
but I have always this exception:
Caused by: java.lang.IllegalArgumentException: methods with same signature createEntityManager() but incompatible return types: [interface com.ibm.websphere.persistence.WsJpaEntityManager, interface org.apache.openjpa.persistence.OpenJPAEntityManage rSPI]
I don't know how can be fixed. Has anyone encountered this problem?
Thanks in advance.
Also this is my persistence.xml:
<?xml version="1.0" encoding="UTF-8"?>
<persistence xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.0"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd">
<persistence-unit name="default" transaction-type="JTA">
<provider>org.apache.openjpa.persistence.PersistenceProvider Impl</provider>
<jta-data-source>jdbc/file_ds</jta-data-source>
<mapping-file>META-INF/orm.xml</mapping-file>
<properties>
<property name="openjpa.TransactionMode" value="managed"/>
<property name="openjpa.ConnectionFactoryMode" value="managed"/>
<property name="openjpa.jdbc.DBDictionary" value="db2"/>
</properties>
</persistence-unit>
</persistence>
<?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:context="http://www.springframework.org/schema/context"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="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/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd">
<bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalEntityManagerFact oryBean">
<property name="persistenceUnitName" value="default"/>
</bean>
<bean id="entityManager" factory-bean="entityManagerFactory" factory-method="createEntityManager"/>
<bean id="securityManager" class="utilities.services.auth.impl.SecurityManagerImpl" init-method="checkInitialization">
<property name="entityManager" ref="entityManager"/>
</bean>
</beans>
and this is the configuration for the controller in the springweb-servlet.xml file:
<bean id="loginController" parent="baseController" class="utilities.controllers.LoginController">
<property name="formView" value="LoginView"/>
<property name="successView" value="LoginSuccessView"/>
<property name="commandName" value="login"/>
<property name="commandClass" value="utilities.controllers.pojo.UserCredentials"/>
<property name="validator" ref="validator"/>
<property name="securityManager" ref="securityManager"/>
</bean>
but I have always this exception:
Caused by: java.lang.IllegalArgumentException: methods with same signature createEntityManager() but incompatible return types: [interface com.ibm.websphere.persistence.WsJpaEntityManager, interface org.apache.openjpa.persistence.OpenJPAEntityManage rSPI]
I don't know how can be fixed. Has anyone encountered this problem?
Thanks in advance.
Also this is my persistence.xml:
<?xml version="1.0" encoding="UTF-8"?>
<persistence xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.0"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd">
<persistence-unit name="default" transaction-type="JTA">
<provider>org.apache.openjpa.persistence.PersistenceProvider Impl</provider>
<jta-data-source>jdbc/file_ds</jta-data-source>
<mapping-file>META-INF/orm.xml</mapping-file>
<properties>
<property name="openjpa.TransactionMode" value="managed"/>
<property name="openjpa.ConnectionFactoryMode" value="managed"/>
<property name="openjpa.jdbc.DBDictionary" value="db2"/>
</properties>
</persistence-unit>
</persistence>