Reconnect remote EJB using ORMI through RMI Tunnel

Hello!
My client application connecting to server EJB using ORMI.
Hashtable env = new Hashtable();
env.put(Context.INITIAL_CONTEXT_FACTORY, "oracle.j2ee.rmi.RMIInitialContextFactory");
env.put(Context.SECURITY_PRINCIPAL, "admin".toUpperCase());
env.put(Context.SECURITY_CREDENTIALS, passwordEncoder.encodePassword("admin", null).toUpperCase());
env.put(Context.PROVIDER_URL, "ormi:http://host:7777/application");
First connection passed. All works.
But if connection between client and server broken, then client must reconnect to server... But it can't.
Client pending and not response.
I dump threads on client pending:
First thread:
java.lang.Thread.State: TIMED_WAITING (on object monitor)
     at java.lang.Object.wait(Native Method)
     - waiting on <0x230962d8> (a java.lang.Object)
     at EDU.oswego.cs.dl.util.concurrent.LinkedQueue.poll(LinkedQueue.java:192)
     - locked <0x230962d8> (a java.lang.Object)
     at oracle.oc4j.rmi.tunnelling.TunnelledRmiTransport$PluggableInputStream.read(TunnelledRmiTransport.java:208)
     - locked <0x2308ac90> (a oracle.oc4j.rmi.tunnelling.TunnelledRmiTransport$PluggableInputStream)
     at oracle.oc4j.rmi.tunnelling.TunnelledRmiTransport$PluggableInputStream.read(TunnelledRmiTransport.java:190)
     - locked <0x2308ac90> (a oracle.oc4j.rmi.tunnelling.TunnelledRmiTransport$PluggableInputStream)
     at java.io.BufferedInputStream.fill(BufferedInputStream.java:218)
     at java.io.BufferedInputStream.read(BufferedInputStream.java:237)
     - locked <0x2308cd68> (a java.io.BufferedInputStream)
     at java.io.ObjectInputStream$PeekInputStream.peek(ObjectInputStream.java:2249)
     at java.io.ObjectInputStream$BlockDataInputStream.readBlockHeader(ObjectInputStream.java:2429)
     at java.io.ObjectInputStream$BlockDataInputStream.refill(ObjectInputStream.java:2499)
     at java.io.ObjectInputStream$BlockDataInputStream.read(ObjectInputStream.java:2571)
     at java.io.ObjectInputStream.read(ObjectInputStream.java:820)
     at com.evermind.server.rmi.RMIConnection.readCommand(RMIConnection.java:162)
     at com.evermind.server.rmi.RMIConnection.handleCommand(RMIConnection.java:149)
     at com.evermind.server.rmi.RMIConnection.listenForOrmiCommands(RMIConnection.java:127)
     at com.evermind.server.rmi.RMIConnection.run(RMIConnection.java:107)
     at EDU.oswego.cs.dl.util.concurrent.PooledExecutor$Worker.run(PooledExecutor.java:814)
     at java.lang.Thread.run(Thread.java:619)
Second thread:
java.lang.Thread.State: WAITING (on object monitor)
     at java.lang.Object.wait(Native Method)
     - waiting on <0x229c0bc8> (a com.evermind.server.rmi.RMICall)
     at java.lang.Object.wait(Object.java:485)
     at com.evermind.server.rmi.RMIClientConnection.waitForResponseFromServer(RMIClientConnection.java:758)
     - locked <0x229c0bc8> (a com.evermind.server.rmi.RMICall)
     at com.evermind.server.rmi.RMIClientConnection.waitForJndiResponse(RMIClientConnection.java:370)
     at com.evermind.server.rmi.RMIClientConnection.lookup(RMIClientConnection.java:179)
     at com.evermind.server.rmi.RMIClient.lookup(RMIClient.java:287)
     at com.evermind.server.rmi.RMIClientContext.lookup(RMIClientContext.java:51)
     at javax.naming.InitialContext.lookup(InitialContext.java:392)
     at StartUp$1.actionPerformed(StartUp.java:61)
Look's like client trying get response from server, but server not answered... But server is alive! Why so?
When i restart client all works fine...
Please help!

Hello!
My client application connecting to server EJB using ORMI.
Hashtable env = new Hashtable();
env.put(Context.INITIAL_CONTEXT_FACTORY, "oracle.j2ee.rmi.RMIInitialContextFactory");
env.put(Context.SECURITY_PRINCIPAL, "admin".toUpperCase());
env.put(Context.SECURITY_CREDENTIALS, passwordEncoder.encodePassword("admin", null).toUpperCase());
env.put(Context.PROVIDER_URL, "ormi:http://host:7777/application");
First connection passed. All works.
But if connection between client and server broken, then client must reconnect to server... But it can't.
Client pending and not response.
I dump threads on client pending:
First thread:
java.lang.Thread.State: TIMED_WAITING (on object monitor)
     at java.lang.Object.wait(Native Method)
     - waiting on <0x230962d8> (a java.lang.Object)
     at EDU.oswego.cs.dl.util.concurrent.LinkedQueue.poll(LinkedQueue.java:192)
     - locked <0x230962d8> (a java.lang.Object)
     at oracle.oc4j.rmi.tunnelling.TunnelledRmiTransport$PluggableInputStream.read(TunnelledRmiTransport.java:208)
     - locked <0x2308ac90> (a oracle.oc4j.rmi.tunnelling.TunnelledRmiTransport$PluggableInputStream)
     at oracle.oc4j.rmi.tunnelling.TunnelledRmiTransport$PluggableInputStream.read(TunnelledRmiTransport.java:190)
     - locked <0x2308ac90> (a oracle.oc4j.rmi.tunnelling.TunnelledRmiTransport$PluggableInputStream)
     at java.io.BufferedInputStream.fill(BufferedInputStream.java:218)
     at java.io.BufferedInputStream.read(BufferedInputStream.java:237)
     - locked <0x2308cd68> (a java.io.BufferedInputStream)
     at java.io.ObjectInputStream$PeekInputStream.peek(ObjectInputStream.java:2249)
     at java.io.ObjectInputStream$BlockDataInputStream.readBlockHeader(ObjectInputStream.java:2429)
     at java.io.ObjectInputStream$BlockDataInputStream.refill(ObjectInputStream.java:2499)
     at java.io.ObjectInputStream$BlockDataInputStream.read(ObjectInputStream.java:2571)
     at java.io.ObjectInputStream.read(ObjectInputStream.java:820)
     at com.evermind.server.rmi.RMIConnection.readCommand(RMIConnection.java:162)
     at com.evermind.server.rmi.RMIConnection.handleCommand(RMIConnection.java:149)
     at com.evermind.server.rmi.RMIConnection.listenForOrmiCommands(RMIConnection.java:127)
     at com.evermind.server.rmi.RMIConnection.run(RMIConnection.java:107)
     at EDU.oswego.cs.dl.util.concurrent.PooledExecutor$Worker.run(PooledExecutor.java:814)
     at java.lang.Thread.run(Thread.java:619)
Second thread:
java.lang.Thread.State: WAITING (on object monitor)
     at java.lang.Object.wait(Native Method)
     - waiting on <0x229c0bc8> (a com.evermind.server.rmi.RMICall)
     at java.lang.Object.wait(Object.java:485)
     at com.evermind.server.rmi.RMIClientConnection.waitForResponseFromServer(RMIClientConnection.java:758)
     - locked <0x229c0bc8> (a com.evermind.server.rmi.RMICall)
     at com.evermind.server.rmi.RMIClientConnection.waitForJndiResponse(RMIClientConnection.java:370)
     at com.evermind.server.rmi.RMIClientConnection.lookup(RMIClientConnection.java:179)
     at com.evermind.server.rmi.RMIClient.lookup(RMIClient.java:287)
     at com.evermind.server.rmi.RMIClientContext.lookup(RMIClientContext.java:51)
     at javax.naming.InitialContext.lookup(InitialContext.java:392)
     at StartUp$1.actionPerformed(StartUp.java:61)
Look's like client trying get response from server, but server not answered... But server is alive! Why so?
When i restart client all works fine...
Please help!

Similar Messages

  • 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

  • Error during JNDI lookup Accessing Remote EJB (access to web service restricted using declarative security model)

    Hello everyone,
    I developed a Web Service prototype accessing remote EJB using the EJB
    control with special syntax in the jndi-name attribute: @jws:ejb
    home-jndi-name="t3://10.10.245.70:7131/AccountDelegatorEJB"
    Everything works fine, but I get an error when I restrict access to my web
    service with a declarative security model by implementing steps provided in
    help doc:
    - Define the web resource you wish to protect
    - Define which security role is required to access the web resource
    - Define which users are granted the required security role
    - Configure WebLogic Server security for my web service(Compatibility
    Security/Users)
    I launch the service by entering the address in a web browser. When prompted
    to accept the digital certificate, click Yes, when prompted for network
    authentication information, enter username and password, navigate to the
    Test Form tab of Test View, invoke the method by clicking the button and I
    get the following exception:
    <error>
    <faultcode>JWSError</faultcode>
    <faultstring>Error during JNDI lookup from
    jndi:t3://10.10.245.70:7131/AccountDelegatorEJB[Lookup failed for
    name:t3://10.10.245.70:7131/AccountDelegatorEJB]</faultstring>
    <detail>
    <jwErrorDetail> weblogic.jws.control.ControlException: Error during JNDI
    lookup from jndi:t3://10.10.245.70:7131/AccountDelegatorEJB[Lookup failed
    for name:t3://10.10.245.70:7131/AccountDelegatorEJB] at
    weblogic.knex.control.EJBControlImpl.acquireResources(EJBControlImpl.java:27
    8) at
    weblogic.knex.context.JwsInternalContext.acquireResources(JwsInternalContext
    .java:220) at
    weblogic.knex.control.ControlHandler.invoke(ControlHandler.java:260) at
    ibas.AccountControl.getTransactionHistory(AccountControl.ctrl) at
    ibas.GetSecure.retrieveVisaHistoryTxn(GetSecure.jws:64) </jwErrorDetail>
    </detail>
    </error>
    I have a simple Hello method as well in my WebService (which is also
    restricted) and it works fine, but remote EJB access doesn't. I tested my
    prototype on Weblogic 7.2 and 8.1 platforms - same result.
    Is that a bug or I am missing some additional configuration in order to get
    that working. Has anyone seen similar behavior? Is there a known resolution?
    Or a suggested way to work around the problem?
    Thank you.
    Andre

    Andre,
    It would be best if this issue is handled as an Eval Support case. Please
    BEA Customer Support at http://support.beasys.com along with the required
    files, and request that an Eval support case be created for this issue.
    Thanks
    Raj Alagumalai
    WebLogic Workshop Support
    "Andre Shergin" <[email protected]> wrote in message
    news:[email protected]...
    Anurag,
    I removed "t3", still get an error but a different one (Unable to create
    InitialContext:null):
    <error>
    <faultcode>JWSError</faultcode>
    <faultstring>Error during JNDI lookup from
    jndi://secuser1:[email protected]:7131/AccountDelegatorEJB[Unable to
    create InitialContext:null]</faultstring>
    <detail>
    <jwErrorDetail> weblogic.jws.control.ControlException: Error during JNDI
    lookup from
    jndi://secuser1:[email protected]:7131/AccountDelegatorEJB[Unable to
    create InitialContext:null] at
    weblogic.knex.control.EJBControlImpl.acquireResources(EJBControlImpl.java:27
    8) at
    weblogic.knex.context.JwsInternalContext.acquireResources(JwsInternalContext
    .java:220) at
    weblogic.knex.control.ControlHandler.invoke(ControlHandler.java:260) at
    ibas.AccountControl.getTransactionHistory(AccountControl.ctrl) at
    ibas.GetVisaHistoryTransactions.getVisaHistoryTxn(GetVisaHistoryTransactions
    .jws:67) </jwErrorDetail>
    </detail>
    </error>
    Note: inter-domain communication is configured properly. The Web Service to
    remote EJB works fine without a declarative security.
    Any other ideas?
    Thank you for your help.
    Andre
    "Anurag" <[email protected]> wrote in message
    news:[email protected]...
    Andre,
    It seems you are using the URL
    jndi:t3://secuser1:[email protected]:7131/AccountDelegatorEJB
    whereas you should not be specifying the "t3:" protocol.
    The URL should be like
    jndi://secuser1:[email protected]:7131/AccountDelegatorEJB
    Please do let me know if you see any issues with this.
    Note that this will only allow you to access remote EJBs in the same WLS
    domain. For accessing EJBs on another domain, you need to configure
    inter-domain communication by
    following a few simple steps as mentioned at
    http://e-docs.bea.com/wls/docs81/ConsoleHelp/jta.html#1106135. This link has
    been provided in the EJB Control Workshop documentation.
    Regards,
    Anurag
    "Andre Shergin" <[email protected]> wrote in message
    news:[email protected]...
    Raj,
    I tried that before, it didn't help. I got similar error message:
    <error>
    <faultcode>JWSError</faultcode>
    <faultstring>Error during JNDI lookup from
    jndi:t3://secuser1:[email protected]:7131/AccountDelegatorEJB[Lookup
    failed for
    name:t3://secuser1:[email protected]:7131/AccountDelegatorEJB]</faultstr
    ing>
    <detail>
    <jwErrorDetail> weblogic.jws.control.ControlException: Error during JNDI
    lookup from
    jndi:t3://secuser1:[email protected]:7131/AccountDelegatorEJB[Lookup
    failed for
    name:t3://secuser1:[email protected]:7131/AccountDelegatorEJB] at
    weblogic.knex.control.EJBControlImpl.acquireResources(EJBControlImpl.java:27
    8) at
    weblogic.knex.context.JwsInternalContext.acquireResources(JwsInternalContext
    .java:220) at
    weblogic.knex.control.ControlHandler.invoke(ControlHandler.java:260) at
    ibas.AccountControl.getTransactionHistory(AccountControl.ctrl) at
    ibas.GetSecure.retrieveVisaHistoryTxn(GetSecure.jws:64) </jwErrorDetail>
    </detail>
    </error>
    Anything else should I try?
    P.S. AccountDelegatorEJB, the remote EJB my Web Service calls is NOTaccess
    restricted.
    I hope there is a solution.
    Thanks,
    Andre
    "Raj Alagumalai" <[email protected]> wrote in message
    news:[email protected]...
    Andre,
    Can you try using the following url with username and password
    jndi://username:password@host:7001/my.resource.jndi.object ?
    once you add webapp level security, the authenticated is the user who
    invokes the EJB.
    http://e-docs.bea.com/workshop/docs81/doc/en/workshop/guide/controls/ejb/con
    CreatingANewEJBControl.html?skipReload=true
    has more info on using remote EJB's.
    Hope this helps.
    Thanks
    Raj Alagumalai
    WebLogic Workshop Support
    "Alla Resnik" <[email protected]> wrote in message
    news:[email protected]...
    Hello everyone,
    I developed a Web Service prototype accessing remote EJB using the EJB
    control with special syntax in the jndi-name attribute: @jws:ejb
    home-jndi-name="t3://10.10.245.70:7131/AccountDelegatorEJB"
    Everything works fine, but I get an error when I restrict access to my
    web
    service with a declarative security model by implementing steps
    provided
    in
    help doc:
    - Define the web resource you wish to protect
    - Define which security role is required to access the web resource
    - Define which users are granted the required security role
    - Configure WebLogic Server security for my web service(Compatibility
    Security/Users)
    I launch the service by entering the address in a web browser. Whenprompted
    to accept the digital certificate, click Yes, when prompted for
    network
    authentication information, enter username and password, navigate tothe
    Test Form tab of Test View, invoke the method by clicking the buttonand
    I
    get the following exception:
    <error>
    <faultcode>JWSError</faultcode>
    <faultstring>Error during JNDI lookup from
    jndi:t3://10.10.245.70:7131/AccountDelegatorEJB[Lookup failed for
    name:t3://10.10.245.70:7131/AccountDelegatorEJB]</faultstring>
    <detail>
    <jwErrorDetail> weblogic.jws.control.ControlException: Error during
    JNDI
    lookup from jndi:t3://10.10.245.70:7131/AccountDelegatorEJB[Lookupfailed
    for name:t3://10.10.245.70:7131/AccountDelegatorEJB] at
    weblogic.knex.control.EJBControlImpl.acquireResources(EJBControlImpl.java:27
    8) at
    weblogic.knex.context.JwsInternalContext.acquireResources(JwsInternalContext
    .java:220) at
    weblogic.knex.control.ControlHandler.invoke(ControlHandler.java:260)at
    ibas.AccountControl.getTransactionHistory(AccountControl.ctrl) at
    ibas.GetSecure.retrieveVisaHistoryTxn(GetSecure.jws:64)</jwErrorDetail>
    </detail>
    </error>
    I have a simple Hello method as well in my WebService (which is also
    restricted) and it works fine, but remote EJB access doesn't. I testedmy
    prototype on Weblogic 7.2 and 8.1 platforms - same result.
    Is that a bug or I am missing some additional configuration in order
    to
    get
    that working. Has anyone seen similar behavior? Is there a knownresolution?
    Or a suggested way to work around the problem?
    Thank you.
    Andre

  • Call EJB via ORMI+OID

    Hi All,
    I need to achieve this
    1. Swing client needs to be authendicated when he calls any EJB of the deployed application. ( My application is secured by OID)
    When i am doing a remote lookup my EJB using ORMI from swing client, i am getting invalid user name and password.
    I am supplying the user name configured in OID. Help me in achieving this.
    Enclosing the java program:
    package com.test.ormi;
    import javax.naming.Context;
    import javax.naming.NamingException;
    import javax.naming.InitialContext;
    import java.util.Hashtable;
    public class ORMITest {
    static public Context getInitialContext(String url, String user, String passwd) throws NamingException {
    Hashtable h = new Hashtable();
    h.put(Context.INITIAL_CONTEXT_FACTORY, "com.evermind.server.rmi.RMIInitialContextFactory");
    h.put(Context.PROVIDER_URL, url);
    h.put(Context.SECURITY_PRINCIPAL, user); // OID user name
    h.put(Context.SECURITY_CREDENTIALS, passwd);
    try {
    Context context = new InitialContext(h);
    return context;
    } catch (Throwable th) {
    throw new NamingException(th.getMessage());
    public static void main(String[] args) {
    Context initalCtx = null;
    try {
    initalCtx = ORMITest.getInitialContext("ormi://developmentservername:12345/CQS", "user", "password");
    Object o = initalCtx.lookup("jndiname");
    System.out.println("Class:" + o.getClass());
    } catch (NamingException e) {
    e.printStackTrace();
    } finally {
    Regards.

    Hi,
    Could you make a simple client Java program (instead of Swing), and call to the EJB.
    Could you test with hardcoded URL (for Context.PROVIDER_URL) and let me know if that works.
    I attached a sample code
    Thanks,
    Olaf
    ====
    package sampleClient;
    import java.util.Hashtable;
    import javax.naming.Context;
    import javax.naming.InitialContext;
    import javax.rmi.PortableRemoteObject;
    import employeedetailssoln.Employee;
    import employeedetailssoln.EmployeeHome;
    import javax.naming.NamingException;
    public class SamClient
    public static void main(String [] args)
    SamClient sClient = new SamClient();
    try
    Context context = getInitialContext();
    SamHome samHome = (SamHome)PortableRemoteObject.narrow(context.lookup("SampleEJB"), SamHome.class);
    Sam samJ;
    // Use one of the create() methods below to create a new instance
    samJ = samHome.create();
    // invoke samJ
    catch(Throwable ex)
    ex.printStackTrace();
    private static Context getInitialContext() throws NamingException
    Hashtable env = new Hashtable();
    env.put(Context.INITIAL_CONTEXT_FACTORY, "com.evermind.server.rmi.RMIInitialContextFactory");
    env.put(Context.SECURITY_PRINCIPAL, "admin");
    env.put(Context.SECURITY_CREDENTIALS, "welcome1");
    env.put(Context.PROVIDER_URL, "ormi://localhost:23891/current-workspace-app");
    return new InitialContext(env);

  • Access remote ejb in oc4j

    I use oc4j in jdeveloper 10G in access a remote EJB using
    sample java client both of EJB and java client on MY COMPUTER
    AS SERVER I THINK I HAVE PROBLEM IN SETTING CLASS PATHS
    I HAVE DOWNLOAD J2EE SDK VER 1.3.1 AND I ASSIGN MY CLASSPATHS
    AS FOLLOWS:
    C:\java_course1\jdbc\lib\classes12.jar;C:\java_course1\jdbc\lib\nls_charset12.jar; c:\java_course1\j2ee\home\lib;c:\java_course1\lib\ ; C:\J2Sdkee1.3.1\lib\j2ee.jar
    java_course1 is folder of jdeveloper
    j2Sdkee.1.3.1 is J2EE SDK VER 1.3.1
    the code i have written in java client
    env.put(Context.INITIAL_CONTEXT_FACTORY,"RMIInitialContextFactory");
    env.put(Context.SECURITY_PRINCIPAL, "admin");
    env.put(Context.SECURITY_CREDENTIALS, "welcome");
    env.put(Context.PROVIDER_URL, "ormi://localhost:23893/current-workspace-app");
    Context context = new javax.naming.InitialContext(env);
    EmpHome empHome = (EmpHome)PortableRemoteObject.narrow(context.lookup("EmpHome"), EmpHome.class);
    I get the following error message
    javax.naming.NoInitialContextException: Cannot instantiate class: RMIInitialContextFactory [Root exception is java.lang.ClassNotFoundException: RMIInitialContextFactory]
    Is Someting is missed in class pathes or should i copy j2ee.jar file from
    C:\J2Sdkee1.3.1\lib\j2ee.jar to oc4j folder

    Thank you for useful information i found in site
    But if you help me if defintions of class passes i have assigned and
    show in my message are correct or I have missed something weather
    in class paths or environment variables
    Again Thanks a lot

  • How to use JNDI to lookup remote EJB Home?

    Hello,
    I am writing a servlet to call a remote EJB on another machine.
    I use JNDI to lookup remote EJBHome (not) but fail.
    Any advice?
    Any trick to configure application-client.xml?
    Thanks!

    Use com.evermind.server.rmi.RMIInitialContextFactory instead
    Here an example
    // EmployeeClient.java
    package mypackage5;
    import javax.ejb.*;
    import javax.naming.*;
    import javax.rmi.PortableRemoteObject;
    import java.io.*;
    import java.util.*;
    import java.rmi.RemoteException;
    import com.evermind.server.ApplicationClientInitialContextFactory;
    import com.evermind.server.rmi.RMIInitialContextFactory;
    * A simple client for accessing an EJB.
    public class EmployeeClient
    public static void main(String[] args)
    System.out.println("EmployeeClient.main(): client started...");
    try
    * initialize JNDI context by setting factory, url and credential
    * in a hashtable
    Hashtable env = new Hashtable();
    env.put(Context.INITIAL_CONTEXT_FACTORY, "com.evermind.server.rmi.RMIInitialContextFactory");
    //env.put(Context.INITIAL_CONTEXT_FACTORY, "com.evermind.server.ApplicationClientInitialContextFactory");
    env.put(Context.PROVIDER_URL, "ormi://koushikm:23791/application4");
    env.put(Context.SECURITY_PRINCIPAL, "admin");
    env.put(Context.SECURITY_CREDENTIALS, "admin");
    * or set these properties in jndi.properties
    * or use container defaults if that's where client got launched from
    Context context = new InitialContext(env);
    * Lookup the EmployeeHome object. The reference is retrieved from the
    * application-local context (java:comp/env). The variable is
    * specified in the assembly descriptor (META-INF/application-client.xml).
    Object homeObject =
    context.lookup("HelloEJB");
    System.out.println("EmployeeClient.main(): bean found...");
    // Narrow the reference to EmployeeHome.
    HelloEJBHome home =
         (HelloEJBHome) PortableRemoteObject.narrow(homeObject,
    HelloEJBHome.class);
    System.out.println("EmployeeClient.main(): home narrowed...");
    // Create remote object and narrow the reference to Employee.
    HelloEJB remote =
         (HelloEJB) PortableRemoteObject.narrow(home.create(), HelloEJB.class);
    System.out.println("EmployeeClient.main(): remote created...");
    String message=remote.helloWorld("SUCCESS");
    System.out.println(message);
    } catch(NumberFormatException e) {
    System.err.println("NumberFormatException: " + e.getMessage());
    } catch(RemoteException e) {
    System.err.println("RemoteException: " + e.getMessage());
    } catch(IOException e) {
    System.err.println("IOException: " + e.getMessage());
    } catch(NamingException e) {
    System.err.println("NamingException: " + e.getMessage());
    } catch(CreateException e) {
    System.err.println("CreateException: " + e.getMessage());
    Hello,
    I am writing a servlet to call a remote EJB on another machine.
    I use JNDI to lookup remote EJBHome (not) but fail.
    Any advice?
    Any trick to configure application-client.xml?
    Thanks!

  • Client remote Authentication using JAAS and EJB Access

    Hi,
    I have a problem using JAAS in combination with Sun One Appserver 8.1 and a java remote client trying to access an EJB. Here is the scenario:
    I have implemented an EJB who's methods are protected through the deployment descriptor:
            <assembly-descriptor>
                 <security-role>
                    <description>role for clients outside of the server </description>
                    <role-name>sedna</role-name>
                  </security-role>
                <method-permission>
                  <role-name>sedna</role-name>
                  <method>
                    <ejb-name>ServerInfoBean</ejb-name>
                    <method-intf>Remote</method-intf>
                    <method-name>*</method-name>
                  </method>
                </method-permission>
                <method-permission>
                  <unchecked/>
                  <method>
                    <ejb-name>ServerInfoBean</ejb-name>
                    <method-name>getVersion</method-name>
                  </method>
                  <method>
                    <ejb-name>ServerInfoBean</ejb-name>
                    <method-name>create</method-name>
                  </method>
                </method-permission>
            </assembly-descriptor>I've deployed the EJB in a jar file which was packed into an ear file of a bigger application. The role has been mapped to the admin Principal in the sun-ejb-jar.xml descriptor.
    I can find the EJB, create it, and call the unchecked method getVersion and that works fine, so far so good.
    But then I try to access another method which is protected and then I get this exception
    org.omg.CORBA.NO_PERMISSION:   vmcid: 0x2000  minor code: 1806 completed: Maybe
            at com.sun.enterprise.iiop.POAProtocolMgr.mapException(POAProtocolMgr.java:179)
            at com.sun.ejb.containers.BaseContainer.postInvoke(BaseContainer.java:853)
            at com.sun.ejb.containers.EJBObjectInvocationHandler.invoke(EJBObjectInvocationHandler.java:137)
    ...I have to mention that I do make a login via the LoginContext. My jaas.config File has a reference to the com.sun.enterprise.security.auth.login.ClientPasswordLoginModule module.
    After login (which works perfectly) I lookup the context with a corbaname url which - if I understood it right - ignores the Context.SECURITY_PRINCIPAL and Context.SECURITY_CREDENTIALS settings.
    After that I make the calls to the EJB. And I am allways ANONYMOUS on the server side, which is definitely the problem. Because ANONYMOUS is not allowed to call the protected EJB Methods. But I made a jaas login in advance. So where am I making a mistake???
    Am I doing something wrong?
    Need help! Thx,
    Stephan

    Hi.
    I understand correctly that you call Subject.doAs on
    the client to call the remote EJB. I guess It isn't
    right way.I had also a bad feeling about this, so I forget it. But anyway it wasn't working with or without using that doAs().
    >
    >
    Subject contextSubject =
    Subject.getSubject(AccessController.getContext());
    contextSubject.getPrincipals();This code throws exceptions in the Appserver. Unfortunately they are catched somewhere so I'm unable to find out what was going wrong. But I guess, that these exceptions where security exceptions. Never the less thanks for the hint!
    But I don't think that doing the check on the server side is the way I want to go because that is programmatically security and I want to use the declarative security which can be used through the deployment descriptor. If used correctly - and supposed I do not completely misunderstand the specification - then it should be possible to create an EJB that is protected via it's deployment descriptor and access it through the client only if the client has been authenticated through JAAS mechanisms. After successful authentication the principal should be accessible through the EJB context but not for security check, that should allready been done at this time.
    Unfortunately I don't find any resource on the internet describing the scenario in such a detail that I can reproduce it. There are only very high level documentations and hints in forums.
    Again, thanks for your effort,
    Stephan

  • How can I call remote ejb through jsp?(null)

     

    Trying the code:
              <%@ page import="si3.*,javax.ejb.*,javax.naming.*,java.util.*,java.rmi.RemoteException" %>
              <%
              int h=8;
              int w=8;
              Hashtable p = new Hashtable ();
              p.put(Context.INITIAL_CONTEXT_FACTORY,"weblogic.jndi.WLInitialContextFactory");
              p.put(Context.PROVIDER_URL,"t3://192.168.0.203:7001");
              Context ctx= new InitialContext(p);
              Object homeref = ctx.lookup("si3.test");
              addHome home = (addHome) PortableRemoteObject.narrow(homeref, addHome.class);
              add the_ejb = home.create();
              out.println(the_ejb.add(h,w));
              out.println("adf");
              the_ejb.remove();
              %>
              yzj wrote:
              > I have two server running weblogic5.1.
              > If the jsp and ejb locate the same server running weblogic 5.1 ,works well .But one deploys the ejb (jndi name si3.test),the other runs the jsp.I use jsp call the remote ejb ,catch exception :
              >
              > GMT+08:00 2000:<E> <ServletContext-General> Root
              > > cause of ServletException
              > > javax.naming.NameNotFoundException: 'si3.test'; remaining name 'si3.test'
              > > at
              > > weblogic.jndi.toolkit.BasicWLContext.resolveName(BasicWLContext.java,
              > > Compiled Code)
              > > at
              > > weblogic.jndi.toolkit.BasicWLContext.lookup(BasicWLContext.java:133)
              > > at
              > > weblogic.jndi.toolkit.BasicWLContext.lookup(BasicWLContext.java:574)
              > > at javax.naming.InitialContext.lookup(InitialContext.java:349)
              > > at jsp_servlet.client._jspService(client.java:90)
              > > at weblogic.servlet.jsp.JspBase.service(JspBase.java:27)
              > > at
              > > weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java
              > > :124)
              > > at
              > > weblogic.servlet.internal.ServletContextImpl.invokeServlet(ServletContextImp
              > > l.java:744)
              > > at
              > > weblogic.servlet.internal.ServletContextImpl.invokeServlet(ServletContextImp
              > > l.java:692)
              > > at
              > > weblogic.servlet.internal.ServletContextManager.invokeServlet(ServletContext
              > > Manager.java:
              > > 251)
              > > at
              > > weblogic.socket.MuxableSocketHTTP.invokeServlet(MuxableSocketHTTP.java:363)
              > > at
              > > weblogic.socket.MuxableSocketHTTP.execute(MuxableSocketHTTP.java:263)
              > > at weblogic.kernel.ExecuteThread.run(ExecuteThread.java, Compiled
              > > Code)
              >
              > Why? Can you help me? Thanks.
              > The jsp's source(Client.jsp ):
              > <%@ page import="si3.*,javax.ejb.*,javax.naming.*,java.util.*,java.rmi.RemoteException" %>
              > <%
              > int h=8;
              > int w=8;
              > Hashtable p = new Hashtable ();
              > p.put(Context.INITIAL_CONTEXT_FACTORY,"weblogic.jndi.WLInitialContextFactory");
              > p.put(Context.PROVIDER_URL,"t3://192.168.0.203:7001");
              > Context ctx= new InitialContext(p);
              > addHome home = (addHome) ctx.lookup("si3.test");
              > add the_ejb = home.create();
              > out.println(the_ejb.add(h,w));
              > out.println("adf");
              > the_ejb.remove();
              > %>
              >
              >
              [att1.html]
              

  • Remote Browsing using RMI

    Hi,
    Read a lot of forums about how to create a Remote file browser using RMI and JFileChooser.
    Not done any RMI coding I thought I'd give it a try. I have finally after 2 days managed to do it.
    This is an overview.
    Create a RemoteFile class that extends Remote.. eg.
    import java.rmi.*;
    import java.io.*;
    import java.net.*;
    public interface RemoteFile extends Remote {
        public boolean canRead() throws RemoteException;
        public boolean canWrite() throws RemoteException;
        public int compareTo(File pathname) throws RemoteException;etc.etc
    Then create an implementation class...
    import java.rmi.server.*;
    import java.io.*;
    import java.net.*;
    public class RemoteFileImpl extends UnicastRemoteObject implements RemoteFile {
        private File f;
        public RemoteFileImpl(File sf) throws java.rmi.RemoteException {
            f=sf;
        public boolean canRead() throws java.rmi.RemoteException {
            return f.canRead();
        }etc etc for all other File functions.
    Then we create a RemoteFileSystemView interface, again extending remote...
    public interface RemoteFileSystemView extends Remote {
        public RemoteFile createFileObject(File dir, String filename) throws RemoteException;
        public RemoteFile createFileObject(String path) throws RemoteException;blah blah
    Then An implementation class...
    import javax.swing.filechooser.*;
    import java.io.*;
    public class RemoteFileSystemViewImpl extends java.rmi.server.UnicastRemoteObject implements RemoteFileSystemView {
        int length;
        private FileSystemView fs;
        public RemoteFileSystemViewImpl() throws java.rmi.RemoteException {
            fs=FileSystemView.getFileSystemView();
        public RemoteFile createFileObject(String path) throws java.rmi.RemoteException {
            return new RemoteFileImpl(fs.createFileObject(path));
        public RemoteFile createFileObject(java.io.File dir, String filename) throws java.rmi.RemoteException {
            return new RemoteFileImpl(fs.createFileObject(dir,filename));
        //public RemoteFileImpl createFileSystemRoot(java.io.File f) throws java.rmi.RemoteException {
        //    return new RemoteFileImpl(fs.createFileSystemRoot(f));
        public RemoteFile createNewFolder(java.io.File containingDir) throws java.rmi.RemoteException {
            RemoteFile tempf;
            try{
                tempf= new RemoteFileImpl(fs.createNewFolder(containingDir));
            } catch (IOException e){System.out.println(e); tempf=null;}
            return  tempf;
        public RemoteFile getDefaultDirectory() throws java.rmi.RemoteException {
            return new RemoteFileImpl(fs.getDefaultDirectory());
        public String[] getFiles(java.io.File dir, boolean useFileHiding) throws java.rmi.RemoteException {
            String[] tempf= new String[fs.getFiles(dir,useFileHiding).length];
            int i;
            File[] f = fs.getFiles(dir,useFileHiding);
            for(i=0;i<tempf.length;i++) tempf=f[i].toString();
    return tempf;
    public RemoteFile getHomeDirectory() throws java.rmi.RemoteException {
    return new RemoteFileImpl(fs.getHomeDirectory());
    public RemoteFile getParentDirectory(java.io.File dir) throws java.rmi.RemoteException {
    return new RemoteFileImpl(fs.getParentDirectory(dir));
    public String[] getRoots() throws java.rmi.RemoteException {
    String[] tempf= new String[fs.getRoots().length];
    System.out.println("fs is-"+fs.getRoots().length);
    int i;
    File[] f = fs.getRoots();
    for(i=0;i<tempf.length;i++) {tempf[i]=f[i].toString();}
    System.out.println("Roots="+tempf[0]);
    return tempf;
    public String getSystemDisplayName(java.io.File f) throws java.rmi.RemoteException {
    return fs.getSystemDisplayName(f);
    public javax.swing.Icon getSystemIcon(java.io.File f) throws java.rmi.RemoteException {
    return fs.getSystemIcon(f);
    public String getSystemTypeDescription(java.io.File f) throws java.rmi.RemoteException {
    return fs.getSystemTypeDescription(f);
    public boolean isComputerNode(java.io.File dir) throws java.rmi.RemoteException {
    return fs.isComputerNode(dir);
    public boolean isDrive(java.io.File dir) throws java.rmi.RemoteException {
    return fs.isDrive(dir);
    public boolean isFileSystem(java.io.File f) throws java.rmi.RemoteException {
    return fs.isFileSystem(f);
    public boolean isFileSystemRoot(java.io.File dir) throws java.rmi.RemoteException {
    return fs.isFileSystemRoot(dir);
    public boolean isFloppyDrive(java.io.File dir) throws java.rmi.RemoteException {
    return fs.isFloppyDrive(dir);
    public boolean isHiddenFile(java.io.File f) throws java.rmi.RemoteException {
    return fs.isHiddenFile(f);
    public boolean isParent(java.io.File folder, java.io.File file) throws java.rmi.RemoteException {
    return fs.isParent(folder,file);
    public boolean isRoot(java.io.File f) throws java.rmi.RemoteException {
    return fs.isRoot(f);
    public Boolean isTraversable(java.io.File f) throws java.rmi.RemoteException {
    return fs.isTraversable(f);
    public RemoteFile getChild(File parent, String fileName) throws java.rmi.RemoteException {
    return new RemoteFileImpl(fs.getChild(parent,fileName));
    Notice that whenever I should be passing a File, I pass a RemoteFile instead! Also.. when I am passing a File Array, I instead pass a String array. Reason is.. I havent managed to get File arrays through RMI.. Any Help anyone?!?!?!?!
    I got round it by simply passing a String array and relying on the client to reconstruct a File array locally using the String array. Messy... perhaps.. any suggestions welcome!
    Next.. use rmic to create Stubs and Skels for the 2 implementations and write an RMI server.. eg.
    import java.rmi.Naming;
    public class RemoteServerRMI {
        /** Creates a new instance of RemoteServerRMI */
        public RemoteServerRMI() {
            try {
                RemoteFileSystemView c = new RemoteFileSystemViewImpl();
                Naming.rebind("rmi://localhost:1099/FileService", c);
            } catch (Exception e) {
                System.out.println("Trouble: " + e);
        public static void main(String[] args) {
            new RemoteServerRMI();
    }Yes.. simple and shamelessly lifted from the tutorials.
    and Finally the client....
    import javax.swing.filechooser.*;
    import java.rmi.*;
    import java.net.MalformedURLException;
    import java.io.*;
    import javax.swing.*;
    public class RemoteFileSystemViewClient extends FileSystemView {
        static RemoteFileSystemView c;
        public RemoteFileSystemViewClient() {
            try {
                c = (RemoteFileSystemView) Naming.lookup("rmi://localhost:1099/FileService");
            catch (MalformedURLException murle) {
                System.out.println();
                System.out.println(
                "MalformedURLException");
                System.out.println(murle);
            catch (RemoteException re) {
                System.out.println();
                System.out.println(
                "RemoteException");
                System.out.println(re);
            catch (NotBoundException nbe) {
                System.out.println();
                System.out.println(
                "NotBoundException");
                System.out.println(nbe);
        public File getHomeDirectory() {
            File tempf;
            try {
                tempf= new File(c.getHomeDirectory().gettoString());
            } catch (RemoteException re){System.out.println(re);tempf=null;}
            return tempf;
        public File createFileObject(File dir, String filename) {
            File tempf;
            try {
                tempf= new File(c.createFileObject(dir, filename).gettoString());
            } catch (RemoteException re){System.out.println(re);tempf=null;}
            return tempf;
        public File createFileObject(String path) {
            File tempf;
            try {
                tempf=new File(c.createFileObject(path).gettoString());
            } catch (RemoteException re){System.out.println(re);tempf=null;}
            return tempf;
        public File createNewFolder(File containingDir) throws RemoteException {
            File tempf;
            try {
                tempf=new File(c.createNewFolder(containingDir).getAbsolutePath());
            } catch (RemoteException re){System.out.println(re);tempf=null;}
            return tempf;
        public File getChild(File parent, String fileName) {
            File tempf;
            try {
                tempf=new File(c.getChild(parent,fileName).gettoString());
            } catch (RemoteException re){System.out.println(re);tempf=null;}
            return tempf;
        public File getDefaultDirectory() {
            File tempf;
            try {
                tempf=new File(c.getDefaultDirectory().gettoString());
            } catch (RemoteException re){System.out.println(re);tempf=null;}
            return tempf;
        public File[] getFiles(File dir, boolean useFileHiding) {
            File[] tempf;
            try {
                tempf=new File[c.getFiles(dir,useFileHiding).length];
                String[] rtempf=c.getFiles(dir, useFileHiding);
                int i;
                for(i=0;i<c.getFiles(dir, useFileHiding).length;i++) tempf=new File(rtempf[i]);
    } catch (RemoteException re){System.out.println(re);tempf=null;}
    return tempf;
    public File getParentDirectory(File dir) {
    File tempf;
    try {
    tempf= new File(c.getParentDirectory(dir).gettoString());
    } catch (RemoteException re){System.out.println(re);tempf=null;}
    return tempf;
    public File[] getRoots(){
    File[] tempf;
    try {
    String[] rtempf= c.getRoots();
    System.out.println("in");
    tempf=new File[rtempf.length];
    int i;
    for(i=0;i<c.getRoots().length;i++) tempf[i]=new File(rtempf[i]);
    } catch (RemoteException re){System.out.println(re);tempf=null;}
    return tempf;
    public String getSystemDisplayName(File f) {
    String tempf;
    try{
    tempf=c.getSystemDisplayName(f);
    } catch (RemoteException re){System.out.println(re);tempf=null;}
    return tempf;
    public javax.swing.Icon getSystemIcon(File f) {
    javax.swing.Icon tempf;
    try{
    tempf=c.getSystemIcon(f);
    } catch (RemoteException re){System.out.println(re);tempf=null;}
    return tempf;
    public String getSystemTypeDescription(File f) {
    String tempf;
    try {
    tempf=c.getSystemTypeDescription(f);
    } catch (RemoteException re){System.out.println(re);tempf=null;}
    return tempf;
    public boolean isComputerNode(File dir) {
    boolean tempf;
    try {
    tempf= c.isComputerNode(dir);
    } catch (RemoteException re){System.out.println(re);tempf=false;}
    return tempf;
    public boolean isDrive(File dir) {
    boolean tempf;
    try {
    tempf= c.isDrive(dir);
    } catch (RemoteException re){System.out.println(re);tempf=false;}
    return tempf;
    public boolean isFileSystem(File f) {
    boolean tempf;
    try {
    tempf= c.isFileSystem(f);
    } catch (RemoteException re){System.out.println(re);tempf=false;}
    return tempf;
    public boolean isFileSystemRoot(File dir) {
    boolean tempf;
    try {
    tempf= c.isFileSystemRoot(dir);
    } catch (RemoteException re){System.out.println(re);tempf=false;}
    return tempf;
    public boolean isFloppyDrive(File dir) {
    boolean tempf;
    try {
    tempf= c.isFloppyDrive(dir);
    } catch (RemoteException re){System.out.println(re);tempf=false;}
    return tempf;
    public boolean isHiddenFile(File f) {
    boolean tempf;
    try {
    tempf= c.isHiddenFile(f);
    } catch (RemoteException re){System.out.println(re);tempf=false;}
    return tempf;
    public boolean isParent(File folder, File file) {
    boolean tempf;
    try {
    tempf= c.isParent(folder,file);
    } catch (RemoteException re){System.out.println(re);tempf=false;}
    return tempf;
    public boolean isRoot(File f) {
    boolean tempf;
    try {
    tempf= c.isRoot(f);
    } catch (RemoteException re){System.out.println(re);tempf=false;}
    return tempf;
    public Boolean isTraversable(File f) {
    Boolean tempf;
    try {
    tempf= c.isTraversable(f);
    } catch (RemoteException re){System.out.println(re);tempf=new Boolean(false);}
    return tempf;
    public static void main(String[] args) {
    RemoteFileSystemViewClient rc = new RemoteFileSystemViewClient();
    JFileChooser fch= new JFileChooser(rc);
    fch.showOpenDialog(null);
    Notice.. the getFiles and getRoots, procedures, get String arrays from the RMI and reconstruct local File arrays.
    I managed to browse up and down directories with this, and even.. to my surprise, create folders!
    If you got any improvements please let me know at [email protected]

    Copyright &copy; Esmond Pitt, 2007. All rights reserved.
    * RemoteFileSystem.java
    * Created on 13 May 2007, 14:39
    import java.io.File;
    import java.io.IOException;
    import java.rmi.Remote;
    import java.rmi.RemoteException;
    import javax.swing.Icon;
    * @author Esmond Pitt
    public interface RemoteFileSystem extends Remote
         File createFileObject(String path) throws RemoteException;
         File[] getFiles(File dir, boolean useFileHiding) throws RemoteException;
         File createFileObject(File dir, String filename) throws RemoteException;
         File getChild(File parent, String fileName) throws RemoteException;
         boolean isFloppyDrive(File dir) throws RemoteException;
         boolean isFileSystemRoot(File dir) throws RemoteException;
         boolean isFileSystem(File f) throws RemoteException;
         boolean isDrive(File dir) throws RemoteException;
         boolean isComputerNode(File dir) throws RemoteException;
         File createNewFolder(File containingDir) throws RemoteException, IOException;
         File getParentDirectory(File dir) throws RemoteException;
         String getSystemDisplayName(File f) throws RemoteException;
         Icon getSystemIcon(File f) throws RemoteException;
         String getSystemTypeDescription(File f) throws RemoteException;
         File getDefaultDirectory() throws RemoteException;
         File getHomeDirectory() throws RemoteException;
         File[] getRoots() throws RemoteException;
         // File     createFileSystemRoot(File f) throws RemoteException;
    import java.io.File;
    import java.io.IOException;
    import java.rmi.RemoteException;
    import java.rmi.server.UnicastRemoteObject;
    import java.util.logging.Level;
    import java.util.logging.Logger;
    import javax.swing.Icon;
    import javax.swing.filechooser.FileSystemView;
    * @author Esmond Pitt
    * @version $Revision: 3 $
    public class RemoteFileSystemServer extends UnicastRemoteObject implements RemoteFileSystem
         private FileSystemView     fs = FileSystemView.getFileSystemView();
         private Logger     logger = Logger.getLogger(this.getClass().getName());
         /** Creates a new instance of RemoteFileSystemServer */
         public RemoteFileSystemServer(int port) throws RemoteException
              super(port);
              logger.log(Level.INFO, "exported on port {0} and receiving calls fs={1}", new Object[]{port, fs});
         public File createFileObject(String path)
              logger.log(Level.FINE, "createFileObject({0})", path);
              return fs.createFileObject(path);
         public File createFileObject(File dir, String filename)
              logger.log(Level.FINE, "createFileObject({0},{1})", new Object[]{dir, filename});
              return fs.createFileObject(dir, filename);
         public File[] getFiles(File dir, boolean useFileHiding)
              logger.log(Level.FINE, "getFiles({0},{1})", new Object[]{dir, useFileHiding});
              return fs.getFiles(dir, useFileHiding);
         public File getChild(File parent, String fileName)
              logger.log(Level.FINE, "getChild({0},{1})", new Object[]{parent, fileName});
              return fs.getChild(parent, fileName);
         public boolean isFloppyDrive(File dir)
              logger.log(Level.FINE, "isFloppyDrive({0})", dir);
              return fs.isFloppyDrive(dir);
         public boolean isFileSystemRoot(File dir)
              logger.log(Level.FINE, "isFileSystemRoot({0})", dir);
              return fs.isFileSystemRoot(dir);
         public boolean isFileSystem(File f)
              logger.log(Level.FINE, "isFileSystem({0})", f);
              return fs.isFileSystem(f);
         public boolean isDrive(File dir)
              logger.log(Level.FINE, "isDrive({0})", dir);
              return fs.isDrive(dir);
         public boolean isComputerNode(File dir)
              logger.log(Level.FINE, "isComputerNode({0})", dir);
              return fs.isComputerNode(dir);
         public File createNewFolder(File containingDir) throws IOException
              logger.log(Level.FINE, "createNewFolder({0})", containingDir);
              return fs.createNewFolder(containingDir);
         public File getParentDirectory(File dir)
              logger.log(Level.FINE, "getParentDirectory({0})", dir);
              return fs.getParentDirectory(dir);
         public String getSystemDisplayName(File f)
              logger.log(Level.FINE, "getSystemDisplayName({0})", f);
              return fs.getSystemDisplayName(f);
         public Icon getSystemIcon(File f)
              logger.log(Level.FINE, "getSystemIcon({0})", f);
              return fs.getSystemIcon(f);
         public String getSystemTypeDescription(File f)
              logger.log(Level.FINE, "getSystemTypeDescription({0})", f);
              return fs.getSystemTypeDescription(f);
         public File getDefaultDirectory()
              logger.log(Level.FINE, "getDefaultDirectory()");
              return fs.getDefaultDirectory();
         public File getHomeDirectory()
              logger.log(Level.FINE, "getHomeDirectory()");
              return fs.getHomeDirectory();
         public File[] getRoots()
              logger.log(Level.FINE, "getRoots()");
              return fs.getRoots();
          public File createFileSystemRoot(File f)
              return fs.createFileSystemRoot(f);
    import java.io.File;
    import java.io.IOException;
    import java.net.MalformedURLException;
    import java.rmi.Naming;
    import java.rmi.NotBoundException;
    import java.rmi.RemoteException;
    import java.util.logging.Level;
    import java.util.logging.Logger;
    import javax.swing.Icon;
    import javax.swing.filechooser.FileSystemView;
    * @author Esmond Pitt
    * @version $Revision: 4 $
    public class RemoteFileSystemView extends FileSystemView
         private Logger     logger = Logger.getLogger(this.getClass().getName());
         private RemoteFileSystem     fs;
         public RemoteFileSystemView(String host)
         throws NotBoundException, RemoteException, MalformedURLException
              String     url = "rmi://"+host+"/"+RemoteFileSystem.class.getName();
              this.fs = (RemoteFileSystem)Naming.lookup(url);
              logger.log(Level.INFO, "Connected to {0} via {1}", new Object[]{url, fs});
         public File createFileObject(String path)
              logger.entering(this.getClass().getName(), "createFileObject", path);
              try
                   return fs.createFileObject(path);
              catch (RemoteException exc)
                   logger.log(Level.SEVERE, "path="+path, exc);
                   return null;
         public File[] getFiles(File dir, boolean useFileHiding)
              logger.entering(this.getClass().getName(), "getFiles", new Object[]{dir, useFileHiding});
              try
                   return fs.getFiles(dir, useFileHiding);
              catch (RemoteException exc)
                   logger.log(Level.SEVERE, "dir="+dir+" useFileHiding="+useFileHiding, exc);
                   return null;
         public File createFileObject(File dir, String filename)
              logger.entering(this.getClass().getName(), "createFileObject", new Object[]{dir, filename});
              try
                   return fs.createFileObject(dir, filename);
              catch (RemoteException exc)
                   logger.log(Level.SEVERE, "dir="+dir+" filename="+filename, exc);
                   return null;
         public File getChild(File parent, String fileName)
              logger.entering(this.getClass().getName(), "getChild", new Object[]{parent, fileName});
              try
                   return fs.getChild(parent, fileName);
              catch (RemoteException exc)
                   logger.log(Level.SEVERE, "parent="+parent+" fileName="+fileName, exc);
                   return null;
         public boolean isFloppyDrive(File dir)
              logger.entering(this.getClass().getName(), "isFloppyDrive", dir);
              try
                   return fs.isFloppyDrive(dir);
              catch (RemoteException exc)
                   logger.log(Level.SEVERE, "dir="+dir, exc);
                   return false;
         public boolean isFileSystemRoot(File dir)
              logger.entering(this.getClass().getName(), "isFileSystemRoot", dir);
              try
                   return fs.isFileSystemRoot(dir);
              catch (RemoteException exc)
                   logger.log(Level.SEVERE, "dir="+dir, exc);
                   return false;
         public boolean isFileSystem(File file)
              logger.entering(this.getClass().getName(), "isFileSystem", file);
              try
                   return fs.isFileSystem(file);
              catch (RemoteException exc)
                   logger.log(Level.SEVERE, "file="+file, exc);
                   return false;
         public boolean isDrive(File dir)
              logger.entering(this.getClass().getName(), "isDrive", dir);
              try
                   return fs.isDrive(dir);
              catch (RemoteException exc)
                   logger.log(Level.SEVERE, "dir="+dir, exc);
                   return false;
         public boolean isComputerNode(File dir)
              logger.entering(this.getClass().getName(), "isComputerNode", dir);
              try
                   return fs.isComputerNode(dir);
              catch (RemoteException exc)
                   logger.log(Level.SEVERE, "dir="+dir, exc);
                   return false;
         public File createNewFolder(File containingDir) throws IOException
              logger.entering(this.getClass().getName(), "createNewFolder", containingDir);
              try
                   return fs.createNewFolder(containingDir);
              catch (RemoteException exc)
                   logger.log(Level.SEVERE, "containingDir="+containingDir, exc);
                   return null;
         public File getParentDirectory(File dir)
              logger.entering(this.getClass().getName(), "getParentDirectory", dir);
              try
                   return fs.getParentDirectory(dir);
              catch (RemoteException exc)
                   logger.log(Level.SEVERE, "dir="+dir, exc);
                   return null;
         public String getSystemDisplayName(File file)
              logger.entering(this.getClass().getName(), "getSystemDisplayName", file);
              try
                   return fs.getSystemDisplayName(file);
              catch (RemoteException exc)
                   logger.log(Level.SEVERE, "file="+file, exc);
                   return null;
         public Icon getSystemIcon(File file)
              logger.entering(this.getClass().getName(), "getSystemIcon", file);
              try
                   return fs.getSystemIcon(file);
              catch (RemoteException exc)
                   logger.log(Level.SEVERE, "file="+file, exc);
                   return null;
         public String getSystemTypeDescription(File file)
              logger.entering(this.getClass().getName(), "getSystemTypeDescription", file);
              try
                   return fs.getSystemTypeDescription(file);
              catch (RemoteException exc)
                   logger.log(Level.SEVERE, "file="+file, exc);
                   return null;
         public File getDefaultDirectory()
              logger.entering(this.getClass().getName(), "getDefaultDirectory");
              try
                   return fs.getDefaultDirectory();
              catch (RemoteException exc)
                   logger.log(Level.SEVERE, "getDefaultDirectory()", exc);
                   return null;
         public File getHomeDirectory()
              logger.entering(this.getClass().getName(), "getHomeDirectory");
              try
                   return fs.getHomeDirectory();
              catch (RemoteException exc)
                   logger.log(Level.SEVERE, "getHomeDirectory()", exc);
                   return null;
         public File[] getRoots()
              logger.entering(this.getClass().getName(), "getRoots");
              try
                   return fs.getRoots();
              catch (RemoteException exc)
                   logger.log(Level.SEVERE, "getRoots()", exc);
                   return null;
         protected File createFileSystemRoot(File file)
              logger.entering(this.getClass().getName(), "createFileSystemRoot", file);
              logger.log(Level.SEVERE, "createFileSystemRoot called with ({0})", new Object[]{file});
              try
                   return fs.createFileSystemRoot(file);
              catch (RemoteException exc)
                   logger.log(Level.SEVERE, "", exc);
              return null;
    }

  • Using a remote Ejb as a datacontrol for ADF

    Hi,
    I am trying to create an EJB 3.0 Data Control on top of remote deployed EJB. Difficulty is that I have no control over the EJB, and all I've been given is a Client jar file containing the remote interface and the entities used in the interface. When looking up the EJB using JNDI this is enough, so I was assuming it would also be enough to create a EJB Data Control, but it seems not.
    I've searched a lot of blogs and tutorials, but everyone seems to create the EJB's and entities from scratch.
    So the question is: how to create an EJB 3.0 Data Control based on just a Remote Interface?
    I tried the following:
    =============
    1. Create a new Fusion Web Application
    2. Add the EJB Client jar to the classpath. If you select "Show Libraries" in the Project Navigator, you can drill down to the Remote Interface class in the EJB Client jar. When you right-click the Remote Interface, there is an option to "Create Data Control", but that doesn't work for .class files. And even if you have the .java source file there, it will generate a POJO Data Control, which is obviously not what we want.
    After some time I found the following workaround:
    ===============================
    3. Create a Session Bean with exact same package and name in the Model project, and make sure its remote interface is the same as the given Remote EJB. Then generate a EJB 3.0 Data Control on top of that
    4. Then via file system remove the Session Bean and interface from Model project, so the Data Control will use the one on the classpath
    5. Update DataControls.dcx with jndi-name and provider-url from Remote EJB
    6. Remove <ejb-ref> from web.xml to avoid deployment issues.
    Problem is that in our project there are many of these Remote EJBs, and they are also work in progress. Means the remote interfaces are changing all the time, and then all of the above steps have to be performed. Isn't there an easier way, like the behaviour I was expecting in step 2?
    Thanks for any suggestions.

    ADF needs to be able to access the source of the facade to create the data control, so the recommended way is to have a project that contains the actual EJB and from it create the data control.
    This shouldn't be a problem assuming that you and the people who provide the EJB all work in the same company.
    You should be able to change the location of the EJB that you access at runtime by modifying the datacontrol definition after it has been created.
    Note also that if your EJBs are constantly changing you'll also need to update your data controls to leverage changes you need.

  • Loading remote EJB from servlet using jakarta and openejb

    I am trying to create an environment where I use
    openejb as my EJB container, and JAKARTA Tomcat
    as my
    Servlet/JSP container. However,
    i'm having a problem in lookingup my remote EJB from my
    jakarta application.
    That exact code works perfectly if I run it standalone. I
    am using the same JRE. Jakarta has also loaded the
    openejb-0.8.3.jar and openejb_client-0.8.3.jar
    What I dont understand is why jakarta
    would behave differently than command-line java when I
    am
    running in the same JRE on a single machine.
    Any help would be much appreciated.

    Several fairly major improvements have been maid in OpenEJB specifically for the Tomcat people. For one, the whole way you integrate them has completely been rewritten. Now all you have to do is copy a openejb_loader-0.9.1.war into the Tomcat webapps directory and change an init-param in it. Pretty straight forward. OpenEJB 0.8.3 won't work with Tomcat in the same VM, however OpenEJB 0.9.0 and up have been totally revamped in all things related to classloading so that it can co-exist with Tomcats unique classloading architecture.
    O'Reilly just published an article detailing the ins and outs of the integration, it's a pretty good read:
    http://www.onjava.com/pub/a/onjava/2003/02/12/ejb_tomcat.html

  • How to use application to call a remote EJB?

    this is my code:
    package test;
    import javax.naming.Context;
    import javax.naming.InitialContext;
    import javax.rmi.PortableRemoteObject;
    import java.util.*;
    import test.HelloWorldHome;
    import test.HelloWorld;
    public class callremoteEjb{
         public String callejb(){
              try{
                   Properties env = new Properties();
                   System.setProperty("org.omg.CORBA.ORBInitialHost", "202.120.80.219");
              System.setProperty("org.omg.CORBA.ORBInitialPort", "7001");
              env.put(Context.INITIAL_CONTEXT_FACTORY,
                             "com.sun.enterprise.naming.SerialInitContextFactory");
              env.put(Context.PROVIDER_URL, "t3://202.120.80.219:7001");
                   Context initial = new InitialContext(env);
                   Object objref = initial.lookup("HelloWorldBean");
                   HelloWorldHome home = (HelloWorldHome)PortableRemoteObject.narrow(
                                                      objref,HelloWorldHome.class);
                   HelloWorld helloBean = home.create();
                   return helloBean.sayHello();
              }catch(Exception ex){
                   ex.printStackTrace();
              return "aaa";          
         public static void main(String[] args){
              callremoteEjb testejb = new callremoteEjb();
              System.out.println(testejb.callejb());     
    i ' ve success deploy the EJB in the remote server.
    but it run error : " Can't find SerialContextProvider "
    how should i do?

    There is a sample called rmi-iiop. It has a Java applicationclient that talks to a remote ejb. Pl have a look at that.
    Sahoo

  • How to capture the remot desktop using RMI?

    Hi friends..
    I am doing a mini project to capture the remot desktop using RMI. I am very new with this subject. So 'm waiting for the help of experts...

    You can't. RMI doesn't do that. After you have captured it, some other way, you can transmit it via RMI, or plain Sockets, or several other ways.

  • How to get remote ejb client working with Weblogic 8.1?

    I have Weblogic 8.1 running on a WinXP box behind my firewall. Port 7001 is open to WL and remote browsers can access the console.
    I have a client machine running WinXP on a different network that is remote to the WL server. It can ping the WL server machine.
    I use JVM 1.4.2_08 on all machines.
    If I put my client machine on the LAN with the WL server, then my EJB test client works fine. If I put the client machine on the remote network then the test client fails with a ClassCastException when trying to do a PortableRemoteObject.narrow on the bean home.
    I had this running fine on JBoss 3.22 using RMI over HTTP. I added an HTTP invoker service to my jboss.xml file. I don't know if something similar is needed on the Weblogic side - any ideas on that? All I've done on the WL side is turn on Tunneling - which obviously works because the remote client gets a correct home object when doing a lookup on the bean - based on the IOR string of the home obj.
    Below I include my client code, exception, ejb-jar.xml and my weblogic-ejb-jar.xml.
    Any ideas on what else needs to be done so that a remote client can do a PortableRemoteObject.narrow? My client.jar has all of the EJB classes, and runs fine when run from LAN.
    Thanks,
    --BobC
    Client Code
    Properties p = new Properties();
    p.put("java.naming.factory.initial", "weblogic.jndi.WLInitialContextFactory");
    p.put("java.naming.provider.url", "http://66.114.140.213:7001");
    InitialContext ic = new InitialContext(p);
    // Test register bean
    Object homeObj = ic.lookup("tacplanner/register");
    RegisterHome home = (RegisterHome) PortableRemoteObject.narrow(homeObj, RegisterHome.class); // <<< ClassCastException here
    Exception
    java.lang.ClassCastException
    at com.sun.corba.se.internal.javax.rmi.PortableRemoteObject.narrow(PortableRemoteObject.java:293)
    at javax.rmi.PortableRemoteObject.narrow(PortableRemoteObject.java:134)
    at com.nimblus.tacplanner.test.TestUtils.<init>(TestUtils.java:60)
    at com.nimblus.tacplanner.test.TestUtils.main(TestUtils.java:196)
    ejb-jar.xml
    <?xml version="1.0"?>
    <!DOCTYPE ejb-jar PUBLIC '-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 1.1//EN' 'http://java.sun.com/j2ee/dtds/ejb-jar_1_1.dtd'>
    <ejb-jar>
    <enterprise-beans>
    <session>
    <ejb-name>register</ejb-name>
    <home> com.nimblus.tacplanner.server.ejb.stateless.RegisterHome</home>
    <remote> com.nimblus.tacplanner.server.ejb.stateless.Register</remote>
    <ejb-class>com.nimblus.tacplanner.server.ejb.stateless.RegisterSession</ejb-class>
    <session-type>Stateless</session-type>
    <transaction-type>Container</transaction-type>
    <resource-ref>
    <description>The Oracle Datasource</description>
    <res-ref-name>java:/OracleDS</res-ref-name>
    <res-type>javax.sql.DataSource</res-type>
    <res-auth>Container</res-auth>
    </resource-ref>
    </session>
    </enterprise-beans>
    <assembly-descriptor>
    <container-transaction>
    <method>
    <ejb-name>register</ejb-name>
    <method-name>*</method-name>
    </method>
    <trans-attribute>Required</trans-attribute>
    </container-transaction>
    </ejb-jar>
    weblogic-ejb-jar.xml
    <?xml version="1.0"?>
    <!DOCTYPE weblogic-ejb-jar PUBLIC
    '-//BEA Systems, Inc.//DTD WebLogic 8.1.0 EJB//EN'
    'http://www.bea.com/servers/wls810/dtd/weblogic-ejb-jar.dtd'>
    <weblogic-ejb-jar>
    <weblogic-enterprise-bean>
    <ejb-name>register</ejb-name>
    <stateless-session-descriptor>
    <pool>
    <max-beans-in-free-pool>100</max-beans-in-free-pool>
    </pool>
    </stateless-session-descriptor>
    <reference-descriptor>
    <resource-description>
    <res-ref-name>jdbc/OracleDS</res-ref-name>
    <jndi-name>OracleDS</jndi-name>
    </resource-description>
    </reference-descriptor>
    <enable-call-by-reference>True</enable-call-by-reference>
    <jndi-name>tacplanner/register</jndi-name>
    </weblogic-enterprise-bean>
    </weblogic-ejb-jar>
    --------------------

    Problem solved.
    For remote clients you need to generate and use the stub classes for EJB interfaces using Weblogic's appc utility.
    See: "http://e-docs.bea.com/wls/docs81/ejb/appc_ejbc.html#1151900"
    --BobC                                                                                                                                                                                                                                                                                                                                                                                                                               

  • Servlet jndi lookup to remote EJB, servlet and EJB not in the same application

    Hi,
    I think that the subject explain my problem.
    I have Oracle IAS9i 9.0.2.0.0, and JDeveloper 9.0.2.829
    I have deployed and EJB in IAS9i and i want to use from the developer machines, which have JDeveloper.
    how can i to do remote calls from JDeveloper?.
    I have modifed the orion-application.xml, and added remote=true.
    I have modifed the rmi.xml and added the hosts where the Jdeveloper placed.
    Any ideas?
    Thanks and cheers
    P.D The app server and jdeveloper are in the same net.
    if it is posible replys me to [email protected] too.

    Steps to access a remote EJB from within OC4J
    ++++++++++++++++++++++++++++++++++++++++++++++
    1) Deploy EJB application (ApplicationRemote) to remote container (REMOTE)
    "java -jar admin.jar -deploy ormi://REMOTE.hostname:REMOTE.port REMOTE.username REMOTE.password -deploy -file ApplicationRemote.ear
    -deploymentName ApplicationRemote"
    2) Ensure that local application (ApplicationLocal) has ejb-ref tags for remote EJBs accessed (in web.xml or ejb-jar.xml)
    3) Deploy to local container (LOCAL) an empty application (ApplicationEmpty) with the same name as the remote application (ApplicationRemote)
    "java -jar admin.jar -deploy ormi://LOCAL.hostname:LOCAL.port LOCAL.username LOCAL.password -deploy -file ApplicationEmpty.ear -deploymentName
    ApplicationRemote"
    5) Deploy local application (ApplicationLocal) to local container (LOCAL)
    "java -jar admin.jar -deploy ormi://LOCAL.hostname:LOCAL.port LOCAL.username LOCAL.password -deploy -file ApplicationLocal.ear -deploymentName
    ApplicationLocal"
    4)Restart local container
    ApplicationEmpty should consist of just an application.xml file - no modules. The same file can be deployed with different application names for all the remote
    applications that must be accessed.
    ApplicationLocal should access the remote EJB by using the following JNDI properties
    java.naming.factory.initial = "com.evermind.server.rmi.RMIInitialContextFactory"
    java.naming.provider.url = "ormi://REMOTE.hostname:REMOTE.port/ApplicationRemote"
    java.naming.security.principal = "REMOTE.username"
    java.naming.security.credentials = "REMOTE.password"
    regards
    Debu Panda

Maybe you are looking for

  • Client Program accessing J2EE entity Bean

    I have trouble find my Course J2EE bean from a client. (The client runs on the same computer but a different VM from the bean.) In Glassfish (Sun Application Server Nine), I set up a simple Container-Managed Entity Bean. I tried to access it from an

  • How to get block stock of QI and UR

    Dear All,              I have a requirement to create a customized report for Finished products stocks. Selection screen:    - Plant    - S/Loc    - material    - month    - year Output has opening and closing balance, of stocks . I am fetching block

  • Lost my computer and my itunes backup!

    I had a windows xp computer that I had my Iphone synced to. I had backup of music, photos and applications. then I lost my computer and got a new one with windows 7. the problem now is that when I connect my iphone with my new itunes, it will ERASE a

  • Additinal tab B in sales Order header not displayed after EHP5 upgrade

    Hello Everyone,                           I am facing an issue that the 'Additional data B' in the sales order header is not getting displayed after we ugraded to EHP5.       We found the issue , that the screen '8309' provided by SAP for the additio

  • Trying to update Adobe Flash Player: 'update' seems to be OUT of date

    I've been trying to download updated version of Adobe Flash Player over & over again for over two hours. The only available version reads 'updated April 19, 2013' and does not work - I am still seeing "blocked plug-in" everywhere there should be a vi