Hi,
Was playing around a combination of OpenJPA 2.0.0 M2 with Spring 3.0.0.M3, made a OSGi-based test environment with Pax Exam.
Everything is smooth until I want to take advantage of autowiring EntityManager fields annotated with @PersistenceContext.
This is my XML config for the context:
Inside JpaGenericDaoImpl above contains such annotated field.Code:<?xml version="1.0" encoding="us-ascii" ?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:osgi="http://www.springframework.org/schema/osgi" 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/osgi http://www.springframework.org/schema/osgi/spring-osgi.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd"> <osgi:reference id="transactionManager" cardinality="1..1" interface="org.springframework.transaction.PlatformTransactionManager" /> <osgi:reference id="entityManagerFactory" cardinality="1..1" interface="javax.persistence.EntityManagerFactory" /> <bean class="org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor"/> <context:annotation-config /> <tx:annotation-driven transaction-manager="transactionManager"/> <bean class="JpaGenericDaoImpl"> <constructor-arg index="0" value=courier.objects.Courier" /> </bean> <osgi:service interface="courier.managers.CourierManager" id="CourierManager"> <bean id="courierManager" class="courier.managers.CourierManagerImpl" /> </osgi:service> </beans>
However when I ran the test I got a ClassNotFoundException, complaining javax.persistence.criteria.CriteriaQuery was not found.Code:@PersistenceContext private EntityManager entityManager;
When I manually added the package import back to Spring ORM's jar:
Everything is fine.Code:javax.persistence.criteria;version="[2.0.0, 3.0.0)";resolution:=optional
I suppose Spring ORM's jar should add such import so I don't need to patch the jar?
rgds,
Raymond



Reply With Quote