• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

HF-EJB - initial context in chapter 1

 
Bear Giles
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, I'm going through the "hello world" -- I mean "advisor" -- program in chapter one to verify I have the complete toolset.

Everything is cool until I try to run the client. I get a javax.naming.NoInitialContextException. I expected this since it's being run directly and I didn't see anything setting up the JNDI environment.

Did I miss something, or is it an oversight in the book. I'm used to setting up the JNDI information in a web container, but this is the first time I've had to set up an EJB container.
 
Balaji Anand
Ranch Hand
Posts: 146
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
this is how changed it when i faced problem

Properties p = new Properties();
p.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.cosnaming.CNCtxFactory");
p.put(Context.PROVIDER_URL, "iiop://localhost:3700");

Context ic = new InitialContext(p);

Please update if it helps.
 
Bear Giles
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks. I needed port 1050 instead of port 3700 -- you would expect those properties to be easily found in documentation! I get a "no connection" message on port 3700.

I can now get past the lookup and 'narrow'.

But when I try to call home.create() I get "java.rmi.AccessException: CORBA NO_PERMISSION 0 No" and "vmcid: 0x0 minor code: 0 completed: no" messages. It also happens when I try running the app as root.
 
SL Narasimhan
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Use the code given in HeadFirst but have asppserv-rt.jar in ur classpath. That's all. It works fine. Reason is SerialInitialContext Factory is located in appserv-rt.jar.

Cheers,
 
Bear Giles
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I couldn't find that system (or something with a similar name) anywhere on my system. Ditto any 1.3 jar file containing that classname.
 
Bear Giles
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I spoke too quickly -- I hadn't found it when I looked under /, but it was in the 1.4 appserver library.

Unfortunately I still get the NO_PERMISSION error with both InitialContext() and InitialContext(p).
 
SL Narasimhan
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi There,

Well I didn't tell u that I ran my code in 1.4. All you need to do is compile the code as it is and execute the following comand

java -cp .;<SUN_HOME>/AppServer/lib/appserv-rt.jar AdviceHome

where <SUN_HOME> refers to your installation directory. Then the code works fine. If you find any issues just paste the logs.

Cheers,
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic