Java IDL FAQ
Home Mapping Info Non-compliance Gallery Java IDL FAQ Java IDL Library

 

Java IDL Frequently Asked Questions

This is the first version of a Java IDL FAQ, and is very incomplete. Suggestions, comments and corrections greatly appreciated. Encouraging words especially appreciated, as this is often all that I need to motivate me to keep going. Send mail to sbarber@alum.mit.edu.

What is Java IDL?

Java IDL is a reference implementation of a CORBA Object Request Broker for Java, including support for the IDL to Java Mapping Specification as well as a transient implementation of the CosNaming service. Java IDL is included as a core package in Sun Microsystems' Java 2 releases (often referred to as JDK 1.2).

Is Java IDL useful for real work?

Yes, especially for Java CORBA clients that use a CORBA Naming Service to discover server references.

It's also fine for Java CORBA servers that run as persistent servers; that is, those that are started manually and don't need to be activated by an ORB or ORB-related service. While this isn't the way all CORBA deployments are configured, this method is used more often than one would think just from reading OMG specifications.

If the system is using the Java IDL-provided tnameserv CORBA Naming Service, then the servers must be written to re-register themselves each time they are started. tnameserv isn't particularly fault-tolerant, so this may be the first piece to consider replacing to do "real work" with Java IDL.

With what CORBA standards does Java IDL comply?

According to the JDK 1.2 documentation, the Java IDL in JDK 1.2 is compliant with the CORBA/IIOP 2.0 Specification (orbos/97-02-25) and the IDL-to-Java Language Mapping (orbos/98-01-06 Final).

Where's the IDL to Java compiler for Java IDL?

It's called idltojava, and it doesn't come with the JDK. It can be obtained for free for Windows and Solaris SPARC platforms by those willing to register as members of Sun's Java Developer Connection, at http://developer.javasoft.com

Can I get idltojava for platforms other than Windows and SPARC Solaris?

I don't think so.

Can I use other IDL to Java compilers to generate Java IDL stubs and skeletons?

In theory, yes. But in practice, some little problem usually creeps up that prevents it from working. Try looking for "strict" or "OMG" options on your compiler, but I haven't had much luck with this kind of thing. Counter-examples welcomed!

Why does idltojava give a can't find the preprocessor error on Windows?

This is because the idltojava compiler needs a C/C++ preprocessor in order to process the IDL directives that begin with #.

Can I use idltojava without a preprocessor?

If your idl file doesn't have any #-directives, the -fno-cpp option can be specified so that idltojava won't try to run a pre-processor.

How do I get the pre-processor working with idltojava?

The pre-processor has to be findable by idltojava, and the right options must somehow be passed to it. Sun actually documents what's going on here, and you can read about it in the idltojava documentation that came with the idltojava compiler for your platform. Or, see the FAQ below about using other pre-processors. Most of the details are re-stated there.

How can I use the Micrsoft Visual C++ preprocessor with idltojava?

For Visual C++ 5.0, there a file called vcvars32.bat that lives in x:\Program Files\DevStudio\VC\bin, where x is the drive where Visual C++ is installed. It may have to be edited to get all the drive letters right. Just execute vcvars32.bat in the command shell where idltojava will be run.

For those interested in such things, for an IDL file called x.idl, idltojava for Java 1.2 preprocesses via Visual C++ by issuing the following command:

cl /nologo /C /E /X /Tp x.idl   

How can I use the lcc preprocessor with idltojava?

There's a simple preprocessor available as part of the lcc compiler. It's free unless included as part of a commercial product.

The full lcc distribution and lots of other information on lcc is available at http://www.cs.princeton.edu/software/lcc

Here are the settings that worked for me on Windows 98:

set CPP=c:\pathto\cpp set CPPARGS=-N   

How can I use other preprocessors with idltojava?

Here's the note from the Sun idltojava documentation on how this is supposed to work:

Note:

idltojava is hard-coded to use a default preprocessor. On Solaris machines, it uses the path /usr/ccs/lib/cpp when looking for the preprocessor. On Wintel machines, it is hard-coded to use the MS Visual C++ preprocessor. You can change the preprocessor that idltojava uses by setting two environment variables:

CPP --set this environment variable to the full path name of the preprocessor executable you want to use.

CPPARGS --set this environment variable to the complete list of arguments to be passed to the preprocessor. The preprocessor needs to write to standard output, so if it does not do so by default, you should include the argument appropriate to your preprocessor to accomplish that.

Examples for Wintel users:

Windows 95 --in your autoexec.bat file, type something like the following:

> set CPP=\usr\share\lib\cpp 
> set CPPARGS=\nologo 

NT --go to Control Panel-->System and click on the Environment tab; then set the environment variables

Examples for Solaris users:

C shell --in your .cshrc file, type something like

> setenv CPP /usr/ccs/lib/cpp
> setenv CPPARGS -BCY 

Bourne or Korn shells --in your .profile file, type something like

> CPP=/usr/ccs/lib/cpp 
> export CPP 
> CPPARGS=-BCY 
> export CPPARGS 

In the example above, B tells the preprocessor to support C++ style comments (// to indicate that the rest of the line is a comment), C tells the preprocessor to leave comments in the preprocessed file, and Y tells the preprocessor not to bother looking at standard input files (such as /usr/include) since they are mostly C header files.

When you run idltojava with these two environment variables set, and the flag -fcpp is ON, idltojava will automatically use the preprocessor you specified in CPP and pass it the arguments you put in CPPARGS.

What minor codes are used when Java IDL returns CORBA exceptions, and what do they mean?

CORBA defines two kinds of exception codes, major codes and minor codes. Major codes correspond directly to CORBA-defined exception types, and are defined by the OMG in the CORBA specification.

Minor codes are ORB-implementation specific, and in Java IDL are defined relative to a major code. Minor codes provide additional information about the cause of the exception. Minor codes need not be unique across the entire implmentation, that is, minor code 3 for a COMM_FAILURE exception may have a completely different meaning than minor code 3 for a BAD_OPERATION exception.

In JDK 1.2.2, minor codes are listed in the com.sun.CORBA.util.MinorCodes class. These are otherwise undocumented, and Sun has made no statements, let alone any guarantees, about the meaning of the codes other the text strings that may accompany them in the exception in which they occur. In particular, there are no guarantees that the minor codes and their meanings will remain constant from release to release.

Nonetheless, one of the more frustrating aspects of developing systems with CORBA is the relative lack of information about what can go wrong, and why. It takes experience to divine, for example, that the most common cause of a remote UNKNOWN exception for a Java CORBA server implementation is a garden-variety Java NullPointerException.

The table below is derived from the JDK 1.2.2 Community Source, and is provided as a convenient summary. For each major exception type and code, we list associated minor codes, the name of the minor code assigned by Sun, and repeat the Sun-provided source comments about the minor code (if any).

Under Construction -- Partial List Only

CORBA System Exception Minor Code Name Description
BAD_INV_ORDER     
1     
DSIMETHOD_NOTCALLED     
BAD_PARAM     
1     
NULL_PARAM     
COMM_FAILURE     
1     
CONNECT_FAILURE     
COMM_FAILURE     
2     
CONN_CLOSE_REBIND     
COMM_FAILURE     
3     
WRITE_ERROR_SEND     
COMM_FAILURE     
4     
GET_PROPERTIES_ERROR     
COMM_FAILURE     
5     
BOOTSTRAP_SERVER_NOT_AVAIL     
COMM_FAILURE     
6     
INVOKE_ERROR     
Unable to successfully connect to the server after several attempts.
DATA_CONVERSION     
1     
BAD_HEX_DIGIT     
Encountered a bad hexadecimal character while doing ORB string_to_object operation.
DATA_CONVERSION     
2     
BAD_STRINGIFIED_IOR_LEN     
The given IOR for string_to_object operation has odd length. It must be even.
DATA_CONVERSION     
3     
BAD_STRINGIFIED_IOR     
The given string does not start with "IOR:" and hence is a bad stringified IOR.
DATA_CONVERSION     
4     
BAD_MODIFIER     
Unable to perform ORB resolve_initial_references operation due to the host or the post being incorrect or unspecified.

Copyright 1999 Steven E. Barber. All Rights Reserved.