Description
Given following blueprint definition:
<service interface="com.foo.MyDao"> <bean class="com.foo.impl.MyDaoImpl"> <tx:transaction method="*" value="Required"/> </bean> </service>
MyDaoImpl has a property of type EntityManager annotated with PersistenceUnit but "JpaComponentProcessor" is not able to properly scan the nested bean inside above service definition to find the annotated property.
looking at JpaComponentProcessor source, following code snippet, one can see it
is checking if component definition is an instance of "MutableBeanMetadata" which is not the case when the bean definition is nested in service definition (it is an instance of "MutableServiceMetadata")
Set<String> components = new HashSet<String(cdr.getComponentDefinitionNames()); for (String component : components) { ComponentMetadata compDef = cdr.getComponentDefinition(component); if (compDef instanceof MutableBeanMetadata && !((MutableBeanMetadata)compDef).isProcessor()) { handleComponent((MutableBeanMetadata)compDef, bundle, cdr, container); } }
As a workaround I can change the blueprint definition to following:
<bean id="myBean" class="com.foo.impl.MyDaoImpl"> <tx:transaction method="*" value="Required"/> </bean> <service interface="com.foo.MyDao"> <ref component-id="myBean" /> </service>