How to call one EJB in another EJB?

How to call one EJB in another EJB? Please explain with some example code.

To refer a Ejb from another Ejb include <ejb-ref> element in ejb-jar.xml
<session>
<ejb-name>EjbA</ejb-name>
<ejb-ref>
<ejb-ref-name>EjbB</ejb-ref-name>
<ejb-ref-type>Entity</ejb-ref-type>
<home>com.ejb.EjbBHome</home>
<remote>com.ejb.EjbB</remote>
</ejb-ref>
</session>
Include a <reference-descriptor> in weblogic-ejb-jar.xml
<weblogic-enterprise-bean>
<ejb-name>EjbA</ejb-name>
<reference-descriptor>
<ejb-reference-description>
<ejb-ref-name>EjbB</ejb-ref-name>
<jndi-name>com.ejb.EjbBHome</jndi-name>
</ejb-reference-description>
</reference-descriptor>
</weblogic-enterprise-bean>
In EjbA Bean class refer to EjbB with
a remote reference to EjbB.
InitialContext initialContext=new InitialContext();
EjbBHome EjbBHome=(EjbBHome)
initialContext.lookup("com.ejb.EjbBHome");
EjbB ejbB=EjbBHome.findByPrimaryKey(primarykey);

Similar Messages

  • How to call one  JSFF into another JSFF

    Hi,
    I am very new to ADf. Could you please tell me how to call one JSFF inside another JSFF. We have a common pop-up written in one JSFF. Is there any best approach to get this pop-up into other JSFF.
    Thanks in Advance.
    Regards
    Narasimha

    If you want to resue the jsff code, make use of bounded task flow with page fragment and then use it as a region.
    For more details you can refer: http://docs.oracle.com/cd/E21764_01/web.1111/b31974/taskflows_regions.htm
    One more:
    http://docs.oracle.com/cd/E18941_01/tutorials/jdtut_11r2_57/jdtut_11r2_57.html

  • How to call one program from another program

    Hai,
      How to call one program through another program.
    Example.
       I have two programs 1.ZPROG1 2. ZPROG2.
    When i execute ZPROG1 at that time it should call ZPROG2.

    Hi ,
    u can use submit statement to call a program .
    DATA: text       TYPE c LENGTH 10,
          rspar_tab  TYPE TABLE OF rsparams,
          rspar_line LIKE LINE OF rspar_tab,
          range_tab  LIKE RANGE OF text,
          range_line LIKE LINE OF range_tab.
    rspar_line-selname = 'SELCRIT1'.
    rspar_line-kind    = 'S'.
    rspar_line-sign    = 'I'.
    rspar_line-option  = 'EQ'.
    rspar_line-low     = 'ABAP'.
    APPEND rspar_line TO rspar_tab.
    range_line-sign   = 'E'.
    range_line-option = 'EQ'.
    range_line-low    = 'H'.
    APPEND range_line TO range_tab.
    range_line-sign   = 'E'.
    range_line-option = 'EQ'.
    range_line-low    = 'K'.
    APPEND range_line TO range_tab.
    SUBMIT report1 USING SELECTION-SCREEN '1100'
                   WITH SELECTION-TABLE rspar_tab
                   WITH selcrit2 BETWEEN 'H' AND 'K'
                   WITH selcrit2 IN range_tab
                   AND RETURN.
    regards,
    Santosh thorat

  • How to call one .SWF from another?

    How do I call one .SWF from another. I built a very beefy
    base .SWF, and want to add music overlay, and an intro slide show
    to the exsting Flash animation, but put it in a second .FLA/.SWF
    file. How do I call one from the other?
    This will be embedded in an HTML file but I assume this is
    superfluous to my question.
    F.Z.

    I think you should open that Another SWF (FLA),
    and add some actionscript..
    For example, you could create a movie clip, and write
    actionscript in the
    first keyframe:
    loadMovie("
    http://www.somewebpage.com/movie.swf",
    this);
    "FredZimmerman" <[email protected]> wrote in
    message
    news:ftnjas$mj5$[email protected]..
    > How do I call one .SWF from another. I built a very
    beefy base .SWF, and
    > want
    > to add music overlay, and an intro slide show to the
    exsting Flash
    > animation,
    > but put it in a second .FLA/.SWF file. How do I call one
    from the other?
    >
    > This will be embedded in an HTML file but I assume this
    is superfluous to
    > my
    > question.
    >
    > F.Z.
    >

  • How to call one procedure from another procedure

    Hi all,
    Could anyone give me clue how to call a procedure contains out parameters
    from another procedure.
    I had following procedures.
    1)
    create or replace procedure INS_PUR_ORDER
    p_poamt in number,
    p_podate in date,
    p_poid out number
    is
    begin
    select pkseq.nextval into p_poid from dual;
    insert into pur_order(poamt,podate,poid)
    values (p_poamt,p_podate,p_poid);
    end;
    2)
    create or replace procedure INS_PUR_ORDER_DETAIL
    p_pounits in number,
    p_poddate in date,
    p_poid in number)
    is
    begin
    Insert into pur_order_detail(podid,pounits,poddate,poid)
    values(pdseq.nextval,p_pounits,p_poddate,p_poid);
    end;
    I need to write a 3rd procedure which calls above two procedures.
    like
    call first procedure ,basing on the return value
    i.e if p_poid != 0 then
    we need to call second procedure
    in the loop.
    thanks in advance.
    rampa.

    Not sure what are you doing, you can not assign cursor to another cursor, may be you are looking for this?
    SQL> create or replace procedure proc1 ( result out sys_refcursor)
      2  is
      3  
      4  begin
      5     open result for
      6       select 'HELLO WORLD' from dual ;
      7  end proc1 ;
      8  /
    Procedure created.
    Elapsed: 00:00:00.01
    SQL> create or replace procedure proc2
      2  is
      3     l_cursor sys_refcursor ;
      4  begin
      5     l_cursor := proc1 ;
      6   
      7  
      8     open l_cursor;
      9     fetch l_cursor into l_text;
    10     dbms_output.put_line(l_text);
    11     close l_cursor;
    12  
    13  
    14  end proc2 ;
    15  /
    Warning: Procedure created with compilation errors.
    Elapsed: 00:00:00.01
    SQL> show error;
    Errors for PROCEDURE PROC2:
    LINE/COL ERROR
    5/4      PL/SQL: Statement ignored
    5/16     PLS-00306: wrong number or types of arguments
             in call to 'PROC1'
    6/4      PLS-00201: identifier 'L_TEXT' must be
             declared
    6/4      PL/SQL: Statement ignored
    8/4      PLS-00382: expression is of wrong type
    8/4      PL/SQL: SQL Statement ignored
    9/4      PL/SQL: SQL Statement ignored
    9/24     PLS-00201: identifier 'L_TEXT' must be
             declared
    10/4     PL/SQL: Statement ignored
    10/25    PLS-00201: identifier 'L_TEXT' must be
             declared
    ---- this is the correct waySQL>ed
      1  create or replace procedure proc2
      2  is
      3     l_cursor sys_refcursor ;
      4     l_text varchar2(100);
      5  begin
    ---- procedure call
      6     proc1(l_cursor); 
    7    -- open l_cursor;
      8     fetch l_cursor into l_text;
      9     dbms_output.put_line(l_text);
    10     close l_cursor;
    11* end proc2 ;
    SQL> /
    Procedure created.
    Elapsed: 00:00:00.01
    SQL> set serveroutput on
    SQL> execute proc2;
    HELLO WORLD
    PL/SQL procedure successfully completed.
    Elapsed: 00:00:00.00
    SQL>

  • How to call one form to another form

    hai
    i had two forms namely A and B. i had one button in form A. when i click the button in form A then form B will open. how to do this.
    thanks in advance.
    C.R

    Take a look at this article for more information:
    http://www.oracle.com/technology/products/jdev/howtos/10g/jcmultiform/index.html
    Erik

  • How to call one form to another form in JDeveloper

    hai,
    i am new to JDeveloper. i am having 2 forms contains some textfields and buttons. when i click button in one form then the second form opens and the first forms also appears remains in back. any one knows about this just tell how to do this.
    thanks in advance

    Hi Ananda Dubey,
    Since your project is MVC,  if others reply still can't resolve your issue, please consider to post in MVC forum.
    http://forums.asp.net/1146.aspx
    Have a nice day!
    Kristin
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • Calling one function in another function

    Hi,
    How to call one function in another function?
    regards,
    Kishore.

    example:
    SQL> ed
    Wrote file afiedt.buf
      1  declare
      2    function bob(x number) return number is
      3    begin
      4      return x*x;
      5    end;
      6    function fred(x number) return number is
      7    begin
      8      return x+bob(x);
      9    end;
    10  begin
    11    dbms_output.put_line('Value: '||to_char(fred(5),'fm9999'));
    12* end;
    SQL> /
    Value: 30
    PL/SQL procedure successfully completed.
    SQL>

  • Call one workflow in another workflow

    How to call one workflow in another workflow? which QPAC is used to achieve this functionality?

    None. If the workflow being called is in the active state you should find alongside your list of 'QPACS' in the Services panel.
    You can then drag it onto the caller process and configure it the same way you would any other QPAC.
    Keep in mind that your parent process will wait or continue immediately, depending on your user settings. Then there is the issue of security....
    Good luck!
    Lachlan
    http://www.avoka.com

  • How to Call one EJB from another

    Hi all
    I am trying to call one EJB in one system from another EJB residing on diferent system...
    Both are Stateless session beans ...
    I can't use No-args Intialcontext() as i need to specify the Ip address of other system to be looked up.....
    So i am using properties Dorg.omg.CORBA.ORBInitlalHost....
    But its not looking up..Its telling not bound...But i called it from standalone client remotely...
    Am i wrong..?
    I hope I am in right path....
    I hope ill get reply as fast as possible...
    Gopal V

    Hi ken Thanks for replying....
    Ya i packed it as a jar (using Export tool in Eclipse3.2)....
    I am using SUN AS 9.....
    I packed bean1 and bean2 as two different jars in the same domain...
    Here is my code...
    Bean1:
    @Stateless(mappedName="ejb/Second")
    public class SecondIMPL implements SecondRemote {
         public FirstRemote obj;
         public String connect() {
              try{
                   InitialContext ctx= new InitialContext();
                   FirstRemote obj =(FirstRemote)ctx.lookup("ejb/First");
                   System.out.println("Client :"+obj.bMethod());
              }catch(Exception e){
                   e.printStackTrace();
              return "Check server Log";
    }Bean2 :
    @Stateless(mappedName="ejb/First")
    public class FirstIMPL implements FirstRemote {
         public String bMethod() {
              return "From First Bean";
    Client:
    public static void main(String[] args) {
              try{
                   InitialContext ctx= new InitialContext();
                   SecondRemote obj =(SecondRemote)ctx.lookup("ejb/Second");
                   System.out.println("Client :"+obj.connect());
              }catch(Exception e){
                   e.printStackTrace();
    Here is my Stack Trace...
    [#|2007-05-24T18:35:17.214+0530|WARNING|sun-appserver-pe9.0|javax.enterprise.system.stream.err|_ThreadID=18;_ThreadName=p: thread-pool-1; w: 19;_RequestID=bb4848e7-829a-421d-a560-93659898eb02;|
    javax.naming.NamingException: ejb ref resolution error for remote business interfacecom.SecondRemote[Root exception is java.lang.ClassNotFoundException: com.SecondRemote]
         at com.sun.ejb.EJBUtils.lookupRemote30BusinessObject(EJBUtils.java:350)
         at com.sun.ejb.containers.RemoteBusinessObjectFactory.getObjectInstance(RemoteBusinessObjectFactory.java:61)
         at javax.naming.spi.NamingManager.getObjectInstance(NamingManager.java:304)
         at com.sun.enterprise.naming.SerialContext.lookup(SerialContext.java:314)
         at javax.naming.InitialContext.lookup(InitialContext.java:351)
         at com.FirstBean.rediff(FirstBean.java:16)
         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
         at java.lang.reflect.Method.invoke(Method.java:585)
         at com.sun.enterprise.security.application.EJBSecurityManager.runMethod(EJBSecurityManager.java:1050)
         at com.sun.enterprise.security.SecurityUtil.invoke(SecurityUtil.java:165)
         at com.sun.ejb.containers.BaseContainer.invokeTargetBeanMethod(BaseContainer.java:2766)
         at com.sun.ejb.containers.BaseContainer.intercept(BaseContainer.java:3847)
         at com.sun.ejb.containers.EJBObjectInvocationHandler.invoke(EJBObjectInvocationHandler.java:190)
         at com.sun.ejb.containers.EJBObjectInvocationHandlerDelegate.invoke(EJBObjectInvocationHandlerDelegate.java:110)
         at $Proxy36.rediff(Unknown Source)
         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
         at java.lang.reflect.Method.invoke(Method.java:585)
         at com.sun.corba.ee.impl.presentation.rmi.ReflectiveTie._invoke(ReflectiveTie.java:121)
         at com.sun.corba.ee.impl.protocol.CorbaServerRequestDispatcherImpl.dispatchToServant(CorbaServerRequestDispatcherImpl.java:650)
         at com.sun.corba.ee.impl.protocol.CorbaServerRequestDispatcherImpl.dispatch(CorbaServerRequestDispatcherImpl.java:193)
         at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.handleRequestRequest(CorbaMessageMediatorImpl.java:1705)
         at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.handleRequest(CorbaMessageMediatorImpl.java:1565)
         at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.handleInput(CorbaMessageMediatorImpl.java:947)
         at com.sun.corba.ee.impl.protocol.giopmsgheaders.RequestMessage_1_2.callback(RequestMessage_1_2.java:178)
         at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.handleRequest(CorbaMessageMediatorImpl.java:717)
         at com.sun.corba.ee.impl.transport.SocketOrChannelConnectionImpl.dispatch(SocketOrChannelConnectionImpl.java:473)
         at com.sun.corba.ee.impl.transport.SocketOrChannelConnectionImpl.doWork(SocketOrChannelConnectionImpl.java:1270)
         at com.sun.corba.ee.impl.orbutil.threadpool.ThreadPoolImpl$WorkerThread.run(ThreadPoolImpl.java:479)
    Caused by: java.lang.ClassNotFoundException: com.Second
         at com.sun.enterprise.loader.EJBClassLoader.findClassData(EJBClassLoader.java:701)
         at com.sun.enterprise.loader.EJBClassLoader.findClass(EJBClassLoader.java:614)
         at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
         at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
         at com.sun.ejb.EJBUtils.getBusinessIntfClassLoader(EJBUtils.java:568)
         at com.sun.ejb.EJBUtils.lookupRemote30BusinessObject(EJBUtils.java:320)
         ... 31 more
    |#]

  • How do I reference an EJB inside anothe EJB ,both are on different hosts

    Hi,
    I want to reference an EJB on one host inside another EJB in another
    host. Even if i hardcode the url of the host on which the EJB is
    deployed , it gives me the error regarding the no such ejb found.
    I would appreciate your help.
    Thanks

    Robert,
    We've been trying to implement this type of multi-server setup for some
    time now. Our application consists of 260+ EJBs with a large team of
    developers actively working against it. The business logic in our
    application puts the EJBS in a highly interrelated situation. This
    degree of interrelation makes it necessary for each developer to deploy
    the entire application before any work can get done.
    Starting a weblogic server, on a Windows Workstation, with 260+ beans is
    very time consuming. But to get around this development bottle neck, we
    are attempting the same scenario described in this thread. We have
    recently upgraded from WL4.5.x to WL5.1 SP8. With WL5.1, we get the
    CommunicationException seen previously in this thread. But the Error
    message in WL5.1 is less descriptive. The 5.1 error message is missing:
    WL6.0 Error Text: "This error could indicate that a component was
    deployed on a cluster member but not other members of that cluster. Make
    sure that any component deployed on a server that is part of a cluster
    is also deployed on all other members"
    It is obvious that weblogic's clustering depends on classes being
    available to each server in the cluster, including the ejbc generated
    _WLStub classes.  To me, it seems wrong that a weblogic server can only
    use standard JNDI to lookup HomeInterfaces on other weblogic servers if
    the hidden _WLStub classes are available to both servers.  I say this
    because non-weblogic clients have JNDI lookup abilities without these
    requirements. This whole experience was frustrating because all along
    I knew that the solution was simply to take the hacker route and put the
    classes in the the client classpath. I guess I just want to know if
    this is bug? If not, I think it should be.
    Thanks for listening
    Steve Dodge
    Steve Dodge
    Realeum Inc.
    Robert Patrick wrote:
    Here is an example:
    On server1, I have a Bean called TellerBean that calls the AccountBean
    that lives on server2. To make this work, I need to deploy the
    TellerBean.jar file AND any/all AccountBean Stub classes (any file in the
    deployed version of the AccountBean.jar file matching the pattern
    AccountBean*Stub.class) on server1. Server2 only needs to deploy the
    AccountBean.jar file
    Hope this helps,
    Robert
    kamps wrote:
    Thanks.
    I did include the files using import and they are alsso packaged
    into the jar file .
    I have done this , TradeCheck is the ejb i am trying to reference
    in Trader EJB.
    I package them into the jar file as follows:-
    @REM Compile EJB classes into the build directory (jar preparation)
    javac -d build TradeCheck.java TradeCheckHome.java Trader.java
    TraderHome.java TraderBean.java TradeResult.java
    @REM Make a EJB jar file, including XML deployment descriptors
    cd build
    jar cv0f std_ejb20_basic_statelessSession2.jar META-INF examples
    images
    cd ..
    @REM Run EJBC on jar file
    java -classpath
    %WL_HOME%/lib/weblogic_sp.jar;%WL_HOME%/lib/weblogic.jar weblogic.ejbc
    -compiler javac build\std_ejb20_basic_statelessSession2.jar
    %APPLICATIONS%\ejb20_basic_statelessSession2.jar
    It still gives the same error not finding the stub class.... Could
    you kindly elaborate on what needs to be done.
    I would appreciate your help.
    Thanks,
    Sunitha
    Robert Patrick <[email protected]> wrote:
    The problem is that the client that downloads the stubs
    at runtime cannot
    be another WebLogic Server. We do not support downloading
    classes into a
    running server so you will need to make sure that the
    stubs are
    "available" to the server that is acting as a client (e.g.,
    packaged in
    the EAR file) on the server acting as a client.
    kamps wrote:
    Thanks Mahendra. I am using WebLogic 6.0. Should I importthe package
    in the first ejb which references the 2nd ejb or evenin the client
    which references the first ejb.
    Thanks again,
    Sunitha
    "Mahendra Dhamdhere" <[email protected]> wrote:
    You are not getting the reference of stub.
    try this. In your client program, import the package
    in
    which ejb classes
    are present. As client downloads the stub from weblogic,
    you have to import
    the package where your stubs are present.
    which version of weblogic are you using?
    Mahendra
    kamps <[email protected]> wrote in message
    news:[email protected]...
    Thanks,
    I have 2 ejbs: one is TraderBean and a client RefClient.
    TraderBean in turn calls a method of another bean
    TradeCheckBean.
    I tried making the changes as suggested but I amgetting
    the following
    error on the client side.
    java examples.ejb20.basic.tatelessSession.RefClient"t3://localhost:7001"
    javax.naming.CommunicationException. Root exceptionis
    java.rmi.UnmarshalException:
    failed to unmarshal class java.lang.Object; nested
    exception
    is:
    java.lang.ClassNotFoundException:examples.ejb20.basic.statelessSession.Trade
    CheckBeanHomeImpl_WLStub: This error could indicatethat a component
    was deployed on
    a cluster member but not other members of that
    cluster.
    Make
    sure that any componen
    t deployed on a server that is part of a cluster
    is
    also deployed
    on all other member
    s of that cluster
    java.lang.ClassNotFoundException:examples.ejb20.basic.statelessSession.TradeCheckBea
    nHomeImpl_WLStub: This error could indicate that
    a
    component was
    deployed on a clus
    ter member but not other members of that cluster.
    Make
    sure that
    any component deploy
    ed on a server that is part of a cluster is also
    deployed
    on all
    other members of tha
    t cluster
    <<no stack trace available>>
    I would appreciate any help.
    Thanks,
    kamps
    "Mahendra Dhamdhere" <[email protected]> wrote:
    you need to get initialcontext of that server.
    Context ctx = null;
    Hashtable ht = new Hashtable();
    ht.put(Context.INITIAL_CONTEXT_FACTORY,
    "weblogic.jndi.WLInitialContextFactory");
    ht.put(Context.PROVIDER_URL, "t3://localhost:7001");
    try
    ctx = new InitialContext(ht); // Use
    the
    context
    in your program
    } catch (NamingException e)
    {    // a failure occurred  }
    finally {    try {ctx.close();}
    catch (Exception e)
    {      // a failure occurred    } }
    use url of that other server. After getting initialcontext,
    lookup for your
    ejb.
    Mahendra
    kampu S <[email protected]> wrote in message
    news:[email protected]...
    Hi,
    I want to reference an EJB on one host inside
    another
    EJB in another
    host. Even if i hardcode the url of the host on
    which
    the EJB is
    deployed , it gives me the error regarding the
    no
    such
    ejb found.
    I would appreciate your help.
    Thanks

  • Calling EJB from another EJB

    I need to make a several calls to the methods inside EJB1 from EJB2. I was getting
    the remote reference of the EJB2 inside the ejbCreate() of the EJB1, is it a good
    practice ?? If not, do I need to get remote reference of the EJB2 every time I
    need to call EJB2 method??
    Thanks in advance.

    To refer a Ejb from another Ejb include <ejb-ref> in ejb-jar.xml
    <session>
    <ejb-name>Ejb1</ejb-name>
    <ejb-ref>
    <ejb-ref-name>Ejb2</ejb-ref-name>
    <ejb-ref-type>Entity</ejb-ref-type>
    <home>com.ejb.Ejb2Home</home>
    <remote>com.ejb.Ejb2</remote>
    </ejb-ref>
    <session>
    Include a <reference-discriptor> in weblogic-ejb-jar.xml
    <weblogic-enterprise-bean>
    <ejb-name>EjbSession</ejb-name>
    <reference-descriptor>
    <ejb-reference-description>
    <ejb-ref-name>Ejb2</ejb-ref-name>
    <jndi-name>com.ejb.Ejb2Home</jndi-name>
    </ejb-reference-description>
    </reference-descriptor>
    </weblogic-enterprise-bean>
    In Ejb1 bean class refer to Ejb2 method with a remote reference to Ejb2.
    InitialContext initialContext = new InitialContext();
    Ejb2Home ejb2Home = (Ejb2Home)initialContext.lookup("com.ejb.Ejb2Home");
    Ejb2 ejb2 = ejb2Home.findByPrimaryKey();
    Alex Pratt wrote:
    I need to make a several calls to the methods inside EJB1 from EJB2. I was getting
    the remote reference of the EJB2 inside the ejbCreate() of the EJB1, is it a good
    practice ?? If not, do I need to get remote reference of the EJB2 every time I
    need to call EJB2 method??
    Thanks in advance.

  • Error in calling an EJB from another EJB

    Hello All,
    I have a scenario where i need to call a method of an ejb from another ejb.
    Both the EJB's are in different DC's.
    EG: DC1 using DC2
    I have added the public part of DC2 in DC1.
    The following code is written in DC1 to access the EJB of DC2
          MyRemote l_remote;
           MyHome l_home;
           InitialContext l_ctx = new InitialContext();
    >>       l_home = (MyHome)l_ctx.lookup("JNDI Name");
           l_remote = (MyRemote)l_home.create();
    There is no error at build time and deploy time, but at run time "MyHome" class is not found.
    Even i am not able to access the helper class defined in the DC2 at runtime.
    Please help.
    Thanks in Advance

    First off, wrong forum section.
    Check if your JNDI name is correctly placed for the bean you're calling -- check j2ee-engine.xml for that. Check the EJB container if the ear file you deployed is there and updated.
    Try placing  "localejbs/JNDI name" on your lookup parameter.
    Regards,
    Jan

  • How tom invoke an EJB from another EJB using the sun rmi protocl in Weblogi

    Hi,
    I am particularly new to EJB.
    My scenario is
    client invoking-->EJB-----invoking ----(Either a webService or an EJB)
    in WEBLOGIC
    Is it possible that a call from EJB to another EJB or WebService use Sun's RMI as underlying protocol instead of t3 or IIOP which are used in Weblogic ?
    Would be really a great help if you could provide me some sample on it on weblogic.

    Hi Stefan,
    You don't need to provide the InitialContextFactory for running a standalone client. The following should work just fine:
    Context initial = new InitialContext();
    System.out.println("Looking up ...");
    Object objref = initial.lookup(EJB);  //the lookup name should be a global JNDI name      //and not from the java:comp namespace
    System.out.println("Looked up EJB");The JNDI implementation looks for the jndi.properties file in your classpath. So make sure that you have the appserv-rt.jar from your <server_installation>/lib directory in your classpath.
    HTH,
    Sheetal

  • CallerPrincipal when calling one sessionbean from another

    Hi all,
    I have a little problem when calling one sessionbean from another sessionbean. The problem is, that in the method, which is called, is used SessionContext's getCallerPrincipal().getName(). This works great from client, but from other sessionbeans getCallerPrincipal() retuns an "ANONYMOUS" principal. How can I set the correct principal (the principal from the first sessionbean)?
    Thank you
    My env: Glassfish 2.1.1, Netbeans 6.8, Eclipselink 2.0.0, Java 1.6.0.18
    My code:
    @Stateless
    public class ABean implements ASessionRemote{
    @Resource
    SessionContext ctx;
    @Override
    public void aMethod(){
    String name = ctx.getCallerPrincipal().getName(); // the name is ANONYMOUS, when the call is done from other sessionbean
    @Stateless
    public class BBean implements BSessionRemote{
    @Resource
    SessionContext ctx;
    @EJB
    private ASessionRemote aSessionBean;
    @Override
    public void bMethod(){
    aSessionBean.aMethod();
    }

    "This works great from client"
    What do you mean by this, i.e what sort of client are you using (stand alone app, servlet) ?
    what shows up if you printout the caller principal in the calling bean ?
    are the two ejbs in the same ear ?
    what security meta-information are you using in ejb-jar.xml and sun-ejb-jar.xml, if any ?

Maybe you are looking for