Archived

This forum has been archived. Please start a new discussion on GitHub.

Handling Specific User defined Ice exception and Delegating the same to client

We have an application where Ice Server is implemented as 2 layers and both of them own separate communicator and object adapter. We have 2 slice file definitions for communication from Client----->First level server[Java implementation]------>Second level server[C++ implementation]. We use different Ice exception defined at each of this level. For example MyAppException is thrown from First level server to Client and MyAppInternalException from Second level server to First level server.

First level server acts as both server and client, for requests from client it implements object adapter and it has proxy to call Second level server. We want to delegate the exception from First level server to Client as MyAppException on specific MyAppInternalException handling.

We were not able to catch MyAppInternalException thrown from Second level server on First level server. But These exception were caught as generic exception java.lang.Exception. How do we catch MyAppInternalException as specific exception and throw proper MyAppException at catch block to client ?

Tagged:

Comments

  • mes
    mes California

    Hi,

    Are you using java:package metadata in your Slice definitions? If so, you probably need to add configuration settings that allow Ice to properly resolve the generated Java class for the user exception. The Ice manual provides more details on these settings.

    If this is not the issue, please provide more information. For example, it might be useful for us to see the full stack trace of the java.lang.Exception.

    Regards,
    Mark

  • Hello,

    We are not using java:package metadata in our slice definitions. I tried similar communication on simple example where it is working fine. But in actual application we are still not able to solve this issue. Sample example code is attached. I have attached exception stack trace on our application we are unable to catch it as specific exception. Exception trace was found on First level java server.

  • mes
    mes California

    Hi,

    I'm afraid the stack trace you provided didn't offer any new information. To get a stack trace, your Java code should do something like this:

    try
    {
        // make remote invocation to internal server...
    }
    catch(InternalException ex)
    {
        throw new ExternalException(...);
    }
    catch(java.lang.Exception ex)
    {
        ex.printStackTrace();
    }
    

    If the Java code receives something other than the expected InternalException, the second catch block will print the exception's stack trace. Please provide that stack trace.

    It would be helpful for us to see the actual Slice definitions being used here. You could also enable protocol tracing in your internal server (with --Ice.Trace.Protocol) to verify that the user exception is being returned as expected.

    Finally, what version of Ice are you using?

    Regards,
    Mark