glassfish
  1. glassfish
  2. GLASSFISH-17113

EclipseLink does not detect entities in Class-Path JAR

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Works as designed
    • Affects Version/s: 3.1.1_b11
    • Fix Version/s: None
    • Labels:
      None
    • Environment:

      Win7 Pro SP1 64 Bit de_DE

      Description

      If an EAR contains an EJB-JAR which contains a persistence.xml and Entity A, and that entity A references an Entity B, then the Entity B ist not found by EclipseLink in case it is not contained directly in the same EJB-JAR but instead in a second jar which is declared in the Class-Path entry of the first EJB-JAR:

      EAR
      EJB-JAR --> persistence.xml, Entity A, Class-Path:UTILITY-JAR
      UTILITY-JAR --> Entity B

      In that case at deployment asadmin says that EclipseLink complains Entity B would not be an Entity. In fact, Entity B is an entity (annotated by @Entity).

      When moving Entity B from UTILITY-JAR to EJB-JAR then deployment is working well.

      This is rather strange as obviously Entity B should be found in the Class-Path and it is easy to detect that it is an entity by looking at the annotation.

        Activity

        Hide
        Mitesh Meswani added a comment -

        Here is from JPA 2.0 spec about how to list of managed classes is derived

        The set of managed persistence classes that are managed by a persistence unit is defined by using one or more of the following
        • Annotated managed persistence classes contained in the root of the persistence unit (unless theexclude-unlisted-classes element is specified)
        • One or more object/relational mapping XML files
        • One or more jar files that will be searched for classes
        • An explicit list of classes

        See section 8.2 of JPA 2.0 spec for definition of root of persistence unit

        Show
        Mitesh Meswani added a comment - Here is from JPA 2.0 spec about how to list of managed classes is derived The set of managed persistence classes that are managed by a persistence unit is defined by using one or more of the following • Annotated managed persistence classes contained in the root of the persistence unit (unless theexclude-unlisted-classes element is specified) • One or more object/relational mapping XML files • One or more jar files that will be searched for classes • An explicit list of classes See section 8.2 of JPA 2.0 spec for definition of root of persistence unit
        Hide
        mkarg added a comment -

        But what about "One or more jar files that will be searched for classes"? For what will those be searched, if not for @Entity?

        Show
        mkarg added a comment - But what about "One or more jar files that will be searched for classes"? For what will those be searched, if not for @Entity?
        Hide
        mkarg added a comment -

        Got it working now: The correct (and working) solution is to register UTILITY-JAR within persistence.xml using <jar-file>UTILITY-JAR</jar-file>, which is working pretty well.

        I wonder why this complexity is needed. It would feel more like Java if Class-Path would be scanned...

        Show
        mkarg added a comment - Got it working now: The correct (and working) solution is to register UTILITY-JAR within persistence.xml using <jar-file>UTILITY-JAR</jar-file>, which is working pretty well. I wonder why this complexity is needed. It would feel more like Java if Class-Path would be scanned...

          People

          • Assignee:
            Mitesh Meswani
            Reporter:
            mkarg
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: