Are there any inherent compatibility issues with ActiveMQ and JNI? Maybe I've got a simple configuration issue. I don't see any clean examples that use ActiveMQ and JNI. This code worked for another jms provider.
Platform: Windows XP C++ Compiler: Visual Studio 6.0 Java version: java 1.6 Activemq version: 5.4.2 Application: C++ application that uses JNI to create JVM to access ActiveMQ topics. The POJO app works fine with same java code that accesses Activemq that is also running on this machine, but when loaded in via JNI I get: javax.naming.NoInitialContextException: Cannot instantiate class: org.apache.activemq.jndi.ActiveMQInitialContextFactory [Root exception is java.lang.ClassNotFoundException: org/apache/activemq/jndi/ActiveMQInitialContextFactory] when javax.naming.InitialContext(props) is called with (IP changed to protect the innocent): java.naming.factory.initial=org.apache.activemq.jndi.ActiveMQInitialContextFactory java.naming.provider.url=tcp://555.555.555.555:61616 java.naming.security.principal=defaultUser java.naming.security.credentials=defaultPassword I've run with -verbose:class and verified the classpath is correct by forcing an instanciation of ActiveMQInitialContextFactory and see: [Loaded org.apache.activemq.jndi.ActiveMQInitialContextFactory from file:/C.../activemq-all-5.4.2.jar] Here's the basic JNI code: classPath = "-Djava.class.path=" + classPath; dsoPath = "-Djava.library.path=" + dsoPath; std::cout << "Path2: "<< (char*)classPath.c_str() << std::endl; JavaVMOption options[3]; options[0].optionString = (char*)classPath.c_str(); options[1].optionString = (char*)dsoPath.c_str(); options[2].optionString = "-verbose:class"; //class|gc|jni mJvmArgs.version = JNI_VERSION_1_6; // Tried using 1_4, but it produced same exception //mJvmArgs.version = JNI_VERSION_1_4; mJvmArgs.options = options; mJvmArgs.nOptions = 3; mJvmArgs.ignoreUnrecognized = JNI_FALSE; if (JNI_CreateJavaVM(&gJvm, (void**)&mJvmEnv, &mJvmArgs) < 0) The class loading is suspicious for InitialContext. With the POJO the class loading looks like: [Loaded com.sun.naming.internal.ResourceManager from rt.jar] [Loaded com.sun.naming.internal.VersionHelper from rt.jar] [Loaded com.sun.naming.internal.VersionHelper12 from rt.jar] [Loaded com.sun.naming.internal.VersionHelper12$2 from rt.jar] [Loaded com.sun.naming.internal.VersionHelper12$6 from rt.jar] [Loaded com.sun.naming.internal.VersionHelper12$5 from rt.jar] [Loaded javax.naming.NamingEnumeration from rt.jar] [Loaded com.sun.naming.internal.VersionHelper12$InputStreamEnumeration from rt.jar] [Loaded com.sun.naming.internal.VersionHelper12$InputStreamEnumeration$1 from rt.jar] [Loaded com.sun.naming.internal.VersionHelper12$4 from rt.jar] [Loaded javax.naming.spi.NamingManager from rt.jar] [Loaded javax.naming.spi.InitialContextFactory from rt.jar] [Loaded org.apache.activemq.jndi.ActiveMQInitialContextFactory from file:activemq-all-5.4.2.jar But the class loading in the c++ app that uses JNI to create a JVM: [Loaded javax.naming.InitialContext from rt.jar] [Loaded com.sun.naming.internal.ResourceManager from rt.jar] [Loaded com.sun.naming.internal.VersionHelper from rt.jar] [Loaded com.sun.naming.internal.VersionHelper12 from rt.jar] [Loaded com.sun.naming.internal.VersionHelper12$2 from rt.jar] [Loaded com.sun.naming.internal.VersionHelper12$6 from rt.jar] [Loaded com.sun.naming.internal.VersionHelper12$5 from rt.jar] >>[Loaded sun.misc.URLClassPath$2 from rt.jar] >>[Loaded java.lang.ClassLoader$2 from rt.jar] >>[Loaded sun.misc.URLClassPath$1 from rt.jar] >>[Loaded java.net.URLClassLoader$3 from rt.jar] >>[Loaded sun.misc.CompoundEnumeration from rt.jar] >>[Loaded javax.naming.NamingEnumeration from rt.jar] >>[Loaded com.sun.naming.internal.VersionHelper12$InputStreamEnumeration from rt.jar] >>[Loaded com.sun.naming.internal.VersionHelper12$InputStreamEnumeration$1 from rt.jar] >>[Loaded java.net.URLClassLoader$3$1 from rt.jar] >>[Loaded com.sun.naming.internal.VersionHelper12$4 from rt.jar] >>[Loaded javax.naming.spi.NamingManager from rt.jar] >>[Loaded javax.naming.NoInitialContextException from rt.jar] Note, I've also put the jndi.properties into the jar that I'm loading that has the properties for finding the activeMQ server. Any ideas are greatly appreciated. Thanks! -- View this message in context: http://activemq.2283324.n4.nabble.com/ActiveMQ-JNI-problem-simple-config-problem-or-compatibility-issue-tp3721325p3721325.html Sent from the ActiveMQ - User mailing list archive at Nabble.com.