dcsimg
Q: Connect to two different server versions from one program?
0 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Peter_Kormos
Posted On:   Thursday, January 13, 2005 01:23 AM

Hi All, I'm trying to write a program that talks with both SwiftMQ 5.x and SwiftMQ 2.x server versions. Since these are different servers, I need to use different .jar files to build up connection to each server. So I come up with the idea of using custom class loaders. Everything seems to be working OK until the code reaches javax.naming.InitialContext.lookup() The objects returned by InitialContext.lookup() are loaded by javax.naming.spi.NamingManager running inside InitialContext. NamingManager is using static final VersionHelper helper = VersionHelper.getVersionHelper() to load the classes. This helper objec   More>>

Hi All,


I'm trying to write a program that talks with both SwiftMQ 5.x and SwiftMQ 2.x server versions.


Since these are different servers, I need to use different .jar files to build up connection to each server. So I come up with the idea of using custom class loaders.
Everything seems to be working OK until the code reaches javax.naming.InitialContext.lookup()


The objects returned by InitialContext.lookup() are loaded by


javax.naming.spi.NamingManager running inside InitialContext.


NamingManager is using
static final VersionHelper helper = VersionHelper.getVersionHelper()


to load the classes. This helper object is initialized somewhere before my code, so it is using the default class loader to find classes. Since my default classpath doesn't contain any JMS API classes, I get ClassNotFoundException
on this line


initialContext = new InitialContext(env);


			
javax.naming.NoInitialContextException: Cannot instantiate class: com.swiftmq.jn
di.InitialContextFactoryImpl. Root exception is java.lang.ClassNotFoundExceptio
n: com.swiftmq.jndi.InitialContextFactoryImpl
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at com.sun.naming.internal.VersionHelper12.loadClass(Unknown Source)
at javax.naming.spi.NamingManager.getInitialContext(Unknown Source)
at javax.naming.InitialContext.getDefaultInitCtx(Unknown Source)
at javax.naming.InitialContext.init(Unknown Source)
at javax.naming.InitialContext. (Unknown Source)

I cannot add JMS API jars to default classpath, because in this case I could connect to either one or the other server only but not both at the same time.


Does anyone have a workaround for this problem?


Thanks for the help,


Peter

   <<Less
About | Sitemap | Contact