UPDATES FOR: J2EE Developer's Handbook
by:  Paul J. Perrone, Venkata S.R.K.R. Chaganti, and Tom Schwenk

The bullet items below contains updates, errata, additional software profiles, and additional information for the J2EE Developer's Handbook.

(Click to return to Assured Technologies, Inc. homepage)



A reader wrote…

> As I was adapting your Corba example to suit a slimmed down example I

> noticed that the CustomerImplementation.java file has two lines out of place.


> The original is:

>      try {

>        NamingContext namingContext =

>          NamingContextUtility.getNamingContext();


>        // bind the Object Reference in Naming

>        NameComponent namingComponent = new NameComponent(name, "");

>        NameComponent nameComponent[] = { namingComponent };


>        //==

>        ORB orb = NamingContextUtility.getORB();


> However, if you do this, then you get a null pointer exception. If you put the

> ORB orb ... line before the NamingContext namingContext...line, then it works.


> Obviously, it may work ok in the full example, but I didn't do much else

> except to slim things down, so suspect it's just a typo. Just checked the

> book and see that on page 379 it's the same as in the code on the cd.


Our reply….


Indeed in the full example, the thread goes as follows:


1) ServerRegistrar.main() method invokes NamingContextUtility.getORB()


2) NamingContextUtility.getORB()invokes initializeOrb(args) which sets

            the local singelton Orb object inside the NamingContextUtility

            via orb = ORB.init(args, null). This orb is initialized on the

            server-side of the example.


3) ServerRegistrar.main() then creates and registers the QueryServerImplementation


4) When the client invokes the QueryServerImplementation server's

            long-winded findCustomersWhoOrderedForMoreThan() method, some

            CustomerImplementation objects are created and bound on the

            server-side via calls to CustomerImplementation.bind()


5) Inside that bind() method is where the snippet you used was located.

            Since the orb was already initialized on the server-side, the

            getNamingContext() method shouldn't flag a null exception when

            it tries to use the orb reference.


As you indicate...as a matter of good practice, we might have a check inside

of the NamingContextUtility.getNamingContext() method to create the orb

object if it isn't already created ala this...


  public static NamingContext getNamingContext() throws Exception{

    // First make sure orb reference is resolved and non-null



    // Get the namingContextReference and namingContext

    org.omg.CORBA.Object namingServiceReference =


    NamingContext namingContext =



    return namingContext;



The reason why we broke out the example as such was for

pedagogic reasons to illustrate the steps.


Thanks very much for the query! We'll make note on the Web site

about your suggetsion for this.


Tips for UNIX developers


If you are having difficulty with the proper UNIX installation of the JNDI

examples in this book, please see the notes on pages 624 and 625.


Note that the build.properties files equipped with this chapter illustrate by example. They are configuration properties that will be different depending on where you decide to place such SPI files on your system. The chapter text preceeding each note references the Web links from where you can download the JNDI SPIs for use with those examples.


The Ant scripts used in the book are platform independent and often generate execution scripts that can run on either Windows or Unix. For example, there are .bat and .sh script templates for the jndi examples you mention beneath the directory examples\config\execscripts\ejava\jndi\directory.


Appendix A also describes how to install and configure all of the examples and describes the approach taken for running the examples on Unix and Windows platforms.