Here is a forum post on the glassfish discussion forums that talks about connecting to a remote GlassFish server programmatically. This would be the same process as connecting from outside of the app server, as long as you have the correct jars on your classpath.
http://forums.java.net/jive/thread.jspa?messageID=272823񂦷
If you read through the whole thing, you will see some description of using different initial context factories that do/don't work as expected, etc.
Good luck
Alex Sherwin
alex.sherwin_at_acadiasoft.com
-----Original Message-----
From: glassfish_at_javadesktop.org [mailto:glassfish_at_javadesktop.org]
Sent: Monday, August 04, 2008 6:02 PM
To: users_at_glassfish.dev.java.net
Subject: Accessing JDBC Resource and JMS Resource
Hi there,
I'd like to know if it is possible to access a jdbc resource created on sun app server can be accessing using jndi name from a standalone application. Also I'd like to know if a standalone java application can lookup a jms resource.
I tried doing the above however I get the following error message "javax.naming.NameNotFoundException [Root exception is org.omg.CosNaming.NamingContextPackage.NotFound: IDL:omg.org/CosNaming/NamingContext/NotFound:1.0]"
Please find enclosed the code that I wrote. Any inputs would be much appreciated.
Hashtable env;
Context jndiContext = null;
try
{
env = new Hashtable();
// For use with the File System JNDI Service Provider
env.put(Context.INITIAL_CONTEXT_FACTORY,
"com.sun.jndi.cosnaming.CNCtxFactory");
env.put(Context.PROVIDER_URL, "iiop://localhost:33700");
// env.put( Context.URL_PKG_PREFIXES ,
//"com.sun.enterprise.naming");
jndiContext = new InitialContext(env);
}
catch (NamingException e)
{
System.out.println("Could not create JNDI API " +
"context: " + e.toString());
System.exit(1);
}
try
{
Object obj1 = jndiContext.lookup("jdbc/INSTA");
//Object obj1 = jndiContext.lookup("jms/MyQCF");
System.out.println("Look up successful");
}
catch (NamingException e)
{
System.out.println("JNDI API lookup failed: " +
e.toString());
System.exit(1);
}
Regards
[Message sent by forum member 'kakkarjatin' (kakkarjatin)]
http://forums.java.net/jive/thread.jspa?messageID=291440
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe_at_glassfish.dev.java.net
For additional commands, e-mail: users-help_at_glassfish.dev.java.net