1 Reply Latest reply on Jan 14, 2004 7:33 AM by doomsday

    Class loading problem / EAR file configuration?

    doomsday Newbie

      Hi Java wranglers,

      I have the following problem:
      In my J2EE app, I use the plugin design pattern which I changed a little to meet the following requirements:
      (1) Plugins reside in individual jar files of unspecified names
      (2) the Plugin jar files reside in fixed directories (see below)
      (3) every plugin jar has a .properties file in the root dir with a fixed name defined by the plugin interface (or abstract class) that configures the class name
      (4) if more than one plugin implementations reside in a jar file, the jar file then must contain the appropriate number (and appropriately named) properties files in its rood directory
      (5) only one implementation variant for a plugin interface must be made available to the application

      I tested this with a little java command line prog, and it works - well, for simplicity, I did set the CLASSPATH appropriately, shortcutting the algorithm to autoload all jar files in a certain dir (like Web Apps do with jars in WEB-INF/lib dir).

      Then I wrote a litlle web application having all jars in the WEB-INF/lib dir, and it worked as I expected. Replacing the implementation variant A with the implementation variant B works without configuring touching the EAR file in any other manner. (See attachments ResourceTest.ear.ImplA.zip and ResourceTest.ear.ImplB.zip) The reason is that all jar files in the WEB-INF lib dir are loaded automatically.

      Now the REAL problem:
      The Plugin mechanism must also be available to at least EJB's and other web apps that reside in this EAR file (in the future). The sort of natural place to put the jars seem to me the root dir of the EAR archive, that is, changing the EAR structure from

      ResourceTest.ear/
       META-INF/
       application.xml
       jboss-app.xml
       Test.war/
       index.jsp
       WEB-INF/
       web.xml
       jboss-web.xml
       lib/
       common.jar
       pluginA_implA.jar

      to
      ResourceTest.ear/
       common.jar
       pluginA_implA.jar
       META-INF/
       application.xml
       jboss-app.xml
       Test.war/
       index.jsp
       WEB-INF/
       web.xml
       jboss-web.xml
       lib/


      common.jar is a fixed name, but the names of the plugin jars do vary from implementation to implementation alternative.

      How can I achieve this?

      Help is greatly appreciated,
      Doomsday

      P.S.: Halas I cannot attach neither source code or sample ear files - how can I make this available?