|
Hi Mark,
I faced something like this a few weeks back ...
though I was on JBoss/Tomcat.
According to what I read then, you need'nt
return new
InitialContext( p);
in your getInitialContext() .. a simple
return
new InitialContext();
should do.
Secondly, I really doubt whether your EJB Home has
been bound to "java:comp/env/ejb/CustomerHome" , maybe you should check your
logs to confirm where exactly it *has* been bound.
regards
Pramod Nair
----- Original Message -----
Sent: Tuesday, February 05, 2002 6:56
PM
Subject: JRun/JNDI Question
JRun's documentation sucks and it's code examples
use deprecated methods. Does anybody know the correct means to get a
JNDI reference to an EJB home interface from a servlet? I've tried most
everything, but what I got before pulling the rest of my hair out and quitting
is a servlet containing, in part:
Context jndiContext = getInitialContext(); Object ref =
jndiContext.lookup(
"java:comp/env/ejb/CustomerHome"); * * * public static Context
getInitialContext() throws NamingException { Properties
p = new Properties(); p.setProperty(
Context.PROVIDER_URL, "ejipt://192.168.0.1:8100");
p.setProperty( Context.INITIAL_CONTEXT_FACTORY,
"allair.ejipt.ContextFactory"); return new
InitialContext( p); }
The PROVIDER_URL is
the port for my JRun Server. The INITIAL_CONTEXT_FACTORY is what the documentation says is
correct, although there is an InitialContextFactory
class in another package. And the JNDI lookup is in the recommended
form. I've also tried the put() method of
Property. No matter what, ref is always
null.
A couple of interesting things: (1) I am not getting a NullPointerException (nor any other error) when calling
the servlet from a browser - just a page with some test HTML output from a
PrintWriter() statement prior to the JNDI
lookup; (2) assert always throws a
NullPointerException: assert ref ==
null; assert ref != null; assert
ref.equals( null);
I know this is happening because the Rams
lost the SB...Appreciate any insight(s) you guys may
have. Mark
|