Logo 
Search:

Java Forum

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds

NoInitialContextException

  Asked By: Carolina    Date: Nov 20    Category: Java    Views: 505
  

I'm trying to set up J2EE 1.4 with the Sun App Server on my home machine
for a testing
environment. I've got a tiny app that worked properly in 1.3 with the RI
which I don't seem
to be able to get to work on 1.4. I've noticed that the 1.4 Deploy Tool
seems to have built-in
naming conventions that I didn't see in 1.3, so I've followed those, but
I'm still crashing on my
JNDI lookup (I think). Here's the code in question:

Context initial = new InitialContext();
Object objref = initial.lookup("EjbLab1Bean");

The test fails on the second line with a NoInitialContextException but my
testing suggests
the problem is really with the first line because any other attempt to get
data from the
InitialContext also fails. I'm running J2EE 1.4 and Sun App Server 8. I've
checked the
JNDI name associated with the EJB I'm deploying, and it matches the above.
I'm using
the default server which is named domain1 and is running on localhost:4848.
I'm not
entirely sure if I'm logged into the server -- I know I'm logged in through
the deploytool,
and that says that my EJB is deployed and running, but I'm not sure how my
client
program is finding the proper server -- perhaps JNDI is doing that.

I'm also noticing that I can't run the RI as I've been doing in 1.3 --
trying to fire "j2ee -verbose"
gets me a "no such command" error at the Win XP command line.

Share: 

 

2 Answers Found

 
Answer #1    Answered By: Allan Bailey     Answered On: Nov 20

I tried to use the "Sun Java Studio Entrprise" to write my first ejb,
but I found this Exception

javax.naming.NoInitialContextException: Need to specify class name in
environment or system property, or as an applet parameter, or in an
application resource file: java.naming.factory.initial
at
javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:645)
at
javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:247)
at
javax.naming.InitialContext.getURLOrDefaultInitCtx(InitialContext.java:2\
84)
at javax.naming.InitialContext.lookup(InitialContext.java:351)
at mainApp.main(mainApp.java:42)


in That block of code:

Hashtable hp = new Hashtable();

hp.put("java.naming.factory.Initial","com.sun.jndi.cosnaming.CNCtxFactor\
y");
hp.put("java.naming.provider.url","iiop://localhost:3700");
Context context  = new InitialContext(hp);
Object ob = context.lookup("ejb/GoodsBean");

Could any one help me wz that error?

 
Answer #2    Answered By: Baylen Smith     Answered On: Nov 20

check the url:



HYPERLINK
"www.developer.com/.../10933_2215571_4"http://www.de
veloper.com/java/ent/article.php/10933_2215571_4

 
Didn't find what you were looking for? Find more on NoInitialContextException Or get search suggestion and latest updates.

Related Topics:




 
 
 

Related Post