Hi All,

I had 1 persistence unit in my route and everything worked fine.
Yesterday I decided to add JPA tracer. For this tracer I defined a
dedicated persistence unit.

Basically this is not a problem to have many persistence unit (just to
be clear my data access layer is in a separate project). All I have to
do is add unitName to @PersistanceContext annotation:

@PersistenceContext(unitName="qualitas-pu")
protected EntityManager em;

This works fine for my Spring web application, but when Camel route is
started I get:

Error creating bean with name 'repository': Injection of persistence
dependencies failed; nested exception is
org.springframework.beans.factory.NoSuchBeanDefinitionException: No
bean named 'qualitas-pu'

Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException:
No bean named 'qualitas-pu' is defined
        at 
org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeanDefinition(DefaultListableBeanFactory.java:529)
        at 
org.springframework.beans.factory.support.AbstractBeanFactory.getMergedLocalBeanDefinition(AbstractBeanFactory.java:1094)
        at 
org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:276)
        at 
org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:196)
        at 
org.springframework.orm.jpa.EntityManagerFactoryUtils.findEntityManagerFactory(EntityManagerFactoryUtils.java:107)
        at 
org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor.findNamedEntityManagerFactory(PersistenceAnnotationBeanPostProcessor.java:510)
        at 
org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor.findEntityManagerFactory(PersistenceAnnotationBeanPostProcessor.java:492)
        at 
org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor$PersistenceElement.resolveEntityManager(PersistenceAnnotationBeanPostProcessor.java:656)

My web app uses Spring 3.0.6-RELEASE and my Camel route is 2.9.0
(which also uses Spring 3.0.6-SNAPSHOT). So the persistance unit
should work in both modules (web app and camel). Previously when I
only had 1 persistance unit and I didn't specify any unitName
parameter both modules worked like a charm.

Any ideas how to make it work? I definitely don't want to add my
custom JpaTraceEventMessage to to my first persistance unit - I don't
want my model to reference camel-jpa dependency. I want my model to be
simply clean, that is why I decided to use 2 separate persistence
units.

thanks,
Łukasz

Reply via email to