4 Replies Latest reply on Mar 27, 2006 9:32 AM by treespace

    Finding Java 5.0 Enum Types

      My entity beans have enum columns and EJB 3.0 handles the translation without any intervention on my part -- not even an annotation! Here's my problem: where can common classes like enums be placed in my EAR such that the entity bean jar can see them? I do not want to put them IN the jar containing my entity beans.

      I have a session bean jar, entity bean jar and war file. If the enum is in the session bean jar everybody sees it EXCEPT the entity bean jar. I really don't like making duplicate copies of classes, so where can classes go which are shared by all tiers in the EAR but not outside the EAR?

        • 1. Re: Finding Java 5.0 Enum Types
          persabi

          One solution I use is to have a common jar that contains the common classes you want to share and add it as a java module to your application.xml.

          • 2. Re: Finding Java 5.0 Enum Types

            Modules have to be an EJB, WAR or application jar. Listing any old jar as a module only works in JBoss. WLS, for exampe, won't load a plain jar file.

            Historically I have used Class-Path settings but was hoping there was now a more convenient yet portable solution. I guess I will use the application.xml for now, then use Class-Path if and when we need to port this.

            • 3. Re: Finding Java 5.0 Enum Types
              epbernard

              set your common jar un your EAR and use ClassPath in entiotybean.jar to depend on this common jar

              • 4. Re: Finding Java 5.0 Enum Types

                That's usually what I've done but that adds another file (manifest) and changes the build script and then you've got to repeat that for all the jars that use common.jar. It seems like a lot of needless tinkering when it should just load jars in the base of the ear listed as "java" modules.

                In fact JBoss does load "java" modules whether they contain a client application or not. Maybe it's a bug but it's VERY convenient. Only thing is the load order isn't specified, but it seems to work.