What causes the UNKNOWN exception in VisiBroker for Java 3.x?

From Support
Jump to: navigation, search

Question:

What causes the UNKNOWN exception in VisiBroker for Java 3.x?

A client application or applet receives a CORBA.UNKNOWN  exception when invoking a method on a remote object.

Answer:

When a  client application or applet receives a CORBA.UNKNOWN  exception the problem is due to an error in the server.

Java Runtime exceptions and UserExceptions not specified in the  IDL definition for an operation will be caught be the ORB runtime and  will be sent as a CORBA.UNKNOWN exception back to the client.

An example might be when a server method throws a NullPointerException due to a programming error.  This exception will get sent back to the client as a CORBA.UNKNOWN.

In order to isolate the problem in the server it is important to know which exception is actually being thrown, and where the error occurs.

A  useful technique is to run the server with the ORBwarn option set to 2 ("-DORBwarn=2").  When ORBwarn is set to level 2 the server will show the underlying exception which is being converted to a CORBA.UNKNOWN.  For example:

vbj -DORBwarn=2 Server

AccountManagerImpl[Server,oid=PersistentId[repId=IDL:Bank/AccountManager:1.0,objectName=BankManager]] is ready.

VisiBroker for Java runtime caught exception:
java.lang.NullPointerException
        at AccountManagerImpl.open(AccountManagerImpl.java:12)
        at Bank._AccountManagerImplBase._execute(_AccountManagerImplBase.java:57

...

Caught exception: org.omg.CORBA.UNKNOWN[completed=MAYBE, reason=Exception: java.lang.NullPointerException]
...

Sending exception to client: org.omg.CORBA.UNKNOWN[completed=MAYBE, reason=Exception: java.lang.NullPointerException]
 

The stack trace for the real exception should be printed in the diagnostic output, which should provide both the type of the exception and location in the call stack where the exception was thrown. Usually this will be in the implementation code, which the programmer will be able to diagnose and correct.  In some rare cases this may be in the skeleton or orb code.  The source of the error will almost always be traceable to an error in the user code that has just completed executing.

Another technique to obtain this information is to run the server with the ORBdebug  property.
This technique can be used in versions prior to VBJ 3.2 where the ORBwarn option may not be available.

Also be aware that for an applet the "server" might be the gatekeeper proxy.  If the server does not show any errors in the ORBwarn or ORBdebug output, but the client receives a CORBA.UNKNOWN, then the problem may be occurring in the gatekeeper. In this situation the gatekeeper should also be run with the log_level set to "debug"  or the ORBwarn property set in the configuration file.



Article originally contributed by Borland Developer Support