How to access an EJB in another J2ee server?

Dear experts:
I have a jsp file that is a client of a J2ee server A, and I am going to access an EJB that is situated in J2ee server B from this jsp file.
It will be very appreciate if you can tell me how to do that. My current program is:
try
Properties props = new Properties();
props.setProperty(Context.PROVIDER_URL, "rmi://ip:port");
Context initial = new InitialContext(props);
Object objref = initial.lookup("MyUserEJB");
UserHome home = (UserHome) PortableRemoteObject.narrow(objref, UserHome.class);
Collection users = home.findByName("alin");               
for(Iterator i=users.iterator(); i.hasNext();)
User user = (User)i.next();
System.out.println("User " + user.getFirstName() + " details:\n");
System.out.println("     email     : " + user.getEmail() + "\n");
catch (Exception e)
System.err.println("Caught an exception.");
e.printStackTrace();
In which, the MyUserEJB is an EJB in ip:port J2ee server (server B). The server A is localhost:1050. This program does not work.
Best regards,
Alan

Hi,
Have a look at
http://forum.java.sun.com/thread.jsp?thread=365927&forum=136&message=1543094

Similar Messages

  • How to run the ejb project in j2ee server

    How to run the EJB project.
    I give like
    java conveterClient converterClient.jar
    here conveterClient is class file name and converterClient.jar is deployed file
    like wise i give some exception is come
    give some help pls friends

    Navigate to the "DBOrders" module in the catalog, right click on the "ORDERS" database below and click "Export Schema Stucture". That will produce a file containing the DML needed to create the database

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

  • Calling EJBs from other EJBs in other J2EE Server?

    How can I call one EJB on one J2EE Server from other
    EJB on other J2EE Server?
    Help me, please.
    Dmitry Tumanov

    Basically call the beans as if you were calling them in the same server through their remote interfaces. Get a InitialContext into the other appserver and then get the home object, narrow it and create a remote reference. You can follow the standard implementation just make sure that the InitialContext you create has the right properties, ie. context factory, urls, etc to the OTHER appserver.

  • How to view the dispatched mails in J2EE server???

    Hi All,
    I want to view how many mails have  been sent from the J2EE server. May I know how we can see this in NetWeaver AS JAVA? As we can view in ABAP stack using SOST tcode, this will show the list of user who have been sent mails from SAP system for a particular criterion. However, I dont find any such option in J2EE server. I see a challenge here to confirm to the buusiness that how many mails have been sent from J2EE server.
    Please help me finding out a way to this.
    Regards,
    Fisal

    Hi Mr!
    If you want to generate the e-file feature 40ACK, do it in our Customization client box (Golden box) & save the request & move to Quality & production.
    Still if you need to workout only in Production, than with the help of Basis people you can get the Production change mode for 5 to 10 min time & can generate it. But mostly Basis people wont give us change mode for Production box ... with ur request they can do..try it.
    Did u collected 4 quarter TAN no's for 2008 Quarter...if not collect it & generate it at a time.
    All the best:-)
    Kind Regards,
    Saisree.S

  • How i access file which stored at application server .? Is there any fm ?

    Hi,
    How i access file which stored at application server . Is there any function module which provide same funtinality.
    Regards,
    Gurprit Bhatia

    Hi ,
            U need to use datasets for reading data from application server.Do a f1 on dataset,u will get to know rest of the things.
    TRY.
        OPEN DATASET file FOR INPUT IN TEXT MODE ENCODING UTF-8.
      ENDTRY.
      IF sy-subrc = 0.
          READ DATASET file INTO <wa_data> MAXIMUM LENGTH 200.
               move the data in to internal table
        close dataset
    Edited by: A kumar on Aug 21, 2008 1:37 PM

  • Calling EJB from other EJB on other J2EE Server

    Can I call EJB from other EJB on other J2EE Server
    Servers - Websphere 5.0
    Do i require home & remote interface of that ejb on client side also
    Help me, please

    the problem is actually i require that is specific to websphere
    for example i want to call a method ion that ejb
    say my ejb name is myejb
    so the normal way i should call is
    InitialContext initialContext = new InitialContext();     
    Object homeObject = initialContext.lookup("ejb/MyEjbHome");
    MyEJBHome myEJBHome =(MYEjbHome )javax.rmi.PortableRemoteObject.narrow(homeObjectMYEjbHome.class);
              myEJB = lSHome.create();
    myEJB.someMethod();
    but here i am having class for home and remote available
    now if other app server i am not having this classes then what to do

  • How to access icloud account from another iphone

    My iphone fell in the water. I am on vacation and need to access info from my calendar. How can i do it from another iphone device?

    Just enter your account details under:
    Settings > Mail, Contacts, Calendar
    and add your account.
    Finished.

  • How to access the ejb using WSIF

    I have deployed my Bean Managed Persistance Entity Bean in Weblogic 8.1 App Server. Trying to access the ejb from Synchronous BPEL process using WSIF. I am getting following error
    - WSIF0011I: Preferred port 'EJBPort' was not available
    org.apache.wsif.WSIFException: Unable to find an available port
         at org.apache.wsif.base.WSIFServiceImpl.getPort(Unknown Source)
         at org.apache.wsif.base.WSIFServiceImpl.getPort(Unknown Source)
         at com.test.wsif.RunInventory.main(RunInventory.java:55)
    How to resolve the above said problem??
    Here is my Inventory.wsdl file
    <?xml version="1.0" ?>
    <definitions targetNamespace="http://wsifservice.Inventory/"
    xmlns:tns="http://wsifservice.Inventory/"
    xmlns:typens="http://wsiftypes.addressbook.service.ejb/"
    xmlns:xsd="http://www.w3.org/1999/XMLSchema"
    xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
    xmlns:format="http://schemas.xmlsoap.org/wsdl/formatbinding/"
    xmlns:ejb="http://schemas.xmlsoap.org/wsdl/ejb/"
    xmlns="http://schemas.xmlsoap.org/wsdl/">
    <!-- type defs -->
    <types>
    <xsd:schema
    targetNamespace="http://wsiftypes.addressbook.service.ejb/"
    xmlns:xsd="http://www.w3.org/1999/XMLSchema">
    <xsd:complexType name="vecdetails">
    <xsd:sequence>
    <xsd:element name="make" type="xsd:string"/>
    <xsd:element name="bodystyle" type="xsd:string"/>
    <xsd:element name="model" type="xsd:string"/>
    <xsd:element name="quantity" type="xsd:int"/>
    </xsd:sequence>
    </xsd:complexType>
    </xsd:schema>
    </types>
    <!-- message declns -->
    <message name="getInventoryRequestMessage">
    <part name="vecdetails" type="typens:request"/>
    </message>
    <message name="getInventoryResponseMessage">
    <part name="response" type="typens:response"/>
    </message>
    <!-- port type declns -->
    <portType name="Inventory">
    <operation name="getInventory">
    <input name="getInventoryRequest" message="tns:getInventoryRequestMessage"/>
    <output name="getInventoryResponse" message="tns:getInventoryResponseMessage"/>
    </operation>
    </portType>
    <!-- binding declns -->
    <binding name="EJBBinding" type="tns:Inventory">
    <ejb:binding/>
    <format:typeMapping encoding="Java" style="Java">
    <format:typeMap typeName="xsd:string" formatType="java.lang.String" />
    </format:typeMapping>
    <operation name="getInventory">
    <ejb:operation
    methodName="getInventory"
    parameterOrder="make bodystyle model quantity"
    interface="remote" returnPart="response" />
    <input name="getInventoryRequest"/>
    <output name="getInventoryResponse"/>
    </operation>
    </binding>
    <!-- service decln -->
    <service name="InventoryService">
    <port name="EJBPort" binding="tns:EJBBinding">
    <!-- Put vendor-specific deployment information here -->
         <ejb:address className="com.poc.inventoryejb.InventoryHome"
              jndiName="Inventory"
    initialContextFactory="weblogic.jndi.WLInitialContextFactory"
         jndiProviderURL="t3://localhost:7001"/>
    </port>
    </service>
    </definitions>

    Try to restart BPEL Server. When I tested WSIF Bindings I had to restart server after every changes in WSIF WSDL.
    Alexey.

  • How to access Enterprise manager from another computer

    Hi There,
    I have Oracle 10g installed on a PC. I can access EM from that PC.
    I would like to know how would I access EM Dbconsole from another computer under same LAN.
    Thanks
    Raf

    Opening the web browser, you can specify the hostname and the port configured to listen the incoming call.
    For example:
    https://hostname:port_number/em
    or
    https://ip_address:port_number/em
    you can get information about the information that you need from the "emctl"
    emctl status dbconsole
    Oracle Enterprise Manager 11g Database Control Release 11.2.0.1.0
    Copyright (c) 1996, 2009 Oracle Corporation. All rights reserved.
    https://hostname:1158/em/console/aboutApplication
    Oracle Enterprise Manager 11g is not running.
    Best regards !
    Shin-Iti.

  • How to access an EJB from a web application deployed in the same server

    Hey All,
    I deployed an EJB named EventServerBean to Sun Application Server 9.0, and put the client side jar file (named eventserver.jar which is generated by Sun Application Server) to C:\Sun\AppServer\lib. Now, I have a web application which is a simple jave file -- lookup EventServer EJB and invoke a remote method in this EJB. However, the web application always throws an exception "java.lang.NoClassDefFoundError: eventserver/EventServerRemoteHome"
    Here is my java class that access the ejb:
    public class Post_Event {
        public HashMap<String, String> getEventInfo(String event_name, String site) {
            System.out.println("Post_Event, the class path: " + System.getProperty("java.class.path"));       
            System.out.println("Post_Event, user.dir: " + System.getProperty("user.dir"));
            System.out.println("Post_Event, java.library.path: " + System.getProperty("java.library.path"));
            HashMap<String, String> result = null;
            EventServerRemote remote = null;
            StringTokenizer st, st2;
            // here get the event information from host
            try {
                String lookupStr = "corbaname:iiop:" + site + ":3700#ejb/EventServerBean";
                InitialContext initialContext = new InitialContext();
                EventServerRemoteHome remoteHome = (EventServerRemoteHome) javax.rmi.PortableRemoteObject.narrow(initialContext.lookup(lookupStr), EventServerRemoteHome.class);
                if (remoteHome != null) {
                    remote = remoteHome.create();
            } catch (javax.naming.NamingException ne) {
                ne.printStackTrace();
                return null;
            } catch (javax.ejb.CreateException ce) {
                ce.printStackTrace();
                return null;
            } catch (java.rmi.RemoteException re) {
                re.printStackTrace();
                return null;
            } catch (java.io.IOException ioe) {
                ioe.printStackTrace();
                return null;
            System.out.println("look up remote event server successfully.");
         result = remote.getEvent(event_name);
            return result;
        } I output the class path in this java file, and the class path DOES include the path C:\Sun\AppServer\lib where eventserver\EventServerRemoteHome.class is.
    Does anyone know why it happens? Why a java class can't find a class that is in its class path?
    appreciate any help!

    <BLOCKQUOTE><font size="1" face="Verdana, Arial">quote:</font><HR>Originally posted by Wael Abbas ([email protected]):
    Thank you for your great topic.
    I think you need to copy the snippet code and past it to every application, applet, servlet or JSP every time you need to use your EJB.
    Its better to include this snippet code in a simple JavaBean and use this bean as a bridge to your EJB, you may include a connect method in your JavaBean or but the connection code in the constructor and include a setters, getters and other methods to encapsulate your EJB methods.
    You can use your JavaBean in any application, applet, servlet or JSP just create an object form it and call its methods.
    Its just an idea
    I hope it will be useful.
    <HR></BLOCKQUOTE>
    null

  • How to access my mail from another computer. Both iPads

    HHow to access my mail from another computer. Both iPads. Both iCloud.

    add the email account to your email software like with any email service, or go to www.iCloud.com

  • How to call an EJB from another EJB

    Hi
    I have a problem here. I need to execute a second EJB which has to get the input from the first EJB as data for execution. So when I call the first EJB, the first EJB should give the data to the second EJB and execute it and provide the result.
    Cheers,
    Raj

    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 the view from another Component

    Hi,
    Seek your advice on this following requirement.
    1. Would like to add the view OVWindow of Component BTCATEGORIES in an assignment block of 
        CRMCMP_CMG similar to the assignment block exists in the BT116H_SRVO component.
    2. Please provide the step by step procedure to implement this requirement.
    Regards,
    Arif

    Hi,
       I am having view1 and view2.
      in view1 i am using roadmap. S1 is one of the step of road map.
      in view1 i used this code to get the reference of this view in componentcontroller attribute
    Data: lo_api TYPE REF TO if_wd_view_controller.
    If first_time = 'X'.
    lo_api = wd_this->wd_get_api( ).
    wd_Comp_Controller->my_VIEW = lo_api.
    endif.
    in my view2 i want to access the roadmap step
    i dono how to access that.. i used this code.......
             wd_comp_controller->my_view->get_element( 'S1' ).
    is this correct.. If not what is the code to get that id..
    Can any one tell me clearly...

  • How to access fied value to another fied

    hi experts,
    how can access the one field value to onther field in a view level.

    Hi,
    In case its a same context node then you would have that value present in Current entity. Just use method get_property/get_property_as_value/get_property_as_string and you would get it.
    Syntax:
    lv_value = lr_entity->get_property_as_string( '*ATTRIBUTENAME*' ).
    if its different context node of same component then please refer to below article by Suchita.
    http://wiki.sdn.sap.com/wiki/pages/viewpage.action?pageId=201066680
    Trust this solves your issue.
    Regards,
    BJ

Maybe you are looking for

  • Vista-scan and fix?

    When I connect my 5th Gen ipod to the notebook i get a message from Vista asking whether it wants me to scan and fix my device. I have downloaded the latest MS Vista updates and patches but this still occurs. Looking on the web I have seen a solution

  • Data fields selected in a form are not displaying

    I have selected "Size" & "Outlook Data File" as 2 fields that I need to see on the front tab of all my contacts.  In testing to see if it works I opened a new contact (blank).  Upon it trying to open I get the same error twice  "The Property does not

  • ** CONTACT MANAGER and CONTACT CATEGORIES **

    I am a 9930 owner. Is there any discussion about fixing the Contact Manager in the new OS to include more of vCard fields as in BB OS version 7x and prior? We need Contact Categories field in the Contact Manager and the tight integration with MS Outl

  • Manual Posting TDS

    Dear Friends,       I am posted Manual TDS throu T.Code F-02 TDS Payable A/C ---Dr To Vendor----Cr. After removing the automatic posting check box for GL Account. I have a problem when creating Rimittence Challan. There is no TDS is availabele in J1I

  • Adding custom field to product master general tab

    Hi All,          i want to add a custom field in Product master creation (commpr01) ,could any one help me out on this ! Many thanks and Regards.