6 Replies Latest reply on Aug 6, 2008 8:14 PM by dheerajtak

    How to deploy seam components as Jar and used them in different ear's

    dheerajtak
      Hi,
      Can i bundle seam components in a separate jar files and deploy this jar files in different ear files?

      Basically I am trying to create different Seam Session Bean components in a jar files and wanted to access these components in different ear applciation.

      I tried to create a EJBProject and created different stateful session beans within it.
      I added jboss-seam.jar in build path so that I can use seam anotation.
      I could compile these

      Now in ear I deployed this jar as a ejb module  by making the following entry in application.xml
      <module>
           <ejb>app_one-ejb.jar</ejb>
      </module>

      However when I am trying to access the components I am not getting them
      I have used @In annotation to get access to the components.

      I am not sure if this is the correct way to do .

      Is there any other way to achieve this.

      any help would be highly appreciated

      Thanks in Advance
      -Dheeraj-
        • 1. Re: How to deploy seam components as Jar and used them in different ear's
          admin.admin.email.tld

          you should be able to do that, assuming that you mean SFSB, SLSB, JavaBean, or JPA entity classes when you say seam components.


          most likely you need to modify an ant build script to accommodate your needs (i.e. copy the JAR files into the EAR for application foo).


          or simply run seam-gen and add the classes to your project and make sure the build script will add the compiled classes in the JAR (and necessary .xml files, like deployment descriptors) to your EAR.


          you could also expose conversational Seam web services (cool) and take a performance hit, most likely...

          • 2. Re: How to deploy seam components as Jar and used them in different ear's
            dheerajtak
            Thanks for the reply
            yes my jar file does has SFSB

            even the application is deployed properly ,
            but when I am trying the access the components i am not getting it

            here is what I am trying to do

            In app One

            @Stateful
            @Name("ThreeBean")
            public class ThreeBean implements Three {
                    public void sayHello()
                    {
                            System.out.println("Hello");
                    }      
            }

            @Local (not sure if this to be made as remote ,any way this jar wud be the part of ear )
            public interface Three {       
                    public void sayHello();
            }


            In app two

            There is another session bean within which i tried the following options

            1.@In
              ThreeBean ThreeBean;  //this is giving as warnign saying context variable nto found

            also this ThreeBean is coming as null


            2.ThreeBean cs =(ThreeBean ) Component.getInstance(ThreeBean.class);
            this is theowing class cast exception ...Component.getInstance(ThreeBean.class) this is returning some javaassist object..

            3.
            @EJB(mappedBy = "app1/ThreeBean/local"
            private ThreeBean ThreeBean

            even this is not working

            Not sure If i need to make some entries in components.xml  or seam.properties




            • 3. Re: How to deploy seam components as Jar and used them in different ear's
              pgmjsd

              Have you tried deploying this in a single EJB-JAR?


              Also, using upper camel case for the field names so that the name of the field and the name of the class/interface are the same might cause problems (e.g. you have ThreeBean ThreeBean;).

              • 4. Re: How to deploy seam components as Jar and used them in different ear's
                dheerajtak

                that was just a type its actually threeBean


                yes there is no error at deployment time , its properly deployed

                • 5. Re: How to deploy seam components as Jar and used them in different ear's
                  pmuir

                  If you want to access a Seam component from another EAR, then you need to use a remote EJB for lookup, and deploy an API to a shared classpath. You'll need to use EJB mechanisms for DI.

                  • 6. Re: How to deploy seam components as Jar and used them in different ear's
                    dheerajtak

                    Thanks all,
                    finally I got the solution


                    I created  a new EJB Project and add jboss-seam.jar in the build path  and created a jar out of this ..
                    we have to place seam.properties(though blank) and seam interceptors in ejb-jar.xml



                    and i am able to access the components from another ear