Results 1 to 2 of 2
- 09-04-2009, 09:13 PM #1
Member
- Join Date
- Sep 2009
- Posts
- 2
- Rep Power
- 0
Glassfish InitialContext & ConnectionFactory lookup
Hi .. I am shifting my JMS-using app from JBoss to Glassfish. So far defeat plagues my effort to instantiate an InitialContext and look up a ContextFactory.
If a simple example exists for doing that with Glassfish, I can’t find it.
If this is the wrong JavaForum category to post this, please suggest the correct one. This is my first try.
To illustrate my problem, I created “MainTest” class (full code below) with a main() method to do that. My problem seems to be that I haven’t yet found the correct property parameters for the InitialContex constructor.
If anyone can help perfect my attempt below, I think it will be a great help to those who follow.
Anyway, here is what follows below:
A. The output from MainTest’s main() method.
[Black text is my code output. Red is from the System.err stream.]
B. Complete MainTest class code.
?1: I can’t find a clear explanation of how to resolve the reference to “endpoints” below.
?2: Please see the underlined red text. I seems like it is telling me it is doing what I thought my properties already did????
Thanks for any help.
GLB
--------------------------------
A. MainTest OUTPUT
java.naming.factory.initial=com.sun.appserv.naming .S1ASCtxFactory
java.naming.factory.url.pkgs=com.sun.enterprise.na ming
java.naming.provider.url=iiop://localhost:3700
java.naming.factory.state=com.sun.corba.ee.impl.pr esentation.rmi.JNDIStateFactoryImpl
Property key:value pairs successfully loaded.
Attempting to instantiate InitialContext.
Sep 4, 2009 9:22:27 AM com.sun.appserv.naming.RoundRobinPolicy setClusterInstanceInfo
WARNING: NAM1005 : No Endpoints selected. Please specify using system property com.sun.appserv.iiop.endpoints.
Sep 4, 2009 9:22:27 AM com.sun.appserv.naming.RoundRobinPolicy getEndpointForProviderURL
WARNING: NAM1001: No Endpoints selected in com.sun.appserv.iiop.endpoints property.
Using JNDI Provider URL iiop://localhost:3700 instead
Sep 4, 2009 9:22:27 AM com.sun.appserv.naming.RoundRobinPolicy setClusterInstanceInfo
INFO: endpoint.weight after checking isWeight = 10
Sep 4, 2009 9:22:27 AM com.sun.appserv.naming.RoundRobinPolicy setClusterInstanceInfo
INFO: sumOfAllWeights = 10
InitialContext instatiated: InitialContext
Attempting to lookup ConnectionFactory.
Sep 4, 2009 9:22:27 AM com.sun.appserv.naming.S1ASCtxFactory getCorbalocURL
INFO: list[i] ==> 127.0.0.1:3700
Sep 4, 2009 9:22:27 AM com.sun.appserv.naming.S1ASCtxFactory getCorbalocURL
INFO: corbaloc url ==> iiop:1.2@127.0.0.1:3700
ERROR: NameNotFoundException
null
B. MainTest CLASS CODE
Java Code:import javax.jms.ConnectionFactory; import javax.naming.Context; import javax.naming.InitialContext; import java.util.Properties; public class MainTest { static public void main (String[] args) { try { System.out.println("Attempting to instantiate InitialContext."); Context jndiContext = (Context) new InitialContext (prop); System.out.println("InitialContext instatiated: " + jndiContext.getClass().getSimpleName()); System.out.println("Attempting to lookup ConnectionFactory."); ConnectionFactory factory = (ConnectionFactory) jndiContext.lookup("jms/connectionFactory"); System.out.println("ConnectionFactory looked up: " + factory.getClass().getSimpleName()); } catch (Exception e){ System.out.println("ERROR: " + e.getClass().getSimpleName() + "\n" + e.getMessage()); } } // Define Property key:value pairs static private final Properties prop = new Properties (); static private final String [] keyValueArray = { "java.naming.factory.initial com.sun.appserv.naming.S1ASCtxFactory" ,"java.naming.factory.url.pkgs com.sun.enterprise.naming" ,"java.naming.provider.url : iiop://localhost:3700" //Tried and failed //"iiop://localhost:3700" //"iiop://localhost:4848" //"[http] ://localhost:8080" I had to bracket http //"[http] ://localhost:4848" because I can’t post “links” yet. ,"java.naming.factory.state : com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl" // ,"org.omg.CORBA.ORBInitialHost ????", Not sure if needed. Unsure of values // ,"org.omg.CORBA.ORBInitialPort 3700", Not sure if needed. // ,"com.sun.appserv.iiop.endpoints ????" Not sure if needed. Unsure of values }; // Load Property key:value pairs static { for (int indx = 0; indx < keyValueArray.length; indx++) { String key = keyValueArray[indx].substring(0, keyValueArray[indx].indexOf(' ')); String value = keyValueArray[indx].substring(keyValueArray[indx].lastIndexOf(' ') + 1); System.out.println(key + "=" + value); prop.put(key, value); } System.out.println("Property key:value pairs successfully loaded."); } }
- 09-04-2009, 09:25 PM #2
Member
- Join Date
- Sep 2009
- Posts
- 2
- Rep Power
- 0
Opps ... my definition of
static private final String [] keyValueArray
looks funny, because some pairs are seperated by spaces and some by ":".
It doesn't matter (see output). However, for esthetics, it should look like:
Java Code:static private final String [] keyValueArray = { "java.naming.factory.initial : com.sun.appserv.naming.S1ASCtxFactory" ,"java.naming.factory.url.pkgs : com.sun.enterprise.naming" ,"java.naming.provider.url : iiop://localhost:3700" //Tried and failed //"iiop://localhost:3700" //"iiop://localhost:4848" //"[http]://localhost:8080" //"[http]://localhost:4848" ,"java.naming.factory.state : com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl" // ,"org.omg.CORBA.ORBInitialHost ????", Not sure if needed. Unsure of values // ,"org.omg.CORBA.ORBInitialPort 3700", Not sure if needed. // ,"com.sun.appserv.iiop.endpoints ????" Not sure if needed. Unsure of values };
Similar Threads
-
About Application Server - Glassfish
By sathishscjp in forum Advanced JavaReplies: 1Last Post: 07-30-2009, 03:51 AM -
ping error in glassfish
By tushar88 in forum Advanced JavaReplies: 0Last Post: 03-09-2009, 03:17 PM -
What d u use, Apache Tomcat or GlassFish? Why
By thom_ in forum New To JavaReplies: 0Last Post: 03-05-2009, 11:14 PM -
Integrate JOSSO with Glassfish
By Kavitha Kamath in forum New To JavaReplies: 0Last Post: 11-12-2008, 09:59 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks