RemoteException by Registry.lookup() in applet

I am getting a RemoteException when calling Registry.lookup() from an applet.
The more specific exception is
java.rmi.UnmarshalException: error unmarshalling return; nested exception is:
     java.lang.ClassNotFoundException: access denied to class loader
Now, exactly the same code executes OK in the application, looking up the same object.
Is there anything special I need to do if the RMI client is an applet?
Any ideas? anyone?
Oh, I am running my applet in IE5, in Java Plug-in.

Thanks for reply.
Actually IE lets you change security settings for unsigned applets as well as signed. So I tried to set the lowest security for unsigned applets first. That didn?t make any difference. Besides, there is no RMI security setting in IE.
I am not sure the applet needs to be signed to make RMI calls to the host in was loaded from. I maybe wrong though.

Similar Messages

  • Weblogic JNDI lookup in Applet

    Hi
    We are facing problem in JNDI lookup inside the applet
    here is the scenario
    We have two weblogic servers(port 7001)
    one server is main server where the Applet1 , weblogic.jar and app.htm
    are in C:\bea\wlserver6.0sp1\config\mydomain\applications\DefaultWebApp_myserver
    and another is proxy server where HTTPProxyServlet is running and one
    web.xml file ( wall these files are provided by weblogic and the port
    of proxy server is 448)
    Both the servers are running on different machines
    and when we run the client browser and put the folloing url
    http://proxyServer IP Address:448/app.htm
    we get the following exception
    Java(TM) Plug-in: Version 1.3.0-C
    Using JRE version 1.3.0 Java HotSpot(TM) Client VM
    User home directory = C:\Documents and Settings\kkumar
    Proxy Configuration: no proxy
    JAR cache enabled.
    In Init.1..:
    In Init.after ..doClassLoaderWorkaround
    In Init.after setText:
    In Init.before initjms:
    In initjms begin
    In initjms hostName...:10.1.10.211
    In initjms before initialcontext...:
    In initjms after initialcontext...:
    javax.naming.ConfigurationException. Root exception is
    java.rmi.MarshalException: failed to marshal public abstract
    java.lang.Object
    weblogic.jndi.internal.NamingNode.lookup(java.lang.String,java.util.Hashtable)
    throws javax.naming.NamingException,java.rmi.RemoteException; nested
    exception is:
    java.io.NotSerializableException: javax.naming.InitialContext
    java.io.NotSerializableException: javax.naming.InitialContext
    at java.io.ObjectOutputStream.outputObject(Unknown Source)
    at java.io.ObjectOutputStream.writeObject(Unknown Source)
    at java.io.ObjectOutputStream.outputClassFields(Unknown Source)
    at java.io.ObjectOutputStream.defaultWriteObject(Unknown Source)
    at java.io.ObjectOutputStream.outputObject(Unknown Source)
    at java.io.ObjectOutputStream.writeObject(Unknown Source)
    at java.util.Hashtable.writeObject(Unknown Source)
    at java.lang.reflect.Method.invoke(Native Method)
    at java.io.ObjectOutputStream.invokeObjectWriter(Unknown Source)
    at java.io.ObjectOutputStream.outputObject(Unknown Source)
    at java.io.ObjectOutputStream.writeObject(Unknown Source)
    at
    weblogic.common.internal.ChunkedObjectOutputStream.writeObject(ChunkedObjectOutputStream.java:102)
    at
    weblogic.common.internal.ChunkedObjectOutputStream.writeObject(ChunkedObjectOutputStream.java:108)
    at weblogic.rmi.internal.ObjectIO.writeObject(ObjectIO.java:19)
    at
    weblogic.rmi.internal.BasicRemoteRef.marshalArgs(BasicRemoteRef.java:121)
    at
    weblogic.rmi.cluster.ReplicaAwareRemoteRef.invoke(ReplicaAwareRemoteRef.java:246)
    at
    weblogic.rmi.cluster.ReplicaAwareRemoteRef.invoke(ReplicaAwareRemoteRef.java:225)
    at
    weblogic.jndi.internal.ServerNamingNode_WLStub.lookup(ServerNamingNode_WLStub.java:121)
    at weblogic.jndi.internal.WLContextImpl.lookup(WLContextImpl.java:323)
    at javax.naming.InitialContext.lookup(Unknown Source)
    at Applet1.initJMS(Applet1.java:128)
    at Applet1.init(Applet1.java:46)
    at sun.applet.AppletPanel.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)
    Initialization failed
    In Init.end of initjms:
    the files are here
    app.htm
                   <OBJECT classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93"
                        width="650" height="300" align="baseline"
                        codebase="http://java.sun.com/products/plugin/1.2.2/jinstall-1_2_2-win.cab#Version=1,2,2,0"
    >
                   <PARAM NAME="code" VALUE="Applet1">
                   <PARAM NAME="codebase" VALUE=".">
                   <PARAM NAME="AppletName" VALUE="Applet1">
                   <PARAM NAME="archive" VALUE="weblogic.jar">
                   <PARAM NAME="MAYSCRIPT" VALUE="true">
                   <PARAM NAME="type"
    VALUE="application/x-java-applet;version=1.2.2">
                   <PARAM NAME="model" VALUE="models/HyaluronicAcid.xyz">
                   <PARAM NAME="scriptable" VALUE="true">
                   <!--
                   <COMMENT>
                        <EMBED type="application/x-java-applet;version=1.2.2" width="650"
    height="300" align="baseline"
                                  code="ANZPopupApplet.class" codebase="../"
    model="models/HyaluronicAcid.xyz"
                             pluginspage="http://java.sun.com/products/plugin/1.2/plugin-install.html"
    MAYSCRIPT="true">
                        <NOEMBED>
                   </COMMENT>
                   -->
                                  No JDK 1.2 support for APPLET!!
                        </NOEMBED>
                        </EMBED>
                   </OBJECT>
    </html>
    Applet1.java
    import java.awt.*;
    import java.applet.*;
    import java.net.*;
    import java.util.*;
    import javax.naming.*;
    import javax.jms.*;
    import java.lang.reflect.*;
    public class Applet1 extends Applet implements MessageListener {
    private boolean started = false;
    // JMS Stuff
    private InitialContext jmsContext = null;
    private QueueConnectionFactory jmsConnFactory = null;
    private QueueConnection jmsConnection = null;
    private Queue jmsQueue = null;
    private QueueSession jmsSession = null;
    private QueueSender jmsSender = null;
    private QueueReceiver jmsReceiver = null;
    // init - called to inform this applet that it has been
    // loaded into the system
    public void init() {
    //{{INIT_CONTROLS
    System.out.println("In Init.1..:");
         //doClassLoaderWorkaround();
    System.out.println("In Init.after ..doClassLoaderWorkaround");
    setLayout(null);
    setSize(426,266);
    jmslabel.setText("JMS Applet");
    System.out.println("In Init.after setText:");
    add(jmslabel);
    jmslabel.setBounds(144,12,148,24);
    textArea1.setEnabled(false);
    add(textArea1);
    textArea1.setBounds(24,36,375,100);
    jmsleaveButton.setLabel("Leave");
    add(jmsleaveButton);
    jmsleaveButton.setBackground(java.awt.Color.lightGray);
    jmsleaveButton.setBounds(312,240,78,20);
    add(jmsMessageField);
    jmsMessageField.setBounds(24,168,367,38);
    System.out.println("In Init.before initjms:");
    initJMS();
    System.out.println("In Init.end of initjms:");
    //{{DECLARE_CONTROLS
         java.awt.Label jmslabel = new java.awt.Label();
         java.awt.TextArea textArea1 = new java.awt.TextArea();
         java.awt.Button jmsleaveButton = new java.awt.Button();
         java.awt.TextField jmsMessageField = new java.awt.TextField();
    // getAppletInfo - Returns information about this applet.
    public String getAppletInfo() {
    return "JMS Applet\r\n";
    // destroy - called to inform this applet that it is being
    // reclaimed and that it should destroy any resources that
    // it has allocated.
    public void destroy() {
    try {
    if(started) {
    if (jmsConnection != null) {
    jmsConnection.stop();
    jmsConnection = null;
    started = false;
    stop();
    catch(Exception e) {
    // start - called to inform this applet that it should start its
    execution
    public void start() {
    if(!started) {
    started = true;
    // stop - Called to inform this applet that it should stop its
    execution
    public void stop() {
    textArea1.setEnabled(false);
    jmsMessageField.setEnabled(false);
    // action - handles entering message, Leave button clicked
    public boolean action(Event evt, Object obj) {
    System.out.println("In action begin:");
    if(evt.id == Event.ACTION_EVENT) {
    if(obj.equals(jmsMessageField.getText())) {
    System.out.println("In action before sendData:");
    sendData(jmsMessageField.getText());
    System.out.println("In action after sendData:");
    jmsMessageField.setText("");
    return true;
    if(obj.equals(jmsleaveButton.getLabel())) {
    destroy();
    return true;
    // initJMS - initialize all of the JMS stuff
    private void initJMS() {
    try {
    System.out.println("In initjms begin");
    String hostName = this.getCodeBase().getHost();
    System.out.println("In initjms hostName...:"+hostName);
    Hashtable env = new Hashtable();
    env.put(Context.APPLET,this);
    env.put(Context.PROVIDER_URL,
    "t3://" + hostName + ":448");
    env.put(Context.INITIAL_CONTEXT_FACTORY,
    "weblogic.jndi.WLInitialContextFactory");
    System.out.println("In initjms before initialcontext...:");
    jmsContext = new InitialContext(env);
    System.out.println("In initjms after initialcontext...:");
    jmsConnFactory
    =(QueueConnectionFactory)jmsContext.lookup("javax.jms.QueueConnectionFactory");
    System.out.println("In initjms after initialcontext..lookup.:");
    jmsConnection = jmsConnFactory.createQueueConnection();
    System.out.println("In initjms after initialcontext..lookup1.:");
    jmsSession = jmsConnection.createQueueSession(false,Session.AUTO_ACKNOWLEDGE);
    System.out.println("In initjms before lookup...:");
    jmsQueue =(Queue)jmsContext.lookup("jms.queue.TestQueue1");
    jmsConnection.start();
    jmsSender = jmsSession.createSender(jmsQueue);
    jmsReceiver = jmsSession.createReceiver(jmsQueue);
    jmsReceiver.setMessageListener(this);
    System.out.println("In initjms before setMessageListener...end of the
    const:");
    catch(Exception e) {
    e.printStackTrace();
    System.out.println("Initialization failed");
    // sendData - sends a message
    void sendData(String data) {
    try {
    System.out.println("In sendData before createTextMessage:");
    TextMessage message = jmsSession.createTextMessage();
    message.setText(data);
    jmsSender.send(message);
    System.out.println("In sendData end data:"+data);
    catch(Exception e) {
    System.out.println("Failed to send message");
    // onMessage - asynchronously receives a message
    public void onMessage(Message message) {
    String data;
    try {
    System.out.println("In onMessage:");
    data = ((TextMessage)message).getText();
    System.out.println("In onMessage data:"+data);
    textArea1.append(data + "\n");
    repaint();
    System.out.println("In onMessage end:");
    catch(Exception e) {
    System.out.println("Failed to receive message");
    private void doClassLoaderWorkaround(){
    boolean didit = false;
    // Get the ClassLoader of this applet:
    ClassLoader cloader = this.getClass().getClassLoader();
    if (cloader == null){
    System.out.println("### getClassLoader() returned null");
    else
    // We might call this handy utility routine:
    // boolean didit =
    Thread.currentThread().setContextClassLoader(cloader);
         Method setContextClassLoaderMeth = null;
         try {
              Method [] allMethods = Thread.class.getMethods();
              for ( int i = 0; i < allMethods.length; i++ ) {
                   if (allMethods.getName().equals("setContextClassLoader")) {
                        setContextClassLoaderMeth = allMethods[i];
                        break;
         catch(Exception e) {
              System.out.println("---Exception " + e);
    // but we don't because we need more visibility about what goes
    wrong.
    // Rather, reproduce that logic here, with extra error messages:
    //Method setContextClassLoaderMeth = null;
    try{
    // Class params = ClassLoader.class ;
    // setContextClassLoaderMeth =
    //Thread.class.getMethod("setContextClassLoader", params);
    catch (NoSuchMethodException ne) {
    setContextClassLoaderMeth = null;
    System.out.println("--- This java version does not have the
    method 'setContextClassLoader'. Not a problem.");
    return;
    catch (Exception ae){
    setContextClassLoaderMeth = null;
    System.out.println("### Thread.class.getMethod() threw
    unexpected exception: " + ae.getMessage());
    if (setContextClassLoaderMeth != null){
    Object[] args = { cloader };
    try{
    setContextClassLoaderMeth.invoke(Thread.currentThread(),
    args);
    didit = true;
    catch (InvocationTargetException ite){
    Throwable be = ite.getTargetException();
    System.out.println("### Thread.setContextClassLoader() failed:
    InvocationTargetException: " + be.getMessage());
    catch (Exception ie){
    System.out.println("### Thread.setContextClassLoader() threw
    unexpected exception: " + ie.getMessage());
    if (didit){
    System.out.println("--- Succeeded in setting the
    ContextClassLoader of this thread to be this applet's own
    ClassLoader");
    else{
    System.out.println("### Could not set ContextClassLoader,
    additional threads may not be able");
    System.out.println("### to get a JNDI Context in java 122 or
    greater.");
    any clue or thought. please help
    regards
    mohan

    It looks like the object that you have placed into the JNDO tree is not serializable or doesnt implement exernalizable!
    java.io.NotSerializableException
    0rrc
    On 26 Jul 2001 16:10:35 -0700, [email protected] (Mohan Raj) wrote:
    Hi
    We are facing problem in JNDI lookup inside the applet
    here is the scenario
    We have two weblogic servers(port 7001)
    one server is main server where the Applet1 , weblogic.jar and app.htm
    are in C:\bea\wlserver6.0sp1\config\mydomain\applications\DefaultWebApp_myserver
    and another is proxy server where HTTPProxyServlet is running and one
    web.xml file ( wall these files are provided by weblogic and the port
    of proxy server is 448)
    Both the servers are running on different machines
    and when we run the client browser and put the folloing url
    http://proxyServer IP Address:448/app.htm
    we get the following exception
    Java(TM) Plug-in: Version 1.3.0-C
    Using JRE version 1.3.0 Java HotSpot(TM) Client VM
    User home directory = C:\Documents and Settings\kkumar
    Proxy Configuration: no proxy
    JAR cache enabled.
    In Init.1..:
    In Init.after ..doClassLoaderWorkaround
    In Init.after setText:
    In Init.before initjms:
    In initjms begin
    In initjms hostName...:10.1.10.211
    In initjms before initialcontext...:
    In initjms after initialcontext...:
    javax.naming.ConfigurationException. Root exception is
    java.rmi.MarshalException: failed to marshal public abstract
    java.lang.Object
    weblogic.jndi.internal.NamingNode.lookup(java.lang.String,java.util.Hashtable)
    throws javax.naming.NamingException,java.rmi.RemoteException; nested
    exception is:
    java.io.NotSerializableException: javax.naming.InitialContext
    java.io.NotSerializableException: javax.naming.InitialContext
    at java.io.ObjectOutputStream.outputObject(Unknown Source)
    at java.io.ObjectOutputStream.writeObject(Unknown Source)
    at java.io.ObjectOutputStream.outputClassFields(Unknown Source)
    at java.io.ObjectOutputStream.defaultWriteObject(Unknown Source)
    at java.io.ObjectOutputStream.outputObject(Unknown Source)
    at java.io.ObjectOutputStream.writeObject(Unknown Source)
    at java.util.Hashtable.writeObject(Unknown Source)
    at java.lang.reflect.Method.invoke(Native Method)
    at java.io.ObjectOutputStream.invokeObjectWriter(Unknown Source)
    at java.io.ObjectOutputStream.outputObject(Unknown Source)
    at java.io.ObjectOutputStream.writeObject(Unknown Source)
    at
    weblogic.common.internal.ChunkedObjectOutputStream.writeObject(ChunkedObjectOutputStream.java:102)
    at
    weblogic.common.internal.ChunkedObjectOutputStream.writeObject(ChunkedObjectOutputStream.java:108)
    at weblogic.rmi.internal.ObjectIO.writeObject(ObjectIO.java:19)
    at
    weblogic.rmi.internal.BasicRemoteRef.marshalArgs(BasicRemoteRef.java:121)
    at
    weblogic.rmi.cluster.ReplicaAwareRemoteRef.invoke(ReplicaAwareRemoteRef.java:246)
    at
    weblogic.rmi.cluster.ReplicaAwareRemoteRef.invoke(ReplicaAwareRemoteRef.java:225)
    at
    weblogic.jndi.internal.ServerNamingNode_WLStub.lookup(ServerNamingNode_WLStub.java:121)
    at weblogic.jndi.internal.WLContextImpl.lookup(WLContextImpl.java:323)
    at javax.naming.InitialContext.lookup(Unknown Source)
    at Applet1.initJMS(Applet1.java:128)
    at Applet1.init(Applet1.java:46)
    at sun.applet.AppletPanel.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)
    Initialization failed
    In Init.end of initjms:
    the files are here
    app.htm
                   <OBJECT classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93"
                        width="650" height="300" align="baseline"
                        codebase="http://java.sun.com/products/plugin/1.2.2/jinstall-1_2_2-win.cab#Version=1,2,2,0"
    >
                   <PARAM NAME="code" VALUE="Applet1">
                   <PARAM NAME="codebase" VALUE=".">
                   <PARAM NAME="AppletName" VALUE="Applet1">
                   <PARAM NAME="archive" VALUE="weblogic.jar">
                   <PARAM NAME="MAYSCRIPT" VALUE="true">
                   <PARAM NAME="type"
    VALUE="application/x-java-applet;version=1.2.2">
                   <PARAM NAME="model" VALUE="models/HyaluronicAcid.xyz">
                   <PARAM NAME="scriptable" VALUE="true">
                   <!--
                   <COMMENT>
                        <EMBED type="application/x-java-applet;version=1.2.2" width="650"
    height="300" align="baseline"
                                  code="ANZPopupApplet.class" codebase="../"
    model="models/HyaluronicAcid.xyz"
                             pluginspage="http://java.sun.com/products/plugin/1.2/plugin-install.html"
    MAYSCRIPT="true">
                        <NOEMBED>
                   </COMMENT>
                   -->
                                  No JDK 1.2 support for APPLET!!
                        </NOEMBED>
                        </EMBED>
                   </OBJECT>
    </html>
    Applet1.java
    import java.awt.*;
    import java.applet.*;
    import java.net.*;
    import java.util.*;
    import javax.naming.*;
    import javax.jms.*;
    import java.lang.reflect.*;
    public class Applet1 extends Applet implements MessageListener {
    private boolean started = false;
    // JMS Stuff
    private InitialContext jmsContext = null;
    private QueueConnectionFactory jmsConnFactory = null;
    private QueueConnection jmsConnection = null;
    private Queue jmsQueue = null;
    private QueueSession jmsSession = null;
    private QueueSender jmsSender = null;
    private QueueReceiver jmsReceiver = null;
    // init - called to inform this applet that it has been
    // loaded into the system
    public void init() {
    //{{INIT_CONTROLS
    System.out.println("In Init.1..:");
         //doClassLoaderWorkaround();
    System.out.println("In Init.after ..doClassLoaderWorkaround");
    setLayout(null);
    setSize(426,266);
    jmslabel.setText("JMS Applet");
    System.out.println("In Init.after setText:");
    add(jmslabel);
    jmslabel.setBounds(144,12,148,24);
    textArea1.setEnabled(false);
    add(textArea1);
    textArea1.setBounds(24,36,375,100);
    jmsleaveButton.setLabel("Leave");
    add(jmsleaveButton);
    jmsleaveButton.setBackground(java.awt.Color.lightGray);
    jmsleaveButton.setBounds(312,240,78,20);
    add(jmsMessageField);
    jmsMessageField.setBounds(24,168,367,38);
    System.out.println("In Init.before initjms:");
    initJMS();
    System.out.println("In Init.end of initjms:");
    //{{DECLARE_CONTROLS
         java.awt.Label jmslabel = new java.awt.Label();
         java.awt.TextArea textArea1 = new java.awt.TextArea();
         java.awt.Button jmsleaveButton = new java.awt.Button();
         java.awt.TextField jmsMessageField = new java.awt.TextField();
    // getAppletInfo - Returns information about this applet.
    public String getAppletInfo() {
    return "JMS Applet\r\n";
    // destroy - called to inform this applet that it is being
    // reclaimed and that it should destroy any resources that
    // it has allocated.
    public void destroy() {
    try {
    if(started) {
    if (jmsConnection != null) {
    jmsConnection.stop();
    jmsConnection = null;
    started = false;
    stop();
    catch(Exception e) {
    // start - called to inform this applet that it should start its
    execution
    public void start() {
    if(!started) {
    started = true;
    // stop - Called to inform this applet that it should stop its
    execution
    public void stop() {
    textArea1.setEnabled(false);
    jmsMessageField.setEnabled(false);
    // action - handles entering message, Leave button clicked
    public boolean action(Event evt, Object obj) {
    System.out.println("In action begin:");
    if(evt.id == Event.ACTION_EVENT) {
    if(obj.equals(jmsMessageField.getText())) {
    System.out.println("In action before sendData:");
    sendData(jmsMessageField.getText());
    System.out.println("In action after sendData:");
    jmsMessageField.setText("");
    return true;
    if(obj.equals(jmsleaveButton.getLabel())) {
    destroy();
    return true;
    // initJMS - initialize all of the JMS stuff
    private void initJMS() {
    try {
    System.out.println("In initjms begin");
    String hostName = this.getCodeBase().getHost();
    System.out.println("In initjms hostName...:"+hostName);
    Hashtable env = new Hashtable();
    env.put(Context.APPLET,this);
    env.put(Context.PROVIDER_URL,
    "t3://" + hostName + ":448");
    env.put(Context.INITIAL_CONTEXT_FACTORY,
    "weblogic.jndi.WLInitialContextFactory");
    System.out.println("In initjms before initialcontext...:");
    jmsContext = new InitialContext(env);
    System.out.println("In initjms after initialcontext...:");
    jmsConnFactory
    =(QueueConnectionFactory)jmsContext.lookup("javax.jms.QueueConnectionFactory");
    System.out.println("In initjms after initialcontext..lookup.:");
    jmsConnection = jmsConnFactory.createQueueConnection();
    System.out.println("In initjms after initialcontext..lookup1.:");
    jmsSession = jmsConnection.createQueueSession(false,Session.AUTO_ACKNOWLEDGE);
    System.out.println("In initjms before lookup...:");
    jmsQueue =(Queue)jmsContext.lookup("jms.queue.TestQueue1");
    jmsConnection.start();
    jmsSender = jmsSession.createSender(jmsQueue);
    jmsReceiver = jmsSession.createReceiver(jmsQueue);
    jmsReceiver.setMessageListener(this);
    System.out.println("In initjms before setMessageListener...end of the
    const:");
    catch(Exception e) {
    e.printStackTrace();
    System.out.println("Initialization failed");
    // sendData - sends a message
    void sendData(String data) {
    try {
    System.out.println("In sendData before createTextMessage:");
    TextMessage message = jmsSession.createTextMessage();
    message.setText(data);
    jmsSender.send(message);
    System.out.println("In sendData end data:"+data);
    catch(Exception e) {
    System.out.println("Failed to send message");
    // onMessage - asynchronously receives a message
    public void onMessage(Message message) {
    String data;
    try {
    System.out.println("In onMessage:");
    data = ((TextMessage)message).getText();
    System.out.println("In onMessage data:"+data);
    textArea1.append(data + "\n");
    repaint();
    System.out.println("In onMessage end:");
    catch(Exception e) {
    System.out.println("Failed to receive message");
    private void doClassLoaderWorkaround(){
    boolean didit = false;
    // Get the ClassLoader of this applet:
    ClassLoader cloader = this.getClass().getClassLoader();
    if (cloader == null){
    System.out.println("### getClassLoader() returned null");
    else
    // We might call this handy utility routine:
    // boolean didit =
    Thread.currentThread().setContextClassLoader(cloader);
         Method setContextClassLoaderMeth = null;
         try {
              Method [] allMethods = Thread.class.getMethods();
              for ( int i = 0; i < allMethods.length; i++ ) {
                   if (allMethods.getName().equals("setContextClassLoader")) {
                        setContextClassLoaderMeth = allMethods[i];
                        break;
         catch(Exception e) {
              System.out.println("---Exception " + e);
    // but we don't because we need more visibility about what goes
    wrong.
    // Rather, reproduce that logic here, with extra error messages:
    //Method setContextClassLoaderMeth = null;
    try{
    // Class params = ClassLoader.class ;
    // setContextClassLoaderMeth =
    //Thread.class.getMethod("setContextClassLoader", params);
    catch (NoSuchMethodException ne) {
    setContextClassLoaderMeth = null;
    System.out.println("--- This java version does not have the
    method 'setContextClassLoader'. Not a problem.");
    return;
    catch (Exception ae){
    setContextClassLoaderMeth = null;
    System.out.println("### Thread.class.getMethod() threw
    unexpected exception: " + ae.getMessage());
    if (setContextClassLoaderMeth != null){
    Object[] args = { cloader };
    try{
    setContextClassLoaderMeth.invoke(Thread.currentThread(),
    args);
    didit = true;
    catch (InvocationTargetException ite){
    Throwable be = ite.getTargetException();
    System.out.println("### Thread.setContextClassLoader() failed:
    InvocationTargetException: " + be.getMessage());
    catch (Exception ie){
    System.out.println("### Thread.setContextClassLoader() threw
    unexpected exception: " + ie.getMessage());
    if (didit){
    System.out.println("--- Succeeded in setting the
    ContextClassLoader of this thread to be this applet's own
    ClassLoader");
    else{
    System.out.println("### Could not set ContextClassLoader,
    additional threads may not be able");
    System.out.println("### to get a JNDI Context in java 122 or
    greater.");
    any clue or thought. please help
    regards
    mohan

  • Can I make an entry in widows Registry through an applet?

    Hi,
    Can i make an entry in the windows registry using applets?
    actually i want to make an entry on a remote machine. is it possible?
    if yes, then how?
    thnx
    kapilChhabra

    Signing an applet basically gives it a certificate. The user decides whether to accept it. If no, it runs as a normal applet, if yes, it runs as a privileged applet like an application. Typically you would purchase certificates, but this is not necessary. You can self-sign. If the user knows and trusts you, he will click yes anyway.
    Read this: http://java.sun.com/j2se/1.4.2/docs/guide/plugin/developer_guide/rsa_signing.html
    Monika.

  • Difference between Naming.lookup and Registry.lookup in RMI

    Hi Folks,
    I have an RMI client which tries to look up a remote object using both
    Naming.lookup("//host[:port]/name OR rmi://<host_name>[:<name_service_port>]/<service_name>") and LocateRegistry.getRegistry().lookup("rmi://<host_name>[:<name_service_port>]/<service_name>").
    The first one fails whereas the second one succeeds. I am in a fix as to why it is so.Is there any difference between the lookup methods provided by Naming and Registry?
    The remote object was registered on the server using
    LocateRegistry.createRegistry().rebind("rmi://<host_name>[:<name_service_port>]/<service_name>").

    I suggest you take a look at this site to understand how to ask questions.
    And don't crosspost again

  • Registry.lookup() return Remote object from different ip address

    I've got this error using
    Registry reg = LocateRegistry.getRegistry(serverName, Registry.REGISTRY_PORT);
    service = (ILogin) reg.lookup("service");and when I use debugger I've got this
    RegistryImpl_Stub[UnicastRef [liveRef: [endpoint:[10.240.161.66:1099](remote),objID:[0:0:0, 0]]]]
    Proxy[ILogin,RemoteObjectInvocationHandler[UnicastRef [liveRef: [endpoint:[10.240.161.54:2074](remote),objID:[-4308ea07:116adade605:-7fff, 9133145996543447416]]]]]Why the Registry return a service from different IP address ?
    I've run this code for several times and it works. But today it cannot connect to the RMIServer.
    Any idea ?

    Thanks, i found my missing prppertis is
    // optional. Defaults to localhost. Only needed if web server is running
    // on a different host than the appserver
    props.setProperty("org.omg.CORBA.ORBInitialHost", "localhost");
    // optional. Defaults to 3700. Only needed if target orb port is not 3700.
    props.setProperty("org.omg.CORBA.ORBInitialPort", "3700");
    to set the port and host back

  • Client/server model and avoiding a registry lookup

    Sorry if this question has been asked/answered before - I searched the forums and could not find the answer to my quesiton.
    I am using RMI to model a fairly vanilla client/server protocol. Client to server communctions are no problem (yet :-)) . The problem is, that sometimes I want the server to initiate communcations to the client (I guess the client would be acting as the 'server' in those instances although the client is the one that makes the initial connection) Is there any way to do this without the server having to bind the client in the client's remote registry? That would require a open port and I want to avoid that for people who are behind firewalls. I was thinking the client could pass an instance of itself, or an instance of a bound stub, and as long as it implemented 'Remote' then it should be OK. I don't have a problem setting up a registry client side, but if I pass an instance of client that is either registry bound or unbound, as long as it implements Remote, (or rather an interface that extends Remote) will the server make remote calls on the client object?
    Message was edited by:
    SunDog

    It's done all the time. What you're looking for is called "callback." Sun has a tutorial.
    One note: Calling the client requires the client to open a port for communication. This happens when the client exports the remote object.

  • Registry's EnumKey Lookup Failing When Called By MSBuild?

    A MS-DOS script executes the VBScript below and it works fine. However, when using a MS Build master deployment file which calls the aforementioned MS-DOS script, the 2nd location lookup ("SOFTWARE\Microsoft\Windows\CurrentVersion\Installer\UserData\S-1-5-18\Products\")
    fails with a result code of 2. I have spent countless hours trying to figure out why the difference. Any ideas?
    Const HKLM = &H80000002 'HKEY_LOCAL_MACHINE
    Set oRegistry = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & node & "/root/default:StdRegProv")
    REM 1st location: "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\"
    sBaseKey = "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\"
    iRC = oRegistry.EnumKey(HKLM, sBaseKey, arSubKeys)
    If iRC <> 0 THEN
    WScript.Echo "Registry lookup failed for " & sBaseKey
    ELSE
    For Each sKey In arSubKeys
    iRC = oRegistry.GetStringValue(HKLM, sBaseKey & sKey, "DisplayName", sValue)
    If sValue = Wscript.Arguments.Item(1) Then
    oRegistry.GetStringValue HKLM, sBaseKey & sKey, "UninstallString", sValue
    InstalledApplications = Replace(sValue, "/I{", "/X{")
    IF LEN(InstalledApplications) > 0 THEN
    InstalledApplications = InstalledApplications & " /qn /l*vx """ & sFile & ".Log"""  & Chr(13) & Chr(10) 
    END IF
    END IF
    NEXT
    END IF
    REM 2nd location: "SOFTWARE\Microsoft\Windows\CurrentVersion\Installer\UserData\S-1-5-18\Products\<GUID>\InstallProperties"
    arProducts = NULL
    sBaseKey = "SOFTWARE\Microsoft\Windows\CurrentVersion\Installer\UserData\S-1-5-18\Products\"
    iRC = oRegistry.EnumKey(HKLM, sBaseKey, arProducts)
    If iRC <> 0 THEN
    WScript.Echo "Registry lookup failed for " & sBaseKey
    ELSE
    For Each guid In arProducts
    sInnerKey = sBaseKey & guid & "\InstallProperties\"
    iRC = oRegistry.GetStringValue(HKLM, sInnerKey, "DisplayName", sValue)
    If sValue = Wscript.Arguments.Item(1) Then
    oRegistry.GetStringValue HKLM, sInnerKey, "UninstallString", sValue
    InstalledApplications = Replace(sValue, "/I{", "/X{")
    IF LEN(InstalledApplications) > 0 THEN
    InstalledApplications = InstalledApplications & " /qn /l*vx """ & sFile & ".Log""" & Chr(13) & Chr(10) 
    END IF
    END IF
    NEXT
    InstalledApplications = InstalledApplications & "GOTO:EOF"
    END IF
    Shawn ([email protected])

    Or try sysnative:
    https://msdn.microsoft.com/en-us/library/windows/desktop/aa384187%28v=vs.85%29.aspx
    Don't retire TechNet! -
    (Don't give up yet - 13,225+ strong and growing)
    But that is not a portable solution.  it does not apply to 32 bit platforms and will only work from a 64 bit session when calling intp a 32 bit session.
    If we are in a 32 bit session running VBScript then we cannot see the 64 bit registry without the help of WMI.  The correct solution is to build in the correct environment.  If you want to run in both environments then you will need to test the
    32 bit version on a 32 bit system assuming the applications being enumerated use the same keys on both architectures.
    ¯\_(ツ)_/¯
    This is correct. I totally forgot there are 32 bit and 64 bit versions of MSBuild. I made no changes except to execute the main deployment script with the 64 bit version of MS Build. Thank you for all of your help.
    -Shawn
    Shawn ([email protected])

  • "java.rmi.UnmarshalException: error unmarshalling" at Applet with RMI comm.

    Hello,
    I am trying to make an Applet work with an RMI server, but i keep getting the same exception again and again whatever i do.
    More specifically, i get the following :
    java.rmi.UnmarshalException: error unmarshalling return; nested exception is:
         java.net.MalformedURLException: unknown protocol: c
         at sun.rmi.registry.RegistryImpl_Stub.lookup(Unknown Source)
         at server.ClientDemo.initGUI(ClientDemo.java:100)
         at server.ClientDemo.<init>(ClientDemo.java:85)
         at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
         at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
         at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
         at java.lang.reflect.Constructor.newInstance(Unknown Source)
         at java.lang.Class.newInstance0(Unknown Source)
         at java.lang.Class.newInstance(Unknown Source)
         at sun.applet.AppletPanel.createApplet(Unknown Source)
         at sun.applet.AppletPanel.runLoader(Unknown Source)
         at sun.applet.AppletPanel.run(Unknown Source)
         at java.lang.Thread.run(Unknown Source)
    Caused by: java.net.MalformedURLException: unknown protocol: c
         at java.net.URL.<init>(Unknown Source)
         at java.net.URL.<init>(Unknown Source)
         at java.net.URL.<init>(Unknown Source)
         at sun.rmi.server.LoaderHandler.pathToURLs(Unknown Source)
         at sun.rmi.server.LoaderHandler.loadProxyClass(Unknown Source)
         at java.rmi.server.RMIClassLoader$2.loadProxyClass(Unknown Source)
         at java.rmi.server.RMIClassLoader.loadProxyClass(Unknown Source)
         at sun.rmi.server.MarshalInputStream.resolveProxyClass(Unknown Source)
         at java.io.ObjectInputStream.readProxyDesc(Unknown Source)
         at java.io.ObjectInputStream.readClassDesc(Unknown Source)
         at java.io.ObjectInputStream.readOrdinaryObject(Unknown Source)
         at java.io.ObjectInputStream.readObject0(Unknown Source)
         at java.io.ObjectInputStream.readObject(Unknown Source)
         ... 13 more
    The exeption is thrown at the following line :
                   remoteReference = (RMIServer) registry.lookup(RMIServer.REGISTRY_NAME);
    This is the code of the server which seems to be running ok:
    if(System.getSecurityManager()==null)
                   System.setSecurityManager(new SecurityManager());
              registry = LocateRegistry.createRegistry(1099);
              RMIServer sr=(RMIServer) UnicastRemoteObject.exportObject(new ServerDemo(),1099);
              registry.rebind(RMIServer.REGISTRY_NAME, sr);
    and the client:
    registry = LocateRegistry.getRegistry("localhost");
    remoteReference = (RMIServer) registry.lookup(RMIServer.REGISTRY_NAME);
    Thank you in advance
    Alex
    Forgot to mention that i am setting the security policy and codebase programmatically:
    System.setProperty("java.security.policy","C:\\Users\\Alex\\workspace\\Demo\\grantall.policy");
              System.setProperty("java.rmi.server.codebase","C:\\Users\\Alex\\workspace\\Demo\\bin");
    Edited by: Alkon on May 15, 2008 4:31 PM

    I edited the code that sets the security and i am now getting the following error, again at the lookup:
    java.rmi.UnmarshalException: Error unmarshaling return header; nested exception is:
         java.io.EOFException
         at sun.rmi.transport.StreamRemoteCall.executeCall(Unknown Source)
         at sun.rmi.server.UnicastRef.invoke(Unknown Source)
         at sun.rmi.registry.RegistryImpl_Stub.lookup(Unknown Source)
         at server.ClientDemo.initGUI(ClientDemo.java:101)
         at server.ClientDemo.<init>(ClientDemo.java:91)
         at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
         at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
         at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
         at java.lang.reflect.Constructor.newInstance(Unknown Source)
         at java.lang.Class.newInstance0(Unknown Source)
         at java.lang.Class.newInstance(Unknown Source)
         at sun.applet.AppletPanel.createApplet(Unknown Source)
         at sun.applet.AppletPanel.runLoader(Unknown Source)
         at sun.applet.AppletPanel.run(Unknown Source)
         at java.lang.Thread.run(Unknown Source)
    Caused by: java.io.EOFException
         at java.io.DataInputStream.readByte(Unknown Source)
         ... 15 more

  • Rmi remote reference lookup very slow in web start application

    I have a little problem with the RMI communication in a web start test application.
    It is a very simple program in which the client calls a remote object that returns a String.
    Everything seems to be working fine when i'm running/debugging the client app in eclipse, but when i package my client project into a jar file and run it as a web start application (i'm providing the jnlp on a local webserver) the remote reference lookup takes about 15 seconds.
    basically, what my client does is this:
    Registry registry = LocateRegistry.getRegistry(address);
    ServerTransaction st= (ServerTransaction) registry.lookup(name);
    String result = st.test();
    The server code looks like this:
    String name = "ServerTransaction";
    ServerTransaction engine = new DefaultServerTransaction();
    ServerTransaction stub = (ServerTransaction) UnicastRemoteObject.exportObject(engine, 0);
    Registry registry = LocateRegistry.createRegistry(Registry.REGISTRY_PORT);
    registry.rebind(name, stub);
    The server runs as a normal stand alone java application on my local machine as well.
    And here the content of the jnlp file for the client application:
    <resources>
         <jar href="WSTest.jar"/>
         <jar href="WSTestServer.jar"/>
         <j2se version="1.6+" href="http://java.sun.com/products/autodl/j2se"/>
         <property name="serverAddress" value="127.0.0.1" />
    </resources>
    <security>
         <all-permissions/>
    </security>
    <application-desc main-class="test.WSTest"/>
    As i said, the whole thing works when run as a normal java application as well as with web start, with the difference that the remote reference lookup takes about 15 seconds with web start.
    Can anyone tell me how i could go about this?

    Meanwhile, i tried the same thing at home on my xp machine (i use vista at work), and even though my test at home basically does the same thing (invoking a simple remote method that just returns "hello world") it worked pretty fast, contary to the 15 second hang on vista.
    So i can't really say where the problem is...
    I also found these two rmi properties
    sun.rmi.transport.connectionTimeout (1.1.6 and later)
    The value of this property represents the period (in milliseconds) for which socket connections may reside in an "unused" state, before the Java RMI runtime will allow those connections to be freed (closed). The default value is 15000 milliseconds (15 seconds).
    and
    sun.rmi.transport.proxy.connectTimeout (1.1 and later)
    The value of this property represents the maximum length of time (in milliseconds) that the Java RMI runtime will wait for a connection attempt (createSocket) to complete, before attempting to contact the server using HTTP. This property is only used when the http.proxyHost property is set and the value of java.rmi.server.disableHttp is false. The default value is 15000 milliseconds (15 seconds).
    Hoping it would help (totally clueless) i tried to set these as system properties via System.setProperty(...) to a lower value (if that even works this was - please correct me if i am totally wrong here) but it didn't help.

  • Manual client deployment not picking up Group Policy provided registry settings

    We are having an issue with some laptops and machines that are turned off overnight not downloading necessary items for the SCCM 2012 client install.  We are going through the upgrade from 2007 to 2012 and are manually installing the client
    through the SCCM console.  Now that we have gotten the majority of our clients up to the 2012 version, we are planning to push the client going forward through WSUS.  Unfortunately, BITS is not allowing the update to come down in the time that some
    machines are on the network. 
    After some digging, we have concerns that the Group Policy setting for the command line properties are being ignored.
    We have the Group policy set as follows:
    /mp:oursccmserver.domain.com / service / forceinstall / BITSPriority:FOREGROUND SMSSITECODE=PRISITE FSP=OURFSP.domain.com
    However, the command line entry in the ccmsetup.log file on machines that have received the client as well as those not installing is showing the following:
    - Ccmsetup command line: "C\Windows\ccmsetup\ccmsetup.exe" /runservice /config:MobileClient.tcf
    - Command line parameters for ccmsetup have been specified. No registry lookup for command line parameters is required.
    Can someone tell me why it is not picking up the settings in the registry?  we have verified the settings are hitting the machines from GP, just does not seem to be using them which is why we thing it is allowing BITS to throttle the download of the
    pre-reqs.
    Thanks in advance for any suggesstions/help.

    Sorry for not updating this...
    After digging for days on this and contemplating calling MSFT support, I happened to check the Client Push installation properties and found the Install properties had been removed from each of our sites (1 primary and 2 secondary's).
    Although we do not have Client Push enabled for a variety of reasons, the properties have to be set for the manual push of the client from the console.  Once we re-entered the command line options for the Push install properties, manual installation
    from the console is working as expected.

  • Dynamic load applet from File or MSSQL trigger

    Hi,
    i have an interesting project that i am researching, i would greatly appreciate if someone can point out some tools to use inorder to reach the following scenario with java.
    I seeking to write data to a web applet whenever an insertion is done to a database or a new file is written to one directory on the server.
    i need to display the information in the applet without refreshing any page.
    i am very new to java, but i found that it could be done in a couple of ways....
    1- Opening a channel between the applet and the server that uses HTTP request and response to load and update the applet without refreshing the page.
    2-Programming a servlet on the server that communicates with the server and the client applet, it send the applet data when ever an insertion is done on the server.
    3-Doing an applet that gets data from a cookie text file on the client machine, using an open channel between the server an the client the server writes these data to a certain directory on the client.
    Please advice if any of these relates to the real world, and please provide tips of tools to do that.
    Greatly appreciated,
    Wafic

    OK, lets see how to accomplish that... :-)
    1- Opening a channel between the applet and the server
    that uses HTTP request and response to load and update
    the applet without refreshing the page.The idea of reloading the applet is not effective and leads to extreme performance losses.
    But you can use a URLConnection to send requests and retrieve any data on that channel.
    2-Programming a servlet on the server that
    communicates with the server and the client applet, it
    send the applet data when ever an insertion is done on
    the server.Here is the tricky part.
    To notify the applet you will have to set up some sort of server, as it does not know anything about operations on the web server side.
    So you either set up a socket connection to the server or (better) use remote method invocation (RMI) to let the server call the appropriate method and immediately send the data.
    This could be methods like (abstracted):
    myApplet.getData(String fileData);
    or
    myApplet.notifyMe(); //triggers the HTTP request to                get the data
    This is also not so easy as you will have to start a RMI registry inside the applet.
    3-Doing an applet that gets data from a cookie text
    file on the client machine, using an open channel
    between the server an the client the server writes
    these data to a certain directory on the client.This is the part I do not understand.
    Why are you sending a text file from the client to the server, which in turn should write the same file back in a client directory ?
    Why not using the applet for that ?
    Under any circumstances you will have to circumvent the applets security rectrictions on the client side by either signing it or deploying a policy file depending on the JAVA platform version you will be using.
    I hope this helps any further.
    Oliver

  • Singleton registry

    I was going through Bruce Eckel's Thinking In Patterns and was not too sure as to what was required in an exercise question
    "Create a registry/lookup service that accepts a Java interface and produces a reference to an object that implements that interface."
    Is the question asking for an interface to be passed into a registry method as a parameter, then have the registry return a reference to an instance that implements the interface?
    I went with this interpretation and tried to come up with something but I don't think the solution fulfills the requirement.
    Does anyone have any ideas for this?

    You would basically be implementing a Factory and Registry. My guess is that you would pass in an interface (or simply the class of an interface) and then use getClass().getName() to look up the interface in a Map (the Registry, could be a Singleton as well). The Factory part would be choosing a particular implementor to return.
    - Saish

  • RMI server invocation delay

    Hello, I have a problem with server invocations. If I call the method that just prints to the console toString of passed MyClass instance, it takes 4.5 seconds.
    If I pass String or null it works less than 10ms.
    This problem appears only at the special environment.
    Server should be at the Linux and client at the Windows.
    The Client is an applet. This applet should be loaded from the Linux server.
    But I have some Win computers that doesn't have this problem though they all are with XP and IE6.
    Combinations like Linux-Linux, Windows-Linux, Windows-Windows work normal.
    Besides if I even start this client from my IDE or just from my file system it works fast.
    I can't even detect conditions which enough to reproduce this problem.
    Here is my code:
    TestServerIntf.java
    public interface TestServerIntf extends Remote {
        void printMe(MyClass myClass) throws RemoteException;
    }TestServer.java
    public class TestServer implements TestServerIntf {
        public static void main(String[] args) {
            try {
                TestServerIntf engine = new TestServer();
                TestServerIntf stub =
                       (TestServerIntf) UnicastRemoteObject.exportObject(engine, 0);
                Registry registry = LocateRegistry.createRegistry(1099);
                registry.rebind("TestServer", stub);
                System.out.println("TestServer server bound");
            } catch (Exception e) {
                System.out.println("TestServer server exception:" + e.getMessage());
        public void printMe(MyClass myClass) throws RemoteException {
            System.out.println(myClass);
    }TestClient.java
    public class TestClient extends JApplet {
        private String host = "SERVER_HOST"; // specify here right host name
        private TestServerIntf server;
        public void init() {
            try {
                SwingUtilities.invokeAndWait(new Runnable() {
                    public void run() {
                        createGUI();
            } catch (Exception e) {
                e.printStackTrace(); 
        private void createGUI() {
            try {
                Registry registry = LocateRegistry.getRegistry(host);
                server = (TestServerIntf) registry.lookup("TestServer");
            } catch (RemoteException e) {
                 e.printStackTrace(); 
            } catch (NotBoundException e) {
                 e.printStackTrace(); 
            final JLabel label = new JLabel();
            getContentPane().add(label, BorderLayout.CENTER);
            try {
                MyClass myClass = new MyClass();
                long t = System.currentTimeMillis();
                server.printMe(myClass);
                label.setText("PrintMe " + (System.currentTimeMillis() - t) + "ms!");
            } catch (RemoteException e1) {
                 e1.printStackTrace(); 
    }MyClass.java
    public class MyClass implements Serializable {
    }Besides if change the signature to "void printMe(Object object)" and pass "new MyClass[]{myClass}" than it takes 9 seconds! But "new MyClass[]{myClass1, myClass2}" takes also a 9 seconds.
    I don't hope that you can reproduce this problem, but may be you have any ideas what is this problem connected with.
    Please help.

    Java does a reverse DNS lookup when you provide an IP address so DNS does come into it. I would say DNS is almost certainly the cause of the delay.

  • RMI client running from different machine giving error

    HI all
    I am trying to run the sample application getStart hello world.
    I am able to run the java applet from the same machine ....
    but i am get error when i am trying run client applet from the different machine .
    (HelloApplet exception: access denied (java.net.SocketPermission)
    client applet on machine1 and server and registory on machine2 in same lan .
    i copied the Helloapplet.class and Helloclient.html to machine1.
    appletviewer Helloclient.html
    but the java version is different in both machines.......
    can any one give some idea ....
    the errror i am geting is :
    HelloApplet exception: access denied (java.net.SocketPermission Neind-ws-003 res
    olve)
    java.security.AccessControlException: access denied (java.net.SocketPermission N
    eind-ws-003 resolve)
    at java.security.AccessControlContext.checkPermission(AccessControlConte
    xt.java:272)
    at java.security.AccessController.checkPermission(AccessController.java:
    399)
    at java.lang.SecurityManager.checkPermission(SecurityManager.java:545)
    at java.lang.SecurityManager.checkConnect(SecurityManager.java:1042)
    at java.net.InetAddress.getAllByName0(InetAddress.java:559)
    at java.net.InetAddress.getAllByName0(InetAddress.java:540)
    at java.net.InetAddress.getByName(InetAddress.java:449)
    at java.net.Socket.<init>(Socket.java:100)
    at sun.rmi.transport.proxy.RMIDirectSocketFactory.createSocket(RMIDirect
    SocketFactory.java:25)
    at sun.rmi.transport.proxy.RMIMasterSocketFactory.createSocket(RMIMaster
    SocketFactory.java:120)
    at sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEndpoint.java:499)
    at sun.rmi.transport.tcp.TCPChannel.createConnection(TCPChannel.java:190
    at sun.rmi.transport.tcp.TCPChannel.newConnection(TCPChannel.java:174)
    at sun.rmi.server.UnicastRef.newCall(UnicastRef.java:318)
    at sun.rmi.registry.RegistryImpl_Stub.lookup(Unknown Source)
    at java.rmi.Naming.lookup(Naming.java:84)
    at examples.hello.HelloApplet.init(HelloApplet.java:23)
    at sun.applet.AppletPanel.run(AppletPanel.java:344)
    at java.lang.Thread.run(Thread.java:484)
    The helloapplet.java code is :
    package examples.hello;
    import java.applet.Applet;
    import java.awt.Graphics;
    import java.rmi.Naming;
    import java.rmi.RemoteException;
    public class HelloApplet extends Applet {
    String message = "blank";
    // "obj" is the identifier that we'll use to refer
    // to the remote object that implements the "Hello"
    // interface
    Hello obj = null;
    public void init() {
         try {
              System.out.println("Path looking: " +getCodeBase().getHost());
         //obj = (Hello)Naming.lookup("//" +
              //     getCodeBase().getHost() + "/HelloServer");
                   obj = (Hello)Naming.lookup("//Neind-ws-003/HelloServer");
         message = obj.sayHello();
         } catch (Exception e) {
         System.out.println("HelloApplet exception: " +
                        e.getMessage());
         e.printStackTrace();
    public void paint(Graphics g) {
         g.drawString(message, 25, 50);
    The helloclient.html code:
    <HTML>
    <title>Hello World</title>
    <center> <h1>Hello World</h1> </center>
    The message from the HelloServer is:
    <p>
    <applet
              code="examples.hello.HelloApplet"
    width=500 height=120>
    </applet>
    </HTML>

    Your problem is at the following line.
    obj = (Hello)Naming.lookup("//Neind-ws-003/HelloServer");
    The line you had commented beforehand is
    //obj = (Hello)Naming.lookup("//" +
    // getCodeBase().getHost() + "/HelloServer");
    This worked because the applet was being retreived from the same server where the RMI server exists.
    Remember, applets can only connect themselfs to the same host they are stored in and retreived from. This is because of VM, the sandbox does not allow you to connect to other machines other than the server where it resides on. If you use a applet viewer it might work if you loosen the security features. On a browser i do not belive it can be done. Maybe if you modify your security options for the VM you are able to achieve something, but personally i'm going for the "It cannot be done " answer because of what I said before.
    Hope this helps
    If any trouble then reply and I'll answer later.
    Rui P.

  • Beginners problems

    Hello!
    I am a computer science student and I am doing my "special work" with JBuilder8SE and as I am trying to learn RMI and the use of JBuilder, I tried to do the example "Getting Started Using RMI" from the JBuilder Help. I have written all the code etc just as they are in the exaple, but I cannot get my source files compiled. Hello.java compiles just fine, but HelloApplet.java and HelloImpl.java files woun't compile. I get three error messages.
    "HelloImpl.java": Error #: 300: class Hello not found in class examples.hello.HelloImpl at line 8 column 63
    "HelloApplet.java": Error #: 300: class Hello not found in class examples.hello.HelloApplet at line 14 column 3
    "HelloApplet.java": Error #: 300: class Hello not found in class examples.hello.HelloApplet at line 18 column 14
    I tried to mend this error by putting the package name in front of the Hello reference (examples.hello.Hello) but as one can guess, I had another compiler error message:
    "HelloApplet.java": Error #: 302: cannot access class examples.hello.Hello; java.io.IOException: class not found: class examples.hello.Hello at line 14, column 18
    I really don't know what's wrong 'cause I've done everything as it's required in the example. Can you help me please? Give me some suggestions what to do next. How can I write a program of my own if I can't even do the easiest examples?
    I hope some one answers me. (And if am in totally wrong place, please tell me where to go for help)

    Hi ChrisBoy!
    Yes, all my code is in the same package "examples.hello". Here's the code: (it's should be exactly the same as in JBuilder Help)
    Hello.java:
    package examples.hello;
    import java.rmi.Remote;
    import java.rmi.RemoteException;
    public interface Hello extends Remote {
    String sayHello() throws RemoteException;
    HelloApplet.java:
    package examples.hello;
    import java.applet.Applet;
    import java.awt.Graphics;
    import java.rmi.Naming;
    import java.rmi.RemoteException;
    public class HelloApplet extends Applet {
    String message = "blank";
    // "obj" on tunniste, jota k�ytet��n viittaamaan et�olioon,
    // joka toteuttaa "Hello" rajapinnan
    examples.hello.Hello obj = null;
    public void init() {
    try{
    obj = (examples.hello.Hello)Naming.lookup("//" + getCodeBase().getHost() + "/HelloServer");
    message = obj.sayHello();
    } catch (Exception e) {
    System.out.println("HelloApplet exception: " + e.getMessage());
    e.printStackTrace();
    public void paint(Graphics g) {
    g.drawString(message, 25, 50);
    HelloImpl.java:
    package examples.hello;
    import java.rmi.Naming;
    import java.rmi.RemoteException;
    import java.rmi.RMISecurityManager;
    import java.rmi.server.UnicastRemoteObject;
    public class HelloImpl extends UnicastRemoteObject implements examples.hello.Hello {
    public HelloImpl() throws RemoteException {
    super();
    public String sayHello() {
    return "Hellou vaan maailma!";
    public static void main(String args[]) {
    //luo ja aseta security manager
    if (System.getSecurityManager() == null) {
    System.setSecurityManager(new RMISecurityManager());
    try {
    HelloImpl obj = new HelloImpl();
    // kiinnit� t�m� olioesiintym� nimeen HelloServer
    Naming.rebind("//myhost/HelloServer", obj);
    System.out.println("HelloServer bound in registry");
    } catch (Exception e) {
    System.out.println("HelloImpl err: " + e.getMessage());
    e.printStackTrace();

Maybe you are looking for

  • App-V 5 Full Infrastructure Apps take long time to stream to the client

    Hi was wondering if anyone has the same issue as i am or knows a fix for this, below is my problem and the troubleshooting i have done. Overview of problem App-V 5 apps delivered via App-V 5 full infrastructure take a long time to stream to the clien

  • Supplimentary invoice in case of Depot Sale

    Hi, During Depot Sales in Indian scenario. After doing MIGO I am capturing the Excise invoice at depot through J1IG. In case if the Product is being sold at the same price, after the PGI in depot I am choosing the excise invoice through J1IJ. I need

  • Developer 6.0 installation failure

    Hi, I have Orace 8i 8.1.6 up and running on a NT machine and am trying to install Developer Forms 6.0 Server. I tried to install it on a separate directory C:\Oradev6, and still got messages saying that Forms cannot be installed in multiple location,

  • Revaluation accounting not getting posted

    when we are doing a revulation entry regarding assets everything is going fine but no accounting entry is being posted. system doesnot generates any error also

  • Pls anybody tel me what is self life / ageing report in mm

    hi all,               i have to develop self life ageing report.              pls anybody tel me what is self life / ageing report in mm.              pls send me template and code. regards vikas