5 Replies Latest reply on Oct 19, 2005 9:35 AM by dornus

    Where do helper classes go?

      From what I understand of EJB3:
      -.par is for classes that persist to the database
      -.ejb3 is for performing business logic on .pars or other .ejb3s
      -.war is for web related classes

      Where do helper classes go? For example, a Paging Bean which remembers which page is currently displayed, how many rows to display per page, etc...

      Obviously this is not stored in the database, so it does not belong in the par file.

      If I put a paging bean in the war file, then I cannot access it from the ejb3 file.

      Do I make it a stateful bean in ejb3? Is there somewhere else it goes?

        • 1. Re: Where do helper classes go?
          bill.burke

          in jboss, i believe you can put it within a jar within the EAR, in the ejb jar file, or even in the par.

          Java EE 5 EAR format has an EAR/lib directory which should alleviate this problem.

          • 2. Re: Where do helper classes go?

            If I put it in the ejb3 jar file as you suggested, does it matter that it doesn't have an interface? I want to be able to create new instances of the Bean.

            MyBean myBean = new MyBean();
            


            I thought everything in the ejb3 needed an interface so it could handle the pooling of objects?

            • 3. Re: Where do helper classes go?

              Maybe I'm not understanding your response well.

              Are you saying to do this?

              MyEar.ear
              |--MyEJB3.ejb3
              | |--MyHelperBeans.ejb
              |--MyPar.par
              |--MyWar.war
              


              Where the helper beans go in their own .ejb (not .ejb3) file. Then that ejb jar file is included inside the ejb3 jar at the root level?

              • 4. Re: Where do helper classes go?

                Also, if I put it in the .ejb3 jar file and don't mark it as @Stateful and make an interface for it then I will get a

                javax.naming.NameNotFoundException: myPackage.myHelperBean not bound
                


                error.

                • 5. Re: Where do helper classes go?

                  OK, I put the helper classes in their own jar file at the root level of the ear

                  Then I modified the application.xml to use it

                   <module>
                   <java>MyHelperClasses.jar</java>
                   </module>
                  


                  and now everything works fine.