Struggling as a newbie to access JMS resources from a standalone client from a Glassfish 4 server running on the same Windows 7 64-bit machine,
running in NetBeans. (want to do this for debugging)
I have had lots of problems trying the create a context and googling has led me to add the following to the classpath
jar:file:/C:/Users/..../Java/xom-1.2.7/XOM/xom-1.2.7.jar (was there anyway I think?)
jar:file:/C:/Oracle/FMW_Home/modules/javax.jms_1.1.1.jar
jar:file:/C:/glassfish4/glassfish/lib/jndi-properties.jar
jar:file:/C:/glassfish4/glassfish/lib/gf-client.jar
jar:file:/C:/glassfish4/glassfish/modules/glassfish-naming.jar
jar:file:/C:/glassfish4/glassfish/lib/javaee.jar
jar:file:/C:/glassfish4/glassfish/lib/appserv-rt.jar
That didn't help so I also manually installed dependences as follows:
During the build I get these messages:
The POM for cepdemo:cepdemopersistence:jar:1.1-SNAPSHOT is missing, no dependency information available
The POM for org.glassfish.appclient:gf-client:jar:3.1.1 is invalid, transitive dependencies (if any) will not be available, enable debug logging for more details
The POM for org.glassfish.common:glassfish-naming:jar:3.1.1 is invalid, transitive dependencies (if any) will not be available, enable debug logging for more details
The first jar is one I've created and added as a dependency. Didn't get this message before I added the other 2 jars as runtime dependences.
I've got beyond exceptions trying to access the class "com.sun.enterprise.naming.impl.SerialInitContextFactory"
but now get the following
Exception in thread "FO Trade Thread" java.lang.NoClassDefFoundError: org/glassfish/internal/api/Globals
at com.sun.enterprise.naming.impl.SerialInitContextFactory.
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:525)
at java.lang.Class.newInstance0(Class.java:372)
at java.lang.Class.newInstance(Class.java:325)
at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:671)
at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:307)
at javax.naming.InitialContext.init(InitialContext.java:242)
at javax.naming.InitialContext.
at com.oracle.cepdemo.tradeinjector.InitQueueContext.getInitialContext(InitQueueContext.java:29)
at com.oracle.cepdemo.tradeinjector.TradeInjectorMain$FOTradeInject.run(TradeInjectorMain.java:173)
at java.lang.Thread.run(Thread.java:722)
Caused by: java.lang.ClassNotFoundException: org.glassfish.internal.api.Globals
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:423)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
... 14 more
Below are relevant snippets of code........
public class xxxMain {
public final static String JNDI_FACTORY = "com.sun.enterprise.naming.impl.SerialInitContextFactory";
public final static String URL = "corbaname:iiop://localhost:7676";
...
stuff going on
....
// then get jndi context to access glassfish resources
InitialContext jndiContext = null;
ConnectionFactory qconFactory = null;
Connection conn = null;
Queue queue;
QueueSession qsession = null;
QueueSender qsender = null;
try {
jndiContext = InitQueueContext.getInitialContext(URL);
//jndiContext = new InitialContext();
} catch (NamingException ex) {
Logger.getLogger(TradeInjectorMain.class.getName()).log(Level.SEVERE, null, ex);
}
abstract class InitQueueContext {
public static InitialContext getInitialContext(String url)
throws NamingException {
Hashtable env = new Hashtable();
env.put(Context.INITIAL_CONTEXT_FACTORY, JNDI_FACTORY);
env.put(Context.PROVIDER_URL, url);
return new InitialContext(env); // stops here
}
}
Any guidance would be welcome
Thank you