Return new remote object

Hi All!
Help me!
public interface Server extends Remote {
QueryServer I() throws RemoteException;
public class ServerImplementation extends UnicastRemoteObject implements Server {
public QueryServer I() throws RemoteException {
return new QueryServerImplementation();
public ServerImplementation() throws RemoteException {
super();
public interface QueryServer extends Remote {
String Y() throws RemoteException;
public class QueryServerImplementation extends UnicastRemoteObject implements QueryServer {
public String Y() throws RemoteException {
return "Hello";
public QueryServerImplementation() throws RemoteException {
super();
Server:
public static void main(String args[]) {
if (System.getSecurityManager() == null) {
System.setSecurityManager(new RMISecurityManager());
Registry registry = LocateRegistry.createRegistry();
ServerImplementation serverImpl = new ServerImplementation();
registry.bind("XXX", serverImpl);
Client:
public static void main(String args[]) {
if (System.getSecurityManager() == null) {
System.setSecurityManager(new RMISecurityManager());
server = (Server) Naming.lookup("XXX");
QueryServer qserver = server.I();
String s = qserver.Y();
Exception java.rmi.NoSuchObjectException
What is uncorrect????
Thank you!

Works for me in JDK 1.3.1. What JDK are you using? and how much time if any elapses between the various client lookups and remote calls?
In general RMI clients do have to be prepared to deal with NoSuchObjectExceptions. They simply mean that the stub is stale in the DGC sense and has to be reacquired. In your case the qserver stub must be reacquired by calling server.I(). If that throws NoSuchObjectException you must reacquire the server stub by repeating the lookup.

Similar Messages

  • 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.

  • 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

  • How to return new blob object?

    Hi,
    I am trying to find documentation on how to return a custom abstract data type (ADT) using the CREATE TYPE... and BLOB interface.
    How can I return a new object type defined inside a blob. Can I return a blob (without initializing the lob locator first)?
    Please advise.

    Hi,
    Please check the below link.
    http://docs.oracle.com/cd/E24693_01/appdev.11203/e17126/create_type.htm
    Regards,
    Sailaja

  • 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.

  • [svn:bz-trunk] 5137: Fix failing security tests on BlazeDS/ trunk by using a remote object to invalidate the FlexSession at the end of each test method which should cause each test method to run with a new /clean session.

    Revision: 5137
    Author: [email protected]
    Date: 2009-03-02 10:28:59 -0800 (Mon, 02 Mar 2009)
    Log Message:
    Fix failing security tests on BlazeDS/trunk by using a remote object to invalidate the FlexSession at the end of each test method which should cause each test method to run with a new/clean session. It looks like some test methods were leaving some things in a bad state which was causing the next test that ran to fail. These may be legitimate bugs/issues so we should investigate further to see what sequence of events gets things into a bad state but for these tests we want all of the test methods to run in isolation.
    Modified Paths:
    blazeds/trunk/qa/apps/qa-manual/WEB-INF/flex/services-config.mods.xml
    blazeds/trunk/qa/apps/qa-regress/WEB-INF/flex/remoting-config.mods.xml
    blazeds/trunk/qa/apps/qa-regress/testsuites/mxunit/tests/messagingService/security/stream ing-amf/JMSAuthSendSubscribeConstraintTest.mxml
    blazeds/trunk/qa/apps/qa-regress/testsuites/mxunit/tests/messagingService/security/stream ing-amf/MessagingAuthProSendTest.mxml
    blazeds/trunk/qa/apps/qa-regress/testsuites/mxunit/tests/messagingService/security/stream ing-http/JMSAuthSendSubscribeConstraintTest.mxml
    blazeds/trunk/qa/apps/qa-regress/testsuites/mxunit/tests/messagingService/security/stream ing-http/MessagingAuthProSendTest.mxml
    Added Paths:
    blazeds/trunk/qa/apps/qa-regress/WEB-INF/src/qa/messaging/SessionManager.java

    In general theory, one now has the Edit button for their posts, until someone/anyone Replies to it. I've had Edit available for weeks, as opposed to the old forum's ~ 30 mins.
    That, however, is in theory. I've posted, and immediately seen something that needed editing, only to find NO Replies, yet the Edit button is no longer available, only seconds later. Still, in that same thread, I'd have the Edit button from older posts, to which there had also been no Replies even after several days/weeks. Found one that had to be over a month old, and Edit was still there.
    Do not know the why/how of this behavior. At first, I thought that maybe there WAS a Reply, that "ate" my Edit button, but had not Refreshed on my screen. Refresh still showed no Replies, just no Edit either. In those cases, I just Reply and mention the [Edit].
    Also, it seems that the buttons get very scrambled at times, and Refresh does not always clear that up. I end up clicking where I "think" the right button should be and hope for the best. Seems that when the buttons do bunch up they can appear at random around the page, often three atop one another, and maybe one way the heck out in left-field.
    While I'm on a role, it would be nice to be able to switch between Flattened and Threaded Views on the fly. Each has a use, and having to go to Options and then come back down to the thread is a very slow process. Jive is probably incapable of this, but I can dream.
    Hunt

  • I have a production mobile Flex app that uses RemoteObject calls for all data access, and it's working well, except for a new remote call I just added that only fails when running with a release build.  The same call works fine when running on the device

    I have a production mobile Flex app that uses RemoteObject calls for all data access, and it's working well, except for a new remote call I just added that only fails when running with a release build. The same call works fine when running on the device (iPhone) using debug build. When running with a release build, the result handler is never called (nor is the fault handler called). Viewing the BlazeDS logs in debug mode, the call is received and send back with data. I've narrowed it down to what seems to be a data size issue.
    I have targeted one specific data call that returns in the String value a string length of 44kb, which fails in the release build (result or fault handler never called), but the result handler is called as expected in debug build. When I do not populate the String value (in server side Java code) on the object (just set it empty string), the result handler is then called, and the object is returned (release build).
    The custom object being returned in the call is a very a simple object, with getters/setters for simple types boolean, int, String, and one org.23c.dom.Document type. This same object type is used on other other RemoteObject calls (different data) and works fine (release and debug builds). I originally was returning as a Document, but, just to make sure this wasn't the problem, changed the value to be returned to a String, just to rule out XML/Dom issues in serialization.
    I don't understand 1) why the release build vs. debug build behavior is different for a RemoteObject call, 2) why the calls work in debug build when sending over a somewhat large (but, not unreasonable) amount of data in a String object, but not in release build.
    I have't tried to find out exactly where the failure point in size is, but, not sure that's even relevant, since 44kb isn't an unreasonable size to expect.
    By turning on the Debug mode in BlazeDS, I can see the object and it's attributes being serialized and everything looks good there. The calls are received and processed appropriately in BlazeDS for both debug and release build testing.
    Anyone have an idea on other things to try to debug/resolve this?
    Platform testing is BlazeDS 4, Flashbuilder 4.7, Websphere 8 server, iPhone (iOS 7.1.2). Tried using multiple Flex SDK's 4.12 to the latest 4.13, with no change in behavior.
    Thanks!

    After a week's worth of debugging, I found the issue.
    The Java type returned from the call was defined as ArrayList.  Changing it to List resolved the problem.
    I'm not sure why ArrayList isn't a valid return type, I've been looking at the Adobe docs, and still can't see why this isn't valid.  And, why it works in Debug mode and not in Release build is even stranger.  Maybe someone can shed some light on the logic here to me.

  • File upload through BlazeDS remote object?

    Hi,
    After researching file upload options in flex, it seems like the only option is through HTTP service requests, such as:
    private var fileRef:FileReference;
    fileRef.upload(new URLRequest(FILE_UPLOAD_URL));
    Is there any way to use BlazeDS remote objects to upload a file from Flex interface? Perhaps passing in a FileReference object and marshalling it into an equivalent Java object?
    Thanks!

    I know there is a workaround like this. It uses a servlet to upload a file and returns a url. The uploaded file is either stored in session or server file system until the session expires. Use the PropertyProxy to register a custom class which contains this url and convert to java.io.File. It is the limitation of the player. It cannot read the local file system for security reason. There is a sample in blazeds/trunk/qa/apps/qa-regress/WEB-INF/src/blazeds/qa/remotingService/Echo.java
    static
    PropertyProxyRegistry registry = PropertyProxyRegistry.getRegistry();
    PropertyProxy proxy = registry.getProxy(java.io.File.class);
    if (proxy == null)
    registry.register(java.io.File.class, new FileProxy());
    proxy = registry.getProxy(FileReference.class);
    if (proxy == null)
    registry.register(FileReference.class, new FileReferenceProxy());
    Hope it can help

  • Do I have to use lookup() to get a reference of remote object?

    Hello,
    I appreciate the help from you guys in advance. My question is, do I have to use lookup() to get the reference to a remote object? Right now I want to pass the remote object itself which can be serialized via stream. I am not sure if this way works.
    Cheers!
    Steve

    some part code:
    client:
    lookup=UC_LookUp.StkTakeListingHdrLookup().getStkTake(usrInfo,tfStkTakeListNo.getText());
    UC_LookUp
    public static basewms.uc.interfaces.UC_ISCSStkTakeListingHdr_Remote StkTakeListingHdrLookup()
          if (look_up==null) look_up= new UC_LookUp();
          if(stktakelistinghdr == null)
          stktakelistinghdr = look_up.startLookUp("UCStkTakeListingHdr","192.168.10.98", 7000);
          while (stktakelistinghdr==null)
               try { Thread.sleep(1000); }catch(InterruptedException e) {}
          return (basewms.uc.interfaces.UC_ISCSStkTakeListingHdr_Remote)look_up.getRemote(stktakelistinghdr);

  • 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.

  • Amfphp - flex remote object error event handler

    I'm using amfphp and I want it to return an error that the flex remote object error event handler will pick up. At the moment I can get only the result handler to do anything in flex.

    Hi,
    Try throwing an exception in the remote method. For example,
    function inverse($x) {
        if (!$x) {
            throw new Exception('Division by zero.');
        else return 1/$x;

  • Best Practices for many Remote Objects?

    Large Object Model doing JDBC over RMI
    Please read the following and provide suggestions for a recommended approach or literature that covers this area well?
    N-Tiered Architecture
    JSP/Servlet (MVC) - Database Access Layer - Database
    Applets - JSp/Servlet Engine - Database Access Layer - Database
    Application Layer - Application Layer - Database Access Layer - Database
    I have an object model developed using Torque (A JDBC Object Relational modeling framework) for over 100 tables (to be over 160) that I am commencing to enable over RMI. I have got several remote methods up and running. For some of the simple methods starting up has been easy. Going forward I forsee issues.
    Each table has a wrapper or data object and a peer object that have setters/getters and special methods as desired. The majority of these classes are extended from Base Objects that have basic common functionality for retrieving, creating, and manipulating with a database using SQL.
    I have started building a Remote Interface and an Implementation class that invoke the necessary methods and classes within the Object Model to pull successfully off or update the database. Additionally the methods will need to return objects that represent non-primitive serializable dataobjects and collections of objects.
    Going forward client applications, servlets, and jsps will be using the database in more complex and comprehensive methods over rmi. Here are a couple of things I am concerned about.
    1) When to use java.rmi.server.codebase for class loading? In my implementation several of the remote methods will return objects (e.g Party, Country, CountryList, AccountList). These objects themselves are composed of other objects that are not part of the jvm. For all remote methods that return non-primitive objects must you include the classes in the codebase for the client to operate upon them. Couldn't this be pointless as you have abstract and extended classes all residing within the codebase? In practice do people generally build very thin proxy objects for the peer/data objects to hold just the basic table elements and sets?
    2) Server Versioning/Identity - Going forward more server classes will be enabled via rmi. Everytime one wants to include more methods on interface that is available must you update the interface, create new implementation classes, and redistribute the Remote Interface, and stubs/skels to client apps to operate on again? Is there some sort of list lookup that a client can do to say which processes are available remotely presently (not just at initialization)? As time changes more or fewer methods might be available?
    Any help is greatly appreciated.

    More on Why other approaches would be better?
    I have implemented some proxy objects for the remote Data Objects produced by Torque. To ease the pain, I have also constructed a proxy Builder that takes the table schema and builds a Proxy Object, an inteface for the proxy, and methods to copy between the Torque Data Object (which only lives on the server) into the Proxy Object (accessible by client and/or server).
    The generated methods are useable in the object implementing the Remote Interface but are themselves not remoteable. Only the Server would use these methods. Clients can only receive primitives, proxy Objects, or collections of ProxyObjects.
    This seems to be fairly light currently. I had to jump hoops to use Torque and enable remote apps to use the proxy objects. What would be the scaling issues that will come up? Why would EJBs with containers and all kinds of things about such as CMP vs BMP to be concerned with be a better approach?
    Methods can be updated to do several operations verses Torque and return appropriately (transactions). In this implementation the client (Servlet, mini App or App) needs the remote stub and the proxy objects (100 or so) to stand in for the Torque generated Data Objects. A much smaller and lighter set of classes, based on common JDK classes, instead of the torque classes (and necessary abstracts/objects/interfaces/exceptions for Torque).

  • EventListeners for multiple remote object calls

    Hi all,
    I have a Flex component that is displaying content from multiple (specifically two) remote object calls. I can call both remote methods, get the results back, pass them off to their respective ItemRenderers, etc. with no trouble. What I need, though, is a way to determine if I get no results back from either function call, to dispatch an event to trigger the next view state, and I don't know how to do that. Something like:
    protected function ticketConfigurationStateChangeHandler(event:Event):void
                   if(getPackagePromptsResult.lastResult.length == 0 && getTicketPromptsResult.lastResult.length == 0)
                         this.dispatchEvent(new Event("ticketConfigurationStateChange"));
                protected function ticketPrompts_creationCompleteHandler(event:FlexEvent):void
                    getTicketPromptsResult.token = registrationAPI.getTicketPrompts();
                    getTicketPromptsResult.addEventListener(ResultEvent.RESULT, showTicketConfiguration);
                protected function packagePrompts_creationCompleteHandler(event:FlexEvent):void
                    getPackagePromptsResult.token = registrationAPI.getPackageCPrompts();
                    getPackagePromptsResult.addEventListener(ResultEvent.RESULT, showPackageConfiguration);
    Any suggestions would be greatly appreciated...I know I need the event listeners to be able to get lastResult.length (and have it not be null) but I don't know how to set them up so I can automatically pass the user through the component and onto the next one if there are no results returned without having the user click a button or something similar on an otherwise blank component.
    Thanks in advance!
    ~ Amanda

    Hi all,
    I have a Flex component that is displaying content from multiple (specifically two) remote object calls. I can call both remote methods, get the results back, pass them off to their respective ItemRenderers, etc. with no trouble. What I need, though, is a way to determine if I get no results back from either function call, to dispatch an event to trigger the next view state, and I don't know how to do that. Something like:
    protected function ticketConfigurationStateChangeHandler(event:Event):void
                   if(getPackagePromptsResult.lastResult.length == 0 && getTicketPromptsResult.lastResult.length == 0)
                         this.dispatchEvent(new Event("ticketConfigurationStateChange"));
                protected function ticketPrompts_creationCompleteHandler(event:FlexEvent):void
                    getTicketPromptsResult.token = registrationAPI.getTicketPrompts();
                    getTicketPromptsResult.addEventListener(ResultEvent.RESULT, showTicketConfiguration);
                protected function packagePrompts_creationCompleteHandler(event:FlexEvent):void
                    getPackagePromptsResult.token = registrationAPI.getPackageCPrompts();
                    getPackagePromptsResult.addEventListener(ResultEvent.RESULT, showPackageConfiguration);
    Any suggestions would be greatly appreciated...I know I need the event listeners to be able to get lastResult.length (and have it not be null) but I don't know how to set them up so I can automatically pass the user through the component and onto the next one if there are no results returned without having the user click a button or something similar on an otherwise blank component.
    Thanks in advance!
    ~ Amanda

  • When  submit remote object call getting error Client.Error.DeliveryInDoubt

    Hello,
    We are having very weird error DeliveryInDoubt from blazeds.
    [ERROR] failed to call the remote service !!![FaultEvent fault=[RPC Fault faultString="Channel disconnected" faultCode="Client.Error.DeliveryInDoubt" faultDetail="Channel disconnected before an acknowledgement was received"] messageId="98F7B030-0FE0-0B88-300C-EC422D055E21" type="fault" bubbles=false cancelable=true eventPhase=2
    Error does not happen every time, but rather from time to time but happens on all client machines.
    Environment:
    blazeds v3.
    Flex application with Remote Object.
    Browser IE7.
    Object that passed to blazeds is complex and might have 100 items.But number of items does not seem affect error occurences.
    Short description for the object passed to blazeds remote object call for processing:
    Remote Object call takes an argument ArrayCollection of SyncRequest objects (_requestSyncList)
                    var syncRequest:SyncRequest = new SyncRequest();
                    var syncObject:Object = new Object();
                    syncObject[requestBuilder.direction] = requestBuilder.jobMap;
                    syncRequest.syncJobs = syncObject;
                    _requestSyncList.addItem(syncRequest);          
    requestBuilder.jobMap is an object that have different artifacts.
    jobMap[obj.artifact] = myColl;
    myColl is ArrayCollection of artifact of SyncJob
    Here is the definition of SyncJob
       public class SyncJob
            public var jobName:String;
            [ArrayElementType("com.farmers.docprocessing.remotesync.vo.JobParameter")]
            public var jobParams:ArrayCollection;
    Not sure what causing that issue and how to debug it. 
    Please advice.
    Thank you

    Not without you psoting some code.
    Possible problem: Difference between object type being returned, vs the type of the reference (i.e., the method that returns an object should have a return type of the interface name).

  • Interrupting a Thread in a Remote Object?

    HI,
    I am trying to get some thread synchronization to happen between a client and a remote RMI object. Essentially what I am trying to accomplish, is that if I interrupt a call on a blocking method in the remote object, I want the thread to throw the InterruptException. For example, the following code represents what I am trying to accomplish:
    package bca.test.rmi;
    import java.rmi.Naming;
    import java.rmi.Remote;
    import java.rmi.RemoteException;
    import java.rmi.server.UnicastRemoteObject;
    public class InterruptThreadApp {
    RemoteBlockingObjectInt remote = null;
    public static void main(String[] args) throws Exception {
    //Create the remote object
    RemoteBlockingObject obj = new RemoteBlockingObject();
    //bind it to the registry
    Naming.rebind("rmi://localhost/blocking", obj);
    //start the client, or the thread which will access the blocking call remotely
    InterruptThreadApp app = new InterruptThreadApp();
    Thread blocking = null;
    //wait for the thread to start
    synchronized ( app ) {
    blocking = app.startClient();
    app.wait();
    Thread.sleep(2000);
    //now interrupt the thread (note: the remote object should be blocking in
    //the blockingMethod().. this should produce an InterruptException?
    blocking.interrupt();
    public Thread startClient() {
    Thread t = new Thread("Client") {
    public void run() {
    try {
    //get a handle to the stub
    remote = (RemoteBlockingObjectInt) Naming.lookup("rmi://localhost/blocking");
    //now make a call to the blocking method, but first wake up the client
    synchronized ( InterruptThreadApp.this ) {
    InterruptThreadApp.this.notify();
    //now make the blocking call
    remote.blockingMethod();
    catch (InterruptedException e) {
    System.out.println("WooHoo! This is what we want! But it never gets thrown :(");
    catch (Exception e) {
    e.printStackTrace();
    t.start();
    return t;
    package bca.test.rmi;
    import java.rmi.server.UnicastRemoteObject;
    import java.rmi.RemoteException;
    import java.rmi.Remote;
    public class RemoteBlockingObject extends UnicastRemoteObject implements RemoteBlockingObjectInt {
    Object obj = new Object();
    public RemoteBlockingObject() throws RemoteException {
    super();
    public void blockingMethod() throws RemoteException, InterruptedException {
    synchronized (obj) {
    System.out.println("About to block.. so we can be interrupted later");
    obj.wait();
    interface RemoteBlockingObjectInt extends Remote {
    public void blockingMethod() throws RemoteException, InterruptedException;
    When I make a call to "remote.blockingMethod()", it blocks in the remote object (buy just "wait" ing). I want to interrupt this thread, by issuing an Thread.interrupt(). When I do so (I call "blocking.interrupt()"), nothing happens... no exception is thrown.. it just silently fails.
    Ok, so I suppose that we can not interrupt a remote thread.. that is fine. But what if I want to interrupt the RMI thread making the remote call? I don't want it to block forever. How can I "cancel" the remote call?
    Ideally, I would like the remote.blockingMethod() call to throw an InterruptException when I issue an "interrupt()" on the blocking thread. Any suggestions on how I might accomplish this?
    Thanks,
    Bryan

    While you can interrupt the RMI call, you cannot stop the active processing. That is, you cannot force a thread to stop (see the Java API documentation on Thread.stop().)
    Since the Client RMI call is a waiting thread, you need another Client thread to do a secondary RMI call. The trick is to have the new RMI endpoint connection thread on the RMI Server interrupt the original RMI endpoint connection thread.
    The only way you can interrupt an RMI call is to have the endpoint connection thread that runs on the RMI Server be aware that the user may wish to interrupt it.
    The best means of interruption is for the endpoint connection thread to use "worker threads". The endpoint connection thread waits for the workers to finish and is interruptible by both the workers and other endpoint connection threads.
    Another means of interruption is for the endpoint connection thread to segment the task into units of work and check for an interruption between those units of work.
    There are two ways I've done RMI call interruption.
    One is for the Client to pass a unique id (UID -- that uniquely identifies the request) to the Server with the original call. When the Client wishes to interrupt the original call, using the separate thread, it does a new RMI call to the Server passing the UID.
    The new endpoint connection thread, using the UID, interrupts the original endpoint connection thread.
    The major problem with this is the unique id. It absolutely, positively must be unique. Otherwise you run the risk of Client_A purging Client_B's request.
    The second method requires callback. If your Client is behind a firewall then RMI callback is near impossible. In such a case you must come up with a way for the Server to call the Client that is secure (the firewall problem.)
    The Client must export a remote object and pass that remote object to the Server with the original call.
    The endpoint connection thread recognizes the remote object and does a call back to the Client passing information that uniquely identifies itself (UID). Since the Server generates the UID, it can guarantee uniqueness.
    The Client callback implementation runs as a separate thread since the Client is in fact an RMI Server itself (when it did the export.) The Client must save the UID. The Client must start a new thread for the interrupt procedure or inform a waiting thread that the Server called back.
    Just like method one, above, when the Client wishes to interrupt the original call, using the separate thread, it does a new RMI call to the Server passing the UID.
    The new endpoint connection thread, using the UID, interrupts the original endpoint connection thread. Simple.
    For an academic example using call back go over to Jini.org. They have an example called "Cancellation" at:
    http://starterkit-examples.jini.org/
    For a professional, open source implementation of both these methods go over to CoopSoft.com. The Tymeac (Java) projects support canceling both waiting and autonomous requests at:
    http://www.coopsoft.com/JavaProduct.html

Maybe you are looking for

  • Regarding- Packing Line Item Not Displayed in the Delivery Document.

    Hi, I have 2 queries 1) Have  created separate Material Type Packaging for my packing material and the item category group used is VERP, my Orginal Material is getting packed in the Delivery Document, however the packed item is not coming as a separa

  • Is there a quick-start guide to creating plugins ?

    Hello Adobe Community, I would like to know if there is a guide or something similar that shows how to create a very-very simple plugin (maybe change only one parameter of a layer) ? Right now there is only the SDK.pdf, which isn't the best place for

  • Checked in filecontent is nil

    Hi, I am trying to upload PDF files to UCM server using UCM out of box WSDL's. When I tried to call CheckIn Universal operation using SoapUI tool from my local machine, I am getting status message that, '*Successfully checked in content item "1000001

  • Download itunes to ipad 2

    How do I buy a movie on itunes and download it to ipad 2?

  • Can't find Lima, Peru in weather widget

    Can anybody find this city in the weather widget? I have tried in 2 different iphones without any luck. I have family there and I would like to have this city added to my weather widget. The strange thing is that my hometown trujillo, peru and cuzco,