Announcement Announcement Module
No announcement yet.
Spring JTA in Jboss 5 Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Spring JTA in Jboss 5

    I am following the example laid out here:

    But I am running into this exception:

    INFO: 13:52:21,657 ERROR ContextLoader:220 - Context initialization failed
    org.springframework.beans.factory.BeanCreationException:  Error creating bean with name 'userAccountDAO': Injection of persistence dependencies failed; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No unique bean of type [javax.persistence.EntityManagerFactory] is defined: expected single bean but found 0
        at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.postProcessPropertyValues(
    This happens when I try and inject the EntityManager directly.

    Any ideas on why Spring is not finding the EntityManagerFactory in jboss? Is there something that the post missed?


  • #2
    Two things.

    One is a personal opinion. In that article they set up Transactional methods using the xml approach. That tends to be very very verbose, and think that @Transactional annotations are so much easier.

    Second is to your issue. Here is its configuration of of the EntityManagerFactory bean

    <jee:jndi-lookup id="emf" jndi-name="persistence/BankAppPU"/>

    So the question is. Is that the name to correctly find it in the JNDI tree of JBoss. Or could it be something else.

    Also, in the post it says this "Make the changes to the <jta-data-source> as you have defined in your system (for example in a file like JBOSS_HOME/server/default/deploy/bank-ds.xml - See JBOSS_HOME/docs/examples/jca/ for templates)."

    Did you do that? If you look at your JBoss log, do you see the datasource being deployed with the name "BankAppDS"? Also in your JBoss log, do you see the EntityManagerFactory being deployed?

    These are just a few that I thought of. Might not be your solution, but things to check.

    Just other thing I noticed that isn't an error or such, but

    1) In the first web.xml it sets up the context param of contextConfigLocation and points to WEB-INF/applicationContext.xml

    This is actually the default name and location that the ContextLoaderListener will look for. So if you have such a file in the WEB-INF directory, you don't even need to have the context-param element in your web.xml

    Hope that fixes it for you