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. These are the two attempts of configuration of spring:
<bean name="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
<property name="entityManagerFactory" ref="em" />
<property name="persistenceUnitName" value="fileUtility" />
<property name="database" value="DB2" />
<property name="showSql" value="true" />
the second is this:
<!-- Entity manager factory bean. -->
<property name="persistenceUnitName" value="Sample" />
<!-- Entity manager bean. -->
<bean id="em" factory-bean="entityManagerFactory"
and the entity manager is injected in this way:
<bean id="messageService" class="utilities.services.impl.MessageServiceImpl">
<property name="entityManager" ref="em" />
but I have always this exception:
Caused by: java.lang.IllegalArgumentException: methods with same signature createEntityManager() but incompatible return types: http://interface com.ibm.websphere.persistence.WsJpaEntityManager, interface org.apache.openjpa.persistence.OpenJPAEntityManagerSPI
I don't know how can be fixed. Has anyone encountered this problem?
Thanks in advance.
Also this is my persitence.xml configuration file:
<property name="openjpa.ConnectionURL" value="jdbc:db2://localhost:50000/db2admin" />
<property name="openjpa.ConnectionDriverName" value="COM.ibm.db2.jdbc.app.DB2Driver" />
<property name="openjpa.ConnectionUserName" value="db2admin" />
<property name="openjpa.ConnectionPassword" value="XXXX" />
<property name="openjpa.FlushBeforeQueries" value="true"/>
<property name="openjpa.RuntimeUnenhancedClasses" value="supported" />
<persistence-unit name="fileUtility2" transaction-type="JTA">
<property name="openjpa.Log" value="SQL=TRACE"/>
<property name="openjpa.ConnectionFactoryProperties" value="PrettyPrint=true, PrettyPrintLineLength=72"/>
NOTICE: developerWorks Community will be offline May 29-30, 2015 while we upgrade to the latest version of IBM Connections. For more information, read our upgrade FAQ.
This topic has been locked.
3 replies Latest Post - 2011-01-13T14:25:07Z by sutter
Pinned topic Spring DB2 JPA Entity Manager Problem
Answered question This question has been answered.
Unanswered question This question has not been answered yet.
Updated on 2011-01-13T14:25:07Z at 2011-01-13T14:25:07Z by sutter
sutter 120000EB4G94 PostsACCEPTED ANSWER
Re: Spring DB2 JPA Entity Manager Problem2011-01-12T15:15:50Z in response to SystemAdminHi gcarlo,
You don't mention the versions of the various software projects you are using... Via a quick Google search, I found this item on the Spring site , but this is from 2008... One of the responses on this thread stated this:
Show Juergen Hoeller added a comment - 30/Jan/08 7:16 AM Unfortunately, the problem there is the EntityManagerFactory rather than the Entitymanager, so we'd have to introduce an "entityManagerFactoryInterface" property as well... I'll try to figure out a proper solution that will work for WebSphere as well. Juergen
Permalink Juergen Hoeller added a comment - 30/Jan/08 8:18 AM
I've introduced a corresponding "entityManagerFactoryInterface" property, auto-populated from the JpaVendorAdapter by default. So as of the next snapshot (388), this should work out of the box, just through specifying OpenJpaVendorAdapter. Juergen
From this exchange, it sounds like Spring resolved this issue "out of the box". So, can you verify that you are running with the proper levels of Spring?
BTW, we have also changed this WAS and OpenJPA EM and EMF heirarchy in our latest WAS releases, so we should be in good shape all the way around.
Hope this helps,
SystemAdmin 110000D4XK45 PostsACCEPTED ANSWER
Re: Spring DB2 JPA Entity Manager Problem2011-01-12T17:31:10Z in response to sutterI have this exception with both spring 2 and 3, I had read the item in the Spring site, but now I have a questions to you: what are the proper levels of Spring that I should verify? You mean the version?
sutter 120000EB4G94 PostsACCEPTED ANSWER
Re: Spring DB2 JPA Entity Manager Problem2011-01-13T14:25:07Z in response to SystemAdminHi gcarlo,
Supposedly, the problem I referenced was resolved in Spring 2.5.2. If you are running with Spring 3.x, I would have assumed this would have been resolved in that version.
Have you checked out this helpful article ? Tom and friends have provided several helpful hints and best practices with integrating Spring with WebSphere and JPA. I also just noticed that this article referenced the same bug report in Spring  that I did.
I would review that article to see if your environment is following the suggestions outlined. I would also double check to ensure that the version of Spring that you are using has the fixes for 4383 in it (this is a question for Spring). If your scenario is still failing, please post more information on your environment (versions of Spring and WebSphere) to this forum. And, I would also post your question to the Spring forums. At this point, the data is pointing at a Spring issue, but I can't be sure.