> With JMS, you use the JNDI InitialContext object that includes the class
> name of the provider of the JMS. Then, JNDI uses that to instantiate the
> class and create the initial connection for JNDI queries.
>
> Do you have any idea how to work with this in a Tomcat world? I'm not
sure
> how to cause this to load since I think it's that nasty situation in which
a
> lower-level classloader doesn't know how to move up. In this case, do you
> think it's "okay" to put the JMS classes in the CLASSPATH for Tomcat?
I've
> seen that it will work.
Unfortunately, this causes the entire problem to rear its ugly head again.
The problem is that I have classes that are in the WEB-INF paths for Tomcat,
and one of those classes is sent as a Serialized object through JMS. And
since JMS ends up being loaded by the CLASSPATH classloader, it cannot find
the class my JSP created.
It seems like using JNDI and JMS in JSP/servlets was supposed to work since
they are part of the J2EE world. Didn't anybody realize that they'd run
into these odd classloader issues? I was able to make it work (I think)
using this code which basically overrides the default JNDI initial context
factory builder and does my own. I have no idea if this will work for other
JMS/JNDI systems.
// First, trick JNDI into use my context factory builder...
javax.naming.spi.NamingManager.setInitialContextFactoryBuilder(this);
And because I was lazy, I just made my class implement:
javax.naming.spi.InitialContextFactoryBuilder
And here's the code that implements that interface:
public javax.naming.spi.InitialContextFactory
createInitialContextFactory(Hashtable env)
throws
javax.naming.NamingException
{
String initialContextFactory =
(String)env.get(Context.INITIAL_CONTEXT_FACTORY);
try
{
return
(javax.naming.spi.InitialContextFactory)Class.forName(initialContextFactory)
.newInstance();
}
catch(java.lang.InstantiationException e)
{
throw new javax.naming.NamingException("Could not instantiate: " +
initialContextFactory);
}
catch(java.lang.IllegalAccessException e)
{
throw new javax.naming.NamingException("Could not legally
instantiate: " + initialContextFactory);
}
catch(java.lang.ClassNotFoundException e)
{
throw new javax.naming.NamingException("Could not load: " +
initialContextFactory);
}
}
David
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, email: [EMAIL PROTECTED]