Thanks to Magnus for solving this one.
If anyone else runs into this problem, the problem is solved by copying the
appropriate VisiBroker jar files to /path-to-jdk/jre/lib/ext/. Weird
behaviour by the VM classloader.
-Joe Walnes
At 04:49 PM 3/22/00 +0000, Joe Walnes wrote:
>I'm trying to use Orion as a client for some CORBA based objects that are
>accessible via Visibroker.
>
>The following code works as a standalone client, providing the correct
>jars are in the classpath and the appropriate system properties are set,
>and the ORB is running on the localhost:
>
>-----------------------------
>
>// Get context
>Properties p = new Properties();
>p.put(Context.INITIAL_CONTEXT_FACTORY,"com.inprise.j2ee.jndi.CtxFactory");
>p.put(Context.URL_PKG_PREFIXES,"com.inprise.j2ee");
>Context context = new InitialContext(p);
>
>// Lookup CustomerHome
>Object ref = context.lookup("customer");
>CustomerHome home =
> (CustomerHome) PortableRemoteObject.narrow(ref,CustomerHome.class);
>
>-----------------------------
>
>However, I'm trying to allow servlets/jsps access to the objects from
>within Orion. All the appropriate system properties (-Dxx=yy) where set on
>the command line when starting orion, the appropriate jars where placed in
>orion/lib and the orb was running on localhost.
>
>In a Servlet running in Orion, when the code got as far as creating the
>new InitialContext, a NoClassDefFoundError for
>com.inprise.j2ee.jndi.CtxFactory was thrown, however,
>Class.forName("com.inprise.j2ee.jndi.CtxFactory") did not throw an error.
>
>The problem appeared to be a ClassLoader problem, where InitialContext was
>using a different method for loading classes that the servlet was using,
>and only seemed to be looking in the base jars in the orion dir. I added
>the appropriate jndi/corba/iiop/orb classes to orion/jndi.jar and the code
>succesfully managed to lookup the required object. Hurrah!
>
>However, the object returned by context.lookup() is of type
>org.omg.CORBA.portable.ObjectImpl which needs to be narrowed to
>appropriate type before casting. This always throws a ClassCastException,
>even though the ObjectImpl says it is the correct type. I'm stuck!
>
>I've been trying to get round this problem for days now unsuccesfully. I
>can access the corba objects as standalone java apps, and from within Sun
>Web Server, mod_jserv and jRun with no problem, just not Orion.
>
>Can anyone help, or shed some light on what the problem may be. I suspect
>the problem is related to ClassLoader.
>
>Could one of the Orion team explain how the ClassLoader works in the
>server please.
>
>Note, in this case Orion is simply being used as a web-server for serving
>jsp/servlets. EJB/JTS/etc is not required, and the JNDI service is
>replaced by that that Visibroker supplies.
>
>Thanks in advance
>
>-Joe Walnes