Injecting EXTENDED @PersistenceContext into JUnit 4 test class causes NoSuchBeanDefinitionException [SPR-8834] #13476
Labels
in: core
Issues in core modules (aop, beans, core, context, expression)
in: test
Issues in the test module
status: backported
An issue that has been backported to maintenance branches
type: bug
A general bug
Milestone
Matthew T. Adams opened SPR-8834 and commented
I'm trying to use a container-managed extended
EntityManager
in a test class. When I use the annotation@PersistenceContext(type=PersistenceContextType.EXTENDED, unitName="...")
, thePersistenceAnnotationBeanPostProcessor
throws aNoSuchBeanDefinitionException
saying that it can't find the bean with the name of my test class. If I remove the type argument (or set it toPersistenceContextType.TRANSACTION
), my test fails for unrelated reasons.Reproducible example attached.
To reproduce, extract archives in archive, issue
"mvn install"
in../dn-atomikos/trunk
, and then issue"mvn clean test -Dtest=TwoPhaseCommitTest"
in../db.jta/
.If reproduced, you should get an exception like the one below. If you comment out
"type=PersistenceContextType.EXTENDED)"
inAbstractTwoPhaseCommitTest
, this exception goes away (and a new, unrelated exception may appear). I need to test this with a container-managed extendedEntityManager
, so I'm blocked until this is fixed.Affects: 3.1 RC1
Attachments:
Referenced from: commits 592e344, 8fb7b69, 388561d, e48c315
Backported to: 4.0.7, 3.2.11
1 votes, 5 watchers
The text was updated successfully, but these errors were encountered: