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

Similar Messages

  • 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);

  • How to use one hash table inside another hash table

    Hi everyone,
    Any example of hash table inside another hash table.
    Can one here help me how to write one hash table inside another with repeating keys for the first hash table.
    Thanks,
    kanty.

    Do you mean you want the 'value' entries in a hash table to themselves be hash tables? Easy but this often indicates a design flaw.
    Hashtable<String,<Hashtable<String,Value>> fred = new Hashtable<String,<Hashtable<String,Value>> ();But what do you mean by "with repeating keys for the first hash table"?
    Edited by: sabre150 on Jul 2, 2010 10:11 PM
    Looks like you have already handled the declaration side in your other thread. I suspect you should be writing your own beans that hold the information and these beans would then be stored in a Map. The problem I have is that your description is too vague so I can't be certain.

  • 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

  • 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 when One EJB calls anothe EJB

    Hi,
    I got the following error when I use one EJB call another EJB in OAS 4.0.8.1, the code is developed in JDeveloper 3.0/Win NT 4.0/SP5.
    Can anyone give me some ideas? or is there any samples in this case?
    Thanks a lot!
    Creating an initial context
    Looking for the EJB published as 'APP/APPEJB'
    Creating a new EJB instance
    Calling APPEJB methods...
    CORBA: org.omg.CORBA.BAD_OPERATION: ; nested exception is:
    org.omg.CORBA.BAD_OPERATION:
    java.rmi.ServerException: CORBA: org.omg.CORBA.BAD_OPERATION: ; nested exception is:
    org.omg.CORBA.BAD_OPERATION:
    at javax.rmi.oas.corba.CorbaRemoteExceptionHelperValue.OBVObjFrom(Compiled Code)
    at TwoEJB._stub_APPEJB.callEJBMapping(Compiled Code)
    at TwoEJB.TwoEJBClient.main(Compiled Code)
    null

    Home handle is an object that identifies an enterprise bean. A client may serialize the handle, and then later deserialize it to obtain a reference to the enterprise bean.
    The javax.ejb.HomeHandle is similar to javax.ejb.Handle. Just as the Handle is used to store and retrieve reference to EJB objects, the HomeHandle is used to store and retrieve remote references to EJB homes. HomeHandle can be stored and later used to access an EJB home remote refrence the same way that a Handle can be serialized and later used to access an EJB object's remoe reference.
    import java.io.*;
    import javax.ejb.EJBHome;
    import javax.ejb.HomeHandle;
    public class WorkingWithEJBHandles {
    public static void main( String[] args ) throws Exception {
    EJBHome aHome = null;
    // get hold of a home interface
    HomeHandle handle = aHome.getHomeHandle();
    ByteArrayOutputStream bos = new ByteArrayOutputStream();
    ObjectOutputStream oos = new ObjectOutputStream( bos );
    oos.writeObject( handle );
    byte[] handleAsBytes = bos.toByteArray();
    // store in the database, on file. howwever you want
    FileInputStream fis = new FileInputStream( "fileobj" );
    ObjectInputStream ois = new ObjectInputStream( fis );
    HomeHandle theHandle = (HomeHandle) ois.readObject();
    // get back the EJBHome from the HomeHandle
    aHome = theHandle.getEJBHome();
    // the same kind of logic also holds for EJBHandles, as well as
    // HomeHandles
    Transfer Object is a Design pattern. Refer to Core J2EE Design Pattern.
    http://java.sun.com/blueprints/corej2eepatterns/Patterns/TransferObject.html
    Rgds,
    Seetesh

  • Can an EJB extend another EJB?

    Can an EJB extend another EJB?
    Are there any limitations?
    Thank you in advance, Kostas

    Refer
    http://archives.java.sun.com/cgi-bin/wa?A2=ind0106&L=ejb-interest&F=&S=&P=31185

  • 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

  • EJB calling another EJB - special considerations

    I am trying to call an EJB from another EJB in the same container. I am able to get hold of the home interface but get an error when I try to narrow and get the Bean.
    The error I get is a class cast exception. Cannot narrow ....
    I read in some place that we need to do soemthing special with the DD's to achieve this. Any answers. I can post more code examples or send you samples.
    Any help will be gr8tly appreciated.
    Vijay

    Hi,
    If ure able to get the Home then you must call the create method on the home to create the Bean and not narrow it again. I think you use narrowing to get the Home and not the bean.
    I hope this helps
    neo

  • After installing Mountain Lion, why is there Yahoo access for one user but not another?--both are administrators.

    After installing Mountain Lion, why is there Yahoo access for one user but not another?--both are administrators.

    We've had several instances where we have had to run chkdsk on arrays with over 1m files. Average completion time is approximately 72 hours. The maximum downtime window they have available is the 64 hour weekend window. File sizes and number of files were
    much smaller then than they are now.
    The idea, in theory, was to use VHDs to compartmentalize the data into smaller volumes which could be more easily managed. It would also improve performance when transferring these compartments of data as they would use sequential read/write rather than
    fragmented/random. This idea was never fleshed out in entirety, they don't split data up into little containers, but simply into big ones per project. Hence the 11m files in one container that I am currently trying to diagnose.
    Some other important facts: The VHD in question is mounted in B:/project/ as this server also allows remote workers to log in, but they are restricted to see only data in E:. Disks A-D are hidden via group policy.
    Update: icacls is failing on a large number of files within this dataset. I counted the path characters to ensure it wasn't the 255 character limit I was encountering and verified that the paths being blocked are only about 150 characters long. Once it finishes,
    I'll have to try taking ownership and then re-running it. At this point I still have no idea how long to expect. I'm running out of time as the environment will be in use again at 9AM tomorrow morning.

  • In Mountain Lion how does OS select between ethernet and WiFi when both are activated??

    In Mountain Lion how does OS select between ethernet and WiFi when both are activated??  How does OS use "both" networl accesses??

    It will pick the highest service in the list which has an internet connection.
    To order the list, open Network System Preferences and select Set order of network services from the button below the service list.

  • HELP!!! How I can call to EJB from another EJB??

    I have two EJBs, for each EJB I have a jar, how I can call to EJB jar to another???
    I have tried the following, in the first EJB I have import the second EJB jar and call it with context, lookup, PortableRemoteObject etc.. but the instruction lookup not find the second EJB reference.
    The name in the lookup instruction is the JNDI name of the second EJB but not find a reference to it.
    Please help me!!! Thanks!!
    The error is:
    javax.naming.NameNotFoundException: Missing node. Root exception is org.omg.CosNaming.NamingContextPackage.NotFound
         at org.omg.CosNaming.NamingContextPackage.NotFoundHelper.read(NotFoundHelper.java:34)
         at org.omg.CosNaming.NamingContextPackage.NotFoundHelper.extract(NotFoundHelper.java:50)
         at org.omg.CosNaming._NamingContextStub.resolve(_NamingContextStub.java:161)
         at com.inprise.j2ee.jndi.java.CorbaContext.resolveName(CorbaContext.java:242)
         at com.inprise.j2ee.jndi.java.CorbaContext.lookup(CorbaContext.java:261)
         at com.inprise.j2ee.jndi.java.javaContext.internal_lookup(javaContext.java:483)
         at com.inprise.j2ee.jndi.java.javaContext.internal_lookup(javaContext.java:493)
         at com.inprise.j2ee.jndi.java.javaContext.internal_lookup(javaContext.java:493)
         at com.inprise.j2ee.jndi.java.javaContext.lookup(javaContext.java:937)
         at com.inprise.j2ee.jndi.java.javaContext.lookup(javaContext.java:942)
         at javax.naming.InitialContext.lookup(InitialContext.java:350)
         at ejbclient.EnterpriseClientBean.addition(EnterpriseClientBean.java:115)
         at ejbclient.EnterpriseClientBean.actionPerformed(EnterpriseClientBean.java:97)
         at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1450)
         at avax.swing.AbstractButton$ForwardActionEvents.actionPerformed(Abstr

    ok.. Here it goes.. I am writing a sample code..
    public class EJB1LogBean implements SessionBean {
    // test is a method of stateless session beam
    public void test ( TestVal val )
    throws RemoteException{
    try {
    EJB2LogHome ejb2Home= (EJB2LogHome)getHome("java:comp/env/ejb/EJB2LogHome",1);
    EJB2Log ejb2Log = ejb2LogHome.create ( val );
    } catch ( CreateException e ) {
         System.out.println("Create Exception occurred ");
         e.printStackTrace();
         } catch ( RemoteException e ) {
         System.out.println( "RemoteException Occured");
    e.printStackTrace();
         throw new RemoteException () ;
         } catch(Exception ee) {
    ee.printStackTrace();
    private EJBHome getHome(String jndiName,int type) {
    try {
    Context context = new InitialContext();
    Object ref = context.lookup( jndiName );
    switch(type)
    case 1:
    EJB2LogHome ejb2LogHome = ( EJB2LogHome )
    PortableRemoteObject.narrow( ref, EJB2LogHome.class );
    return ejb2LogHome;
    } catch ( Exception e ) {
    e.printStackTrace();
    return null;
    }//EJB1LogBean ends
    Here as you can see, EJB1LogBean(session bean) is calling a second EJB, EJB2LogBean (entity bean). TestVal is a sample value object passed. It is plain java class and can vary from app to app and it has got nothing to do with ejbs.
    "java:comp/env/ejb" is a J2EE standard and while getting a home interface, you have to append the home interface class name to "java:comp/env/ejb". Here I am passing "java:comp/env/ejb/EJB2LogHome" and "1" to getHome method, whose job is to get a reference to a home interface. getHome method is a local method. "1" is passed just to give a flexibility to getHome method as you can have more ejbs to invoked. In that case, you can go on adding different case statements for 2, 3 etc.
    The only thing you have to keep in mind is that your deployment descriptor for EJB1LogBean will contain the entires for both the beans i.e. for EJB1LogBean and EJB2LogBean. This is because EJB2LogBean is wrapped by EJB1LogBean.
    Hope this helps.
    Please let me know if you need anything more.
    - Amit

  • How to access a variable from inside another symbol

    So i did this tutorial, Leveraging Independent Symbol Timelines created by Eliane...it's rockin, btw.  ;-)
    All's well but now i have a symbol on the stage called mc-home.  inside of mc-home is a button called btn-go.
    On the stage in composition ready there's a variable sym.setVariable("current", "mc-home");
    This code works for a symbol that's on the stage but, how do i get this code to work on a button that's inside another symbol that's on the stage?
    var current = sym.getVariable("current");
    if (current != "") {
        sym.getSymbol(current).play("OUT");
    sym.getSymbol("mc-something").play("IN");
    sym.setVariable("current", "mc-something");

    sorry, i was kind of confused myself too, don't worry about it but thanks for your patience for reading it anyway

  • How to import ADF JS packages inside another javascript

    Hi,
    I need to import the ADF Faces javascript packages inside another javascript,
    to be able, inside this javascript, to access the page components.
    How can I do this ?

    You can't embed one jspx inside other, you need to use jsf page fragments for this.
    Approach 1:
    - Create a page fragment for the second page(second.jsff)
    - Include this in first.jspx page using jsp:inpclude tag as in sample below:
    <!-- first.jspx -->
        <af:document id="d1">
          <af:form id="f1">
            <af:outputText value="First Page"/>
            <af:commandLink text="Include Second" id="includeLink" partialSubmit="true">
              <af:setActionListener from="true" to="#{requestScope.includeSecond}"/>
            </af:commandLink>     
            <af:panelGroupLayout visible="#{requestScope.includeSecond eq true}"
                                 partialTriggers="includeLink">
              <jsp:include page="/second.jsff"/>
            </af:panelGroupLayout>  
          </af:form>
        </af:document>Approach 2:
    - Create a bounded taskflow with page fragments and drop a view and generate second.jsff for this view
    - Drop this taskflow as region inside first.jspx and set the visible property as given above in sample code to show only on clicking commandImageLink
    Sireesha

  • How can I insert a folder inside another folder

    is it possible to have sub folders
    I want to create 3 main folder
    MainFolder 1, mainfolder2, mainfolder3
    And I want to have 5 folders inside mainfolder 1
    so when the user click on mainfolder 1 , will see 5 folder in it , not next to it
    sincerely yours
    Riade Asleh

    So far I have not got any solution
    i want a folder inside another folder
    for example
    i have to main folders , folder 1 , folder2
    folder1.top =25
    folder1.left =10
    folder2.top =25
    folder2.left =115
    now, I wan a sub folders inside folder1
    subfolder1.top =50 not 25
    subfolder1.left =30
    I dont' want the subfolder1 to have the same top as folder1.top
    it's seems that all folders must have the same top value
    because when I changed the value of the subfolder1.top to 50, the value of folder1.top, and folder2.top  changed to 50, in which i don't want it to behave like that
    if you have a sample code,  please sent it to me
    sincerely yours
    Riade Asleh

Maybe you are looking for