4 Replies Latest reply on Jan 3, 2004 4:26 AM by rahul_41

    Jar's Wars Ears and classpaths once and for all

    Mark Gargan Newbie

       

      "gags_78" wrote:
      "gags_78" wrote:
      Hi there,
      I've been confused for some time about the interactions of jars and wars, ears, knees, toes etc..

      I've narrowed it down to a couple of questions.

      Say I have a standalone jar-file, app1-ejb.jar, file containing an EJB
      i.e.
      Bean class
      home&remote interfaces
      ejb-jar.xml & jboss.xml descriptors
      Manifest.ms file
      application.xml file

      This bean must make reference to another bean located on another jboss engine on a remote machine just to explicitness'

      sake. This bean is app2-ejb.jar and contains the exact same file structure as app1-ejb.jar. note they are seperate

      applications providing diverse services.

      From what I understand and please correct me if I'm wrong cos this is proving hasslesome, in order for app1-ejb.jar to be

      able to access app2-ejb.jar's interfaces I must jar them up the interfaces directly into the app1-ejb.jar file instead of being

      able to jar them into an interface jar, namely app2Client-interfaces.jar that only contains the home and remote

      interfaces for app2. Is this correct? So basically I can jar up the interface classes fine explicitly but if I attempt to include

      them jarred up I'm outta luck? Even if I include a manifest that declares a classpath pointing to them?

      I think I understand that if I was to create a j2ee application app1.ear then I can include the interface jar for app2 within

      this app1.ear file, amend the classpath in the ear's manifest file to point to the app2 interface jar then I'm elected again.

      There's just no way to include the interfaces jarred up within the standalone ejb jar file.

      I hope this is making sense and not just annoying folks.

      Secondly when I'm earing up my app1.ear file which now contains a WAR and a JAR the structure I'm coming out with is

      like so: -
      1 app.ear file containing :

      1 app-ejb.jar file
      some client-interface.jars for beans accessed by app-ejb.jar
      1 app-war.war file
      A manifest file indicating the classpath for the EJB


      The app-war.war file in itself containing:-
      Some jsp files
      Copies of the same client-interface.jars
      Copy of the app-ejb.jar file
      a Manifest file indicating the classpath for the EJB in the WAR


      Is there no way to direct any client access request that does NOT originate thru one of the war's jsps to the bean
      contained app1-ejb.jar of the war file instead of having to include two versions of the same ejb in the same ear file? It seems wasteful so much so that I'm beginning to question whether I've just got this all wrong.

      Please keep in mind I'm quite new to EJB and the whole J2EE platform and honestly I inherited much off my jarring and warring practice from a colleague so if I'm well off base then I do apologise for wasting everyones time and would greatly appreciate being set straight...

      Please excuse my spelling it out so bluntly but I've never come across a proper explanation of this and it's beginning to annoy me also I'm wondering why a proper thorough idiot proof explanation, (expressly for the likes of muggins here) isn't available?

      Thanks very much for taking the time to read this and any help would be thoroughly appreciated.

      Thanks,
      Mark.


        • 1. Re: Jar's Wars Ears and classpaths once and for all
          Mark Gargan Newbie

           

          "gags_78" wrote:
          "gags_78" wrote:
          "gags_78" wrote:
          hi there,
          Finally think I've figured some of it out. So basically if you want your ejb to access an external bean then you must supply the interface classes explicitly i.e. unpackaged at the top of the ejb within the jar if it's a standalone application. Also ye have to reference the external bean within the ejb-jar.xml file which the deployer will resolve in the jboss.xml file.

          For ejbs deployed within the same j2ee application ear file you can use the ejb-link tag and local interfaces for quicker access.

          For a standalone web application that resources an external bean you supply the interface classes unpackaged within the WEB-INF/classes directory off the root of the war.
          For web apps deployed within the same j2ee application ear file as the beans it wishes to resource, you may use the <ejb-link> element as above to quick reference the bean..

          If within you application ear you have one or more EJBs referencing a number of remote beans each with seperate intefaces you may then package those interfaces altogether within the one interfaces.jar file, somewhere off the root of the ear file e.g. /lib/clientInterfaces.jar and then make them available to the packaged within EJBs by setting the classpath within the EJB's manifest file to point to
          Class-path: /lib/clientInterfaces.jar...

          If anyone gets the chance could they quickly jot down anywhere I'm inaccurate or else just plain incorrect?

          I'd really appreciate it..

          Thanks,
          Mark.


          • 2. Re: Jar's Wars Ears and classpaths once and for all
            Mark Gargan Newbie

             

            "gags_78" wrote:
            "gags_78" wrote:
            Also for web-apps that externally resource a bean if you just jar up the interfaces to the root of the web-application then it should be able to find them without having to state it within a manifest..

            Thanks,
            Mark.


            • 3. Re: Jar's Wars Ears and classpaths once and for all
              hbhcoke Newbie

               

              "hbhcoke" wrote:
              "hbhcoke" wrote:
              (ear) is final file for deployment, it may consist of many *.jar and *.war and one META-INF folder. META-INF folder must have one application.xml.

              (war) file is where u put ur servlet, jsp and other helper classes. the folder structure consist of WEB-INF and other *.jsp and *.html, etc. WEB-INF must at least have web.xml, classes folder, lib folder. in our case, we deploy on jboss, so we need jboss-web.xml in WEB-INF folder as well. classes folder is where u put ur servlet and helper classes, lib just the same, but must in form of *.jar. usually for api library.

              (filename-ejb.jar) file is where u put ur ejb and its helper classes. its folder structure is much simpler, u may just jar ur java package together with META-INF folder. the META-INF folder consist of ejb-jar.xml and jboss.xml.

              this is all about ear, war and ejb.jar. u may put all ejb in one jar or in many different jar. doesnt matter, depend on how u want organize your work.
              as long as u jar them up with the folder structure describe above, u got an complete ear file ready for drop into jboss for deployment.


              • 4. Re: Jar's Wars Ears and classpaths once and for all
                rahul_41 Newbie

                 

                "rahul_41@yahoo.com" wrote:
                "rahul_41@yahoo.com" wrote:
                "hbhcoke" wrote:
                (ear) is final file for deployment, it may consist of many *.jar and *.war and one META-INF folder. META-INF folder must have one application.xml.

                (war) file is where u put ur servlet, jsp and other helper classes. the folder structure consist of WEB-INF and other *.jsp and *.html, etc. WEB-INF must at least have web.xml, classes folder, lib folder. in our case, we deploy on jboss, so we need jboss-web.xml in WEB-INF folder as well. classes folder is where u put ur servlet and helper classes, lib just the same, but must in form of *.jar. usually for api library.

                (filename-ejb.jar) file is where u put ur ejb and its helper classes. its folder structure is much simpler, u may just jar ur java package together with META-INF folder. the META-INF folder consist of ejb-jar.xml and jboss.xml.

                this is all about ear, war and ejb.jar. u may put all ejb in one jar or in many different jar. doesnt matter, depend on how u want organize your work.
                as long as u jar them up with the folder structure describe above, u got an complete ear file ready for drop into jboss for deployment.


                That was very informative! :)