Can't kill remote objects!

OK, from what i've read and seen, there are 4 things that must happen in order to successfully release a server-side remote object and have it garbage-collected:
1) The server must call unexportObject
2) The client must release all references (stubs) to the remote object;
3) The server must release all local references to the original object
4) Wait for outstanding leases to expire
My application is doing 1, 2 and 3 - but 4 never happens because for some unknown reason the client continues [unnecessarily] to renew the leases!!!!
I'm convinced this Is a bug! I know for a fact that 1 is happening - the client's reference becomes invalid. I have confirmed 2 and 3 using a heap analysis tool.
If i forcibly terminate the client, the leases DO eventually expire, but I need a slightly more elegant solution than this.
What could possibly be causing the persistent renewal of leases on unused objects? What can I look for on the Client side [or Server side]?
Perhaps it is possible to simulate a clean() call somehow, but most of the classes required to do so are not 'public'.
Over time, this problem is causing memory issues and VERY poor performance. Help!!!

Thanks, but these objects are not bound to the registry.
However, that raises an excellent point. For anyone else watching this topic, step 1.5 would be to call Registry.unbind() if the object was previously boud using bind() or rebind(). Otherwise, the RMI runtime would be holding on to a strong reference to the instance.

Similar Messages

  • I can't use remote object in Flex to save an image to the server.

    I have a situation where I can't use remote object in Flex to save an image to the server.
    Could someone help me with an alterntaive?
    private function doSave():void {
                    var bd:BitmapData = new BitmapData(canvas.width,canvas.height);
                    var pe:PNGEncoder = new PNGEncoder;
                    bd.draw(canvas);
                    var ba:ByteArray = pe.encode(bd);
                    myService.doUpload(ba,sIP);
        <cffunction name="doUpload" displayname="Save Signature" hint="Saves a PNG Signature" access="remote" output="false" returntype="any">
            <cfargument name="sigbytes" required="true" type="binary">
            <cfargument name="ip_suffix" required="true" type="string">
            <cfset myUUID =  RandomString('ABCDEFGHIJKLMNOPQRSTUVWXYZ',15)>
            <cfset name = expandPath("converted_pngs/signature_#arguments.ip_suffix#_#myUUID#.png")>
            <cffile action="write" file="#name#" output="#arguments.sigbytes#" />
        <cfset SigFileName = "#arguments.ip_suffix#_#myUUID#">
            <cfreturn SigFileName />
        </cffunction>

    Try assigning binary arg to <cfimage/> then save.

  • Can't update remote object (RMI)

    I have made a class "A" that implements a remote interface "RI". I then rebind it to the rmiregistry:
    RI bob = new A();
    Naming.rebind("bob",bob);Class A has a few methods that I call that changes som private fields.
    After some time I start another class B that makes a look up:
    RI found  = (RI)Naming.lookup("//localhost/bob");But the private fields have not been changed in this looked up object.
    Is it necessary to call rebind each time I make a change to a remote object??

    If you'd stick to the same thread instead of starting a new one all over the place you'd find that I've already answered this question three days ago: http://forum.java.sun.com/thread.jspa?threadID=770735&messageID=4393030#4393030
    Can you stick to that thread please.

  • DBMS_SQL.PARSE to access remote objects

    I am using following code in a procedure ...
    DBMS_SQL.PARSE (cur, vSQL, DBMS_SQL.NATIVE);
    where variable vSQL can contain a remote object.
    A DB link (with Fixed User option) exists to access that database.
    The DB link is working. The remote object is accessible outside this procedure.
    When this command is executed, I get ...
    ORA-24374: define not done before fetch or execute and fetch
    ... error.
    Can DBMS_SQL handle remote objects?
    Oracle version is 9.2.0.5.0
    Any help would be greatly appreciated.

    Here is the code I am running ...
    CREATE OR REPLACE PROCEDURE p_sql_valid_or_not_cnt
    (vSQL IN VARCHAR2, vValid OUT NUMBER, vMessage OUT VARCHAR2, vCount OUT NUMBER) IS
    -- Purpose: Returns 0 in vvalid if SQL is valid, else returns -1. Returns row count when SQL is valid.
    -- Parameters:
    -- IN : vSQL
    -- OUT : vValid
    -- OUT : vMessage
    -- OUT : vCount
    cur INTEGER := DBMS_SQL.OPEN_CURSOR;
    fdbk INTEGER;
    BEGIN
    DBMS_SQL.PARSE (cur, vSQL, DBMS_SQL.NATIVE);
    fdbk := DBMS_SQL.EXECUTE (cur);
    vCount := 0;
    LOOP /* Fetch next row. Exit when done. */
    EXIT WHEN DBMS_SQL.FETCH_ROWS (cur) = 0;
    vCount := vCount + 1;
    END LOOP;
    vValid := 0;
    vMessage := 'No errors';
    DBMS_SQL.CLOSE_CURSOR (cur);
    END p_sql_valid_or_not_cnt;
    To run ...
    set serveroutput on
    declare
    i number;
    m varchar2(500);
    c number;
    begin
    p_sql_valid_or_not_cnt('SELECT * FROM TAB where 1 <> 1',i,m,c);
    DBMS_OUTPUT.PUT_LINE(i);
    DBMS_OUTPUT.PUT_LINE(m);
    DBMS_OUTPUT.PUT_LINE(c);
    end;
    This runs fine.
    But when I try to access an object from a remote server using DB link. I get the error ...
    set serveroutput on
    declare
    i number;
    m varchar2(500);
    c number;
    begin
    p_sql_valid_or_not_cnt('SELECT * FROM REMOTE_SCHEMA.T_REMOTE@REMOTE_SERVER where 1 <> 1',i,m,c);
    DBMS_OUTPUT.PUT_LINE(i);
    DBMS_OUTPUT.PUT_LINE(m);
    DBMS_OUTPUT.PUT_LINE(c);
    end;
    declare
    ERROR at line 1:
    ORA-24374: define not done before fetch or execute and fetch
    ORA-06512: at "SYS.DBMS_SYS_SQL", line 1125
    ORA-06512: at "SYS.DBMS_SQL", line 328
    ORA-06512: at "IMEPAS.P_SQL_VALID_OR_NOT_CNT", line 16
    ORA-06512: at line 6
    I can run the SQL that I am passing as vSQL directly in SQLPLUS ...
    This code in itself works.
    SELECT * FROM
    REMOTE_SCHEMA.T_REMOTE@REMOTE_SERVER
    where 1 <> 1;
    The user I am using to logon to my server is also there on REMOTE_SERVER.
    The DB LINK is created by CONNECTED USER option. The user on REMOTE_SERVER has explict select access on the table (not via role) I am accessing.
    Any help would be much appreciated.

  • Is the Remote Object always a singleton?

    Hi,
    Using .Net Remoting we can export a Remote Objects in three different ways:
    1. Singleton: Same instance of a Server-side object is used by all the clients for all the requests.
    2. SingleCall: Whenever a new call is received, a new instance of the Server-side object is created and reference is passed to the client. Therefore, for each call to the server, the client gets a new instance of the object.
    3. Client Activation: In this, the Client requests to the server for creating a new instance which can be used for multiple calls. The instance activated by a client is not used by other clients. Client-Activated objects can store state information between method calls for its specific client.
    Do we have this options in RMI or the Remote Object must always be a Singleton?
    What I'm looking for is a way to create one instance of the Remote Object (in the server side) to each client that connects to a server.
    thx

    Do we have this options in RMI1 and 3 are available. 2 is not.
    or the Remote Object must always be a Singleton?No.
    What I'm looking for is a way to create one instance of the Remote Object (in the server side) to each client that connects to a server.It's as simple as 'return new MyRemoteObject(...);'.
    For example:
    public interface Login extends Remote
      public Session login(String username, ...) throws RemoteException;
    public interface Session extends Remote
      // your client API here
    public class LoginImpl extends UnicastRemoteObject implements Login
      public Session login(String username, ...) throws RemoteException
        // validate username etc. If OK return a session.
        return new SessionImpl();
    public class SessionImpl extends UnicastRemoteObject implements Session
      // your client API implementation here, also all the server-side state belonging to that client session
    }Note that this is as secure as the login() method. By type safety, nobody can execute Session methods until they have logged in.
    I'm deleting your two other threads.

  • Can we cache the remote object?

    hi,
    can we cache the remote object?
    is this right way of doing?
    please suggest me
    regards
    crr

    Yes, caching EJBHome, EJBObject, and Remote business references is fine. They can also
    be portably stored in an HttpSession. However, when caching in the web tier you must still
    be careful to prevent concurrent access to the same stateful session bean. The fact that
    remote references to stateful session beans can be cached does not guarantee they can
    be accessed by more than one client at a time.
    --ken                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • Can I cache the Remote object

    I am using Stateless session bean. Can I cache the reference of the remote objects to this bean ?
    I read that some containers support the fearture of pre creating the EJB objects in the pool , during startup
    using some custom configuration ( like connection pool ). How is this performed ?`

    I am using Stateless session bean. Can I cache the
    reference of the remote objects to this bean ?No, but you can cache the HomeHandle of the Home interface references - that saves you the overhead of JNDI lookups, which are far more "expensive" time-wise than calling the create method to get the Remote implemenation.
    I read that some containers support the fearture of
    pre creating the EJB objects in the pool , during
    startup using some custom configuration ( like connection pool
    ). How is this performed ?Ask your vendor - it's vendor-specific.

  • Can't load all properties of a remote object

    Hi,
    I have a java class called
    Employe which has a field of type
    Group(an java class)
    when i get the Employe Object in flex using remote Object and
    try to access Group's properties like
    employe.goup.name, i get:
    "Error #1009: Cannot access a property or method of a null
    object reference".
    Can some one please help me! Thank you.

    Please check your Node Object, I mean all Objects that you are going to save is serialized or not.

  • Can a remote service return a remote object?

    Hi all,
    please consider a business logic for a typical forum service :
    public interface ForumManager extends Remote
    Forum createNewForum(String Name);
    Forum getForum(String Name);
    public interface Forum extends Remote
    void postNewArticle(String Title, String Content);
    Article [] getArticles();
    public class Article implements Serializable
    There are two interfaces of remote objects: ForumManager and Forum, both of two interfaces are extended from interface Remote. I created two classes implementing these interfaces respectively, and created two stub classes from the implementation with rmic.
    As the logic, a ForumManager creates and manages forums on the server. A client can retrieve a remote stub of a forum instance from the manager stub, and post articles to the forum stub. The forum stub then sends the new articles to the real ForumImpl on the server, and the real implementation of Forum on the server then save the articles into disks or DBs. So, you can see, the most important thing is that clients have to be able to get the stub of a forum.
    Codes in createForum() of the implementation class of ForumManager is like this:
    ForumImpl TheNewForum = new ForumImpl(this.getRef());
    // ^ Because ForumImpl is a remote object, without a ref, it can not be marshaled.
    ForumTable.put(Name, TheNewForum);
    return TheNewForum;
    The problem is, the Forum instance my client retrieved from FourmManagerImpl_Stub (gotten from Naming.lookup()) is a ForumImpl, but not a Forum_Stub. So that articles posted to the forum will not be sent to the server, and different clients can not share articles with each other. I found a bunch of documents about RMI, but they did not illustrated how to retrieve a stub of a remote object from another remote object (like a manager). If you know how to cope this problem, please tell me.
    Edited by: DBPZ on Apr 2, 2008 3:33 AM

    why does this base class exist?It's really only there to support stubs. The only thing it gives you over Object is the remote equality semantics, and only stubs need that. (It also provides the RemoteReference but only RMI needs that, internally, you don't.)
    When should we use RemoteObject instead of UnicastRemoteObject?Never, but if you do, or you use Object (or indeed anything other than UnicastRemoteObject and Activatable), you have to export it yourself as indicated above.

  • Can't access remote java object

    I'm using Flex Builder 3 plug-in and trying to build a simple
    demo app that uses JDBC to return results to a datagrid.
    However, I getting the following error message:
    "[MessagingError message='Destination 'enrollmentService'
    either does not exist or the destination has no channels defined
    (and the application does not define any default channels.)']"
    faultCode="InvokeFailed" faultDetail="Couldn't establish a
    connection to 'enrollmentService'"]
    I have the enrollService.class deployed under WEB-INF/classes
    of the blazeds webapp under Tomcat. (Just not sure exactly where to
    put it.) Also in my project in Flex builder I created a
    WEB-INF/classes under WebContent and put the class there as well.
    I've attached both my remoting-config.xml and my apps .mxml
    files
    I'm pulling my hair out trying to figure out what needs to go
    where in order my remote object to be available. Any help would be
    much much appreciated.

    Just use event.target which will return the doc object.
    see sample code below
    var doc = event.target;
    doc.print();
    doc.saveAs();
    doc.closeDoc();
    Nith

  • How to shutdown an application remote object in lcds

    I've got an application configured remote object that manages a couple of threads inside lcds.  When I go to shutdown lcds I get this
    SEVERE: The web application [/wrcastle] appears to have started a thread named [Thread-5] but has failed to stop it. This is very likely to create a memory leak.
    the tasks aren't shutting down and I've got catches for handling the thread.interrupt() should proprogate down.
    How do I cleanly shutdown my tasks?
    TIA
    chuckles

    Look at registering your own BootstrapService (See docs here).  You can do anything you want in such a service (not just register runtime destinations) and the stop() method will get called when the MessageBroker servlet stop() method is called.  You could then kill your threads here.
    You could just ignore the messages from tomcat.  If you are shutting down the VM, there will be no memory leak.
    Tom

  • Remote object trying to return another remote object and a ClassCastExcepti

    I have a server running with a TreeModel (the tree model implements Remote). I also have the the TreeNodes all linked together on the server. Now, I can get to the TreeModel on the server and the root node of the remote tree model.
    treeModelStub = (treeModelIface)Naming.lookup(url+"remoteTM"); //works
    rootStub = (remoteTreeNodeIface)treeModelStub.getRoot(); //works. The call to getRoot returns Object
    But when I call
    remoteTreeNodeIface aChild = (remoteTreeNodeIface)rootStub.getChildAt(index) //Does not work. "Exception in thread "main" java.lang.ClassCastException
    at remoteTreeNode_Stub.getChildAt(Unknown Source)
    The remote tree node method getChildAt returns TreeNode because the class implements TreeNode:
    public class remoteTreeNode extends UnicastRemoteObject implements rdcaDataIface, Comparable, TreeNode {
    public TreeNode getChildAt(int idx) {
    System.out.println("DEBUG: class is "+this.getClass()); // class is remoteTreeNode
    return (remoteTreeNode)children.get(idx);
    The remote interface is defined as:
    public interface rdcaDataIface extends java.rmi.Remote {
    public TreeNode getChildAt(int idx) throws RemoteException;
    Any ideas why this does not work. Why can a remote object of type Object be returned just fine, but a TreeNode not be returned?
    Thank you for your help,
    Brent

    I have a server running with a TreeModel (the tree
    model implements Remote). I also have the the
    TreeNodes all linked together on the server. Now, I
    can get to the TreeModel on the server and the root
    node of the remote tree model.
    treeModelStub =
    (treeModelIface)Naming.lookup(url+"remoteTM");
    //works
    rootStub =
    (remoteTreeNodeIface)treeModelStub.getRoot();
    //works. The call to getRoot returns Object
    But when I call
    remoteTreeNodeIface aChild =
    (remoteTreeNodeIface)rootStub.getChildAt(index)******************************************
    can only be casted to rdcaDataIface. The returned object is an instanceof the rdcaDataIface_stub, which have nothing to do with TreeNode.
    //Does not work. "Exception in thread "main"
    java.lang.ClassCastException
    at remoteTreeNode_Stub.getChildAt(Unknown
    t(Unknown Source)
    The remote tree node method getChildAt returns
    TreeNode because the class implements TreeNode:
    public class remoteTreeNode extends
    UnicastRemoteObject implements rdcaDataIface,
    Comparable, TreeNode {
    public TreeNode getChildAt(int idx) {
    System.out.println("DEBUG: class is
    lass is "+this.getClass()); // class is
    remoteTreeNode
    return (remoteTreeNode)children.get(idx);
    The remote interface is defined as:
    public interface rdcaDataIface extends java.rmi.Remote
    public TreeNode getChildAt(int idx) throws
    ows RemoteException;
    Any ideas why this does not work. Why can a remote
    object of type Object be returned just fine, but a
    TreeNode not be returned?
    Thank you for your help,
    Brent

  • Remote Object - not able to get the returned value from java method

         Hi ,
    I am developing one sample flex aplication that connects to the java code and displays the returned value from the
    java method in flex client. Here I am able to invoke the java method but not able to collect the returned value.
    lastResult is giving null .  I am able to see the sysout messages in server console.
    I am using flex 3.2 and blazeds server  and java 1.5
    Here is the code what I have written.
    <?xml version="1.0" encoding="utf-8"?><mx:WindowedApplication  xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" backgroundColor="#FFFFFF" initialize="initApp()">
     <mx:Script><![CDATA[
    import mx.controls.Alert; 
    import mx.binding.utils.ChangeWatcher; 
    import mx.rpc.events.ResultEvent; 
    import mx.messaging.*; 
    import mx.messaging.channels.* 
    public function initApp():void { 
         var cs:ChannelSet = new ChannelSet(); 
         var customChannel:Channel = new AMFChannel("my-amf", "http://localhost:8400/blazeds/messagebroker/amf");     cs.addChannel(customChannel);
         remoteObj.channelSet = cs;
    public function writeToConsole():void {      remoteObj.writeToConsole(
    "hello from Flash client");
          var returnedVal:String = remoteObj.setName().lastResult;     Alert.show(returnedVal);
    //[Bindable] 
    // private var returnedVal:String; 
    ]]>
    </mx:Script>
    <mx:RemoteObject id="remoteObj" destination="sro" /> 
    <mx:Form width="437" height="281">
     <mx:FormItem>  
    </mx:FormItem>  
    <mx:Button label="Write To Server Console" click="writeToConsole()"/>
     </mx:Form>
     </mx:WindowedApplication>
    Java code
    public  
         public SimpleRemoteObject(){  
              super();     }
      class SimpleRemoteObject { 
         public void writeToConsole(String msg) {          System.out.println("SimpleRemoteObject.write: " + msg);     }
         public String setName(){          System.
    out.println("Name changed in Java"); 
              return "Name changed in Java";
    And I have configured destination in  remote-config.xml
    <destination id="sro">
       <properties>    
        <source>SimpleRemoteObject</source>
        <scope>application</scope>
       </properties>
      </destination>
    Please help me .

    You are not able to get the returned value because if you see the Remote object help you will realise you have to use result="resultfn()" and fault = "faultfn()"
    In this you define what you wish to do.
    More importantly in the remote object you need to define which method you wish to call using the method class like this
    <mx:RemoteObject id="remoteObj" destination="sro" result="r1" fault="f1"  >
         <Method name="javaMethodName" result="r2" fault="f2"/>
    <mx:RemoteObject>
    r2 is the function where you get the result back from java and can use it to send the alert.

  • Exporting two remote objects on the same port

    Hi,
    I would like to export two remote objects on the same host, same port and bind them with different service names.
    There is no problem when I do that from the same Java program.
    But when I export and bind an object from a Java program 1, I cannot do the same with the second (and similar) Java program 2. This is the stack trace of my Exception:
    java.rmi.server.ExportException: Port already in use: 50040; nested exception is:
         java.net.BindException: Address already in use: JVM_Bind
         at sun.rmi.transport.tcp.TCPTransport.listen(TCPTransport.java:243)
         at sun.rmi.transport.tcp.TCPTransport.exportObject(TCPTransport.java:178)
         at sun.rmi.transport.tcp.TCPEndpoint.exportObject(TCPEndpoint.java:382)
         at sun.rmi.transport.LiveRef.exportObject(LiveRef.java:116)
         at sun.rmi.server.UnicastServerRef.exportObject(UnicastServerRef.java:145)
         at sun.rmi.server.UnicastServerRef.exportObject(UnicastServerRef.java:129)
         at java.rmi.server.UnicastRemoteObject.exportObject(UnicastRemoteObject.java:275)
         at java.rmi.server.UnicastRemoteObject.exportObject(UnicastRemoteObject.java:178)
         at java.rmi.server.UnicastRemoteObject.<init>(UnicastRemoteObject.java:75)Can some one help please

    It should work in any version of Java as long as the server socket factories are null or equal according to Object.equals() or its override in the SSF.equals() method if any. Which needs to be present and needs to take the form:
    public boolean equals(Object object)
      return object != null && object.getClass() == this.getClass();
    }with further tests if the server socket factories have additional state.

  • Trying to create a local instance of the remote object

    Hi,
    I have a ClassA on which I need to be able to invoke RMI calls. Problem is the interface which ClassA implements does not throw exceptions. To get around this problem I have created a wrapper class ClassWrap which has a ClassA attribute and calls made to ClassWrap are directed to this ClassA object. A facade type design I think it's called.
    ClassWrap implements Remote so it can be used as a Remote object.
    When I create an instance of ClassWrap and deploy it on a server, my client has no problem communicating with the remote ClassWrap object via a remote stub ClassWrap_Stub.
    Problem is I also want my client to be able to use a local instance of ClassWrap. Whan I try to create an instance of ClassWrap in my client I get a remote Exception ... but !! when I have a ClassWrap_Stub object in my classpath then there is no problem creating a ClassWrap object.
    Any ideas why this happens?

    What you are trying to do should work just fine. Do you have the wrapper class file in your client jar?

Maybe you are looking for

  • Suspends fails the first time, but succeeds the second time

    Hi all, I am running Arch Linux on my Dell XPS 15 9530 laptop, and overall I am very happy with the combination. I have however had some issues with suspending. The problem is that the first time I try to suspend the machine it seems to go to sleep,

  • Grouping contacts based on filter

    I receive SMS alerts from work that are sent in the format: sms-[my name]+[random string]@workdomain.com Now, the "sms-[my name]" part of it is the same every time an SMS alert is sent, but the [random string] changes every time. It's about 15 charac

  • Refering text from Shipping doc to billing doc

    Hi dear Friends, how do I copy text from delivery to invoice in invoice the document of reference is always the sales order in structure REFERENZ there is only the order the problem is the same for VBBK and VBBP can you help me??? thank you very much

  • Why do I get an error message that says Firefox is inaccessible? I have MAc OS X

    Firefox worked yesterday. My Mac had a Safari update & I had to Restart the pc. Now I get an error message that says "Firefox may be missing or inaccessible".

  • Hyperlinks with red and blue bordersHi

    Hi, I have a HTML file with three jpg images. I created hyperlinks to websites for all 3 images. However, I get this blue and red border around the hyperlink when I preview it in my web browser. Not sure why this is happening.... Any help is apprecia