3 Replies Latest reply on Jul 19, 2010 11:31 AM by I need a real name

    Seam Component used as "standard EJB"

    I need a real name Newbie

      Hi!


      I'd like to know if it was possible to use a seam component as a standard EJB3 which could be called via JNDI from an external stand alone application or another web app.


      I'm trying to embeed an stateless EJB in my Seam project but the bean is not bound and so cannot be called... The others seam components are working fin as the web app is deployed correctly.



      Thank you !

        • 1. Re: Seam Component used as "standard EJB"
          Serkan Eskici Novice

          You can try out something like this:


          Scope(STATELESS)
          @Name("remoteEJBClient"
          public class YourEJBRemoteClient {
          
              //@Out(scope=STATELESS) or try to outject in some scope and use it as a component
              private EJBRemote remoteEJB;
          
              
              @Create
              public void init() {
                  this.remoteEJB = //do a JNDI lookup;
              }
          
              @Unwrap
              public EJBRemote getRemoteEJB() {
                  return this.remoteEJB;
              }
          }
          



          Thus use either @Unwrap or @Factory in combination with @Out putting the component in some scope.

          • 2. Re: Seam Component used as "standard EJB"
            I need a real name Newbie

            I see your point, but it's not what I was looking for (maybe I didn't have been clear enough)



            What I'm trying to do is the opposite (but it should work nearly the same)


            I already have some seam components and I wanted to reach them form another web app as if they were standard EJB3..




            I made something like this :



            My Seam component that I want to reach from the outside :


            @Stateless
            @Name("myBeanHome")
            @JndiName("MyApp/MyBean/remote")
            public class MyBeanHome implements MyBeanRemote {
               
               @Remove
               public void destroy(){}
            ....



            The Remote Interface it should implement :



            @Remote
            public interface UserManager {
            
              ...
              public void destroy();
            }



            I also added a ejb-ref in the web.xml file...


            The other web app should obtain the MyBeanHome EJB by context lookup ...


            Thx for your help !




            • 3. Re: Seam Component used as "standard EJB"
              I need a real name Newbie

              Oups.. bad copy/paste...


              The interface is :




              @Remote
              public interface MyBeanRemote {
              
                ...
                public void destroy();
              }