dcsimg
InitialContext from standalone client app contains different bindings from InitialContext got without env parameter. Why?
0 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Michael_Chigrichenko
Posted On:   Monday, July 30, 2007 10:30 AM

Hello, good people! The problem I have (in my opinion) is that I cannot access the JNDI context where my Sun Application Server 9 stores references to EJB3 beans but instead I access some part of it or something else. I am going through chapter 21 of the J2EE 5 tutorial "Getting stated with Enterprice Beans"(http://java.sun.com/javaee/5/docs/tutorial/doc/EJB2.html#wp79824) where you construct the ConverterBean. I compile the bean and deploy it on the server successfully as an EJB module. Then I deploy a standalone webapp with my own servlet accessing the EJB like this: Context c = new InitialContext(); Converter conv = (Converter)c.lookup(myPair.getName()); logge   More>>

Hello, good people!

The problem I have (in my opinion) is that I cannot access the JNDI context where my Sun Application Server 9 stores references to EJB3 beans but instead I access some part of it or something else.




I am going through chapter 21 of the J2EE 5 tutorial "Getting stated with Enterprice Beans"(http://java.sun.com/javaee/5/docs/tutorial/doc/EJB2.html#wp79824) where you construct the ConverterBean. I compile the bean and deploy it on the server successfully as an EJB module. Then I deploy a standalone webapp with my own servlet accessing the EJB like this:




Context c = new InitialContext();
Converter conv = (Converter)c.lookup(myPair.getName());
logger.debug(" $100 = " + conv.dollarToYen(new BigDecimal("100")) + " Yen");




myPair.getName() returns the fully qualified class name of the BusinessInterface: converter.ejb.Converter



And it works with no problem. But when I try to access the bean from a standalone client with the following code, the JNDI context does not contain the converter.ejb.Converter name:




Properties p = new Properties();p.setProperty(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.cosnaming.CNCtxFactory");
p.setProperty(Context.PROVIDER_URL, "iiop://localhost:3700");
p.setProperty("javax.rmi.CORBA.UtilClass", "com.sun.corba.ee.impl.javax.rmi.CORBA.Util");
p.setProperty("org.omg.CORBA.ORBClass", "com.sun.corba.ee.impl.orb.ORBImpl");
p.setProperty("org.omg.CORBA.ORBSingletonClass", "com.sun.corba.ee.impl.orb.ORBSingleton");



I added the last three properties because I read in Sun's java forum that I should. And I also should add appserv-rt.jar to my classpath, which I have also done. The context did not contain my EJB reference.



The strange thing is, that when I list the names of the bindings contained in the context in my servlet I get the following output:



NamingEnumeration list = context.list("");



and then iterate and print the NameClassPairs' names, I get these results:



UserTransaction

converter.ejb.Converter#converter.ejb.Converter

converter.ejb.Converter__3_x_Internal_RemoteBusinessHome__

jdbc

__SYSTEM

ejb

converter.ejb.Converter



When I run the same code on the standalone client, I get:


SerialContextProvider

converter.ejb.Converter__3_x_Internal_RemoteBusinessHome__

ejb



Is the context factory used by the Sun AppServer 9 different from com.sun.jndi.cosnaming.CNCtxFactory? What should I do to access my bean from a standalone client?    <<Less
About | Sitemap | Contact