Uploaded image for project: 'Camel'
  1. Camel
  2. CAMEL-6798

JPAComponent: unable to find EntityManagerFactory in JNDIRegistry

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Duplicate
    • 2.12.0, 2.12.1
    • None
    • camel-core, camel-jpa
    • None
    • Unknown

    Description

      When using a JNDIRegistry in a Camel context to make a JPA EntityManagerFactory available to a JPAComponent (required when running Camel in a Java EE container), the JPAComponent is unable to find it due do this line:

      Map<String, EntityManagerFactory> map = getCamelContext().getRegistry().findByTypeWithName(EntityManagerFactory.class);

      since the method findByTypeWithName in JNDIRegistry is unimplemented (returns a null map).
      This forces to fallback to a SimpleRegistry or to a Spring registry, thus making impossible to use the JAVA EE container JNDI registry.

      Proposted solution: At present, JNDI does not allow lookups based on a class.
      My suggestion is to lookup the EntityManagerFactory by a standard name, such as when looking for the default persistence unit name (and eventually adding a property for the JPA URL in order to use a custom name).

      Attachments

        Issue Links

          Activity

            People

              davsclaus Claus Ibsen
              abaldoni Alessandro Baldoni
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: