aspose file tools*
The moose likes EJB Certification (SCBCD/OCPJBCD) and the fly likes InitialContext problem in AdviceCleint Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Certification » EJB Certification (SCBCD/OCPJBCD)
Bookmark "InitialContext problem in AdviceCleint" Watch "InitialContext problem in AdviceCleint" New topic
Author

InitialContext problem in AdviceCleint

Nauman Khan
Ranch Hand

Joined: Aug 07, 2003
Posts: 49
Hi,
Sorry to post this problem here but I desperately need the solution of it.
Here is my environment
OS=Window XP
J2EE SDK 1.2_beta because earlier version is not available for XP
J2SDK 1.4.2
I deployed advice bean successfully but when i run the bean through AdviceClient Client program it throws the following exception
java AdviceClient (After Compiled)

javax.naming.NoInitialContextException: Need to specify class name in environmen
t or system property, or as an applet parameter, or in an application resource f
ile: java.naming.factory.initial
at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:6
40)
at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:243
)
at javax.naming.InitialContext.getURLOrDefaultInitCtx(InitialContext.jav
a:280)
at javax.naming.InitialContext.lookup(InitialContext.java:347)
at AdviceClient.go(AdviceClient.java:19)
at AdviceClient.main(AdviceClient.java:11)


After getting this error,I included all the jar files in lib diretory in the CLASSPATH,then I again run my program and get following error
javax.naming.CommunicationException: Can't find SerialContextProvider
at com.sun.enterprise.naming.SerialContext.getProvider(SerialContext.jav
a:81)
at com.sun.enterprise.naming.SerialContext.lookup(SerialContext.java:138
)
at javax.naming.InitialContext.lookup(InitialContext.java:347)
at AdviceClient.go(AdviceClient.java:27)
at AdviceClient.main(AdviceClient.java:12)

I used other program to investigate the problem

import javax.naming.*;
import java.io.*;
import java.util.*;
public class test {
public static void main(String[] args) throws Exception{
Context ctx = new InitialContext();
Hashtable env = ctx.getEnvironment();
System.out.println(env.toString());
}}

it results
{java.naming.corba.orb=com.sun.corba.ee.impl.orb.ORBImpl@ad8659}
I did check this in JBoss 3.2.2 and getting the same problem,earlier i was using it in Windows 2000 professional and it was working really fine but now I'm stuck in window XP and I believe Advive is really a normal bean which could run in any j2ee version so i think this is not the j2ee version problem or not a classpath problem because i have included all jar's.
So please anybody know the solution or comment, I really appreciate.
Regards,


Nauman Khan <br />SCJP,MCSE,SCWCD,SCBCD,SCWCD1.4
Roger Chung-Wee
Ranch Hand

Joined: Sep 29, 2002
Posts: 1683
Resurrecting this ...
I'm getting the same problem in trying to run AdviceClient on XP. Here's the output from my script file:

JAVA_HOME = D:\jdk1.3.1_09
J2EE_HOME = D:\j2sdkee1.3.1
CLASSPATH = C:\projects\advice;C:\projects\advice\classes;C:\projects\advice\AdvisorAppClient.jar
javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet pa
rameter, or in an application resource file: java.naming.factory.initial
at javax.naming.spi.NamingManager.getInitialContext(Unknown Source)
at javax.naming.InitialContext.getDefaultInitCtx(Unknown Source)
at javax.naming.InitialContext.getURLOrDefaultInitCtx(Unknown Source)
at javax.naming.InitialContext.lookup(Unknown Source)
at com.caribbeanaviation.AdviceClient.go(AdviceClient.java:16)
at com.caribbeanaviation.AdviceClient.main(AdviceClient.java:31)

The only real differences in my code compared to the book is that I've changed getAdvice() to getSomething() as I suffered from the CORBA error and that I've got AdviceClient in a package (com.caribbeanaviation).
It seems as if the InitialContext class does not have properties for the JNDI service. Is something missing from the book?
[ December 07, 2003: Message edited by: Roger Chung-Wee ]

SCJP 1.4, SCWCD 1.3, SCBCD 1.3
Roger Chung-Wee
Ranch Hand

Joined: Sep 29, 2002
Posts: 1683
Problem solved by placing j2ee.jar on the classpath ...
You need this file as it has the jndi.properties file in it, with these entries:

java.naming.factory.initial=com.sun.enterprise.naming.SerialInitContextFactory
java.naming.factory.url.pkgs=com.sun.enterprise.naming

[ December 07, 2003: Message edited by: Roger Chung-Wee ]
Barry Gaunt
Ranch Hand

Joined: Aug 03, 2002
Posts: 7729
J2EE SDK 1.2_beta because earlier version is not available for XP

You must use j2sdk1.3.1. It is available for Windows 2000, I'm using it on XP without problems.
Get the 1.3.1 FCS from here.


Ask a Meaningful Question and HowToAskQuestionsOnJavaRanch
Getting someone to think and try something out is much more useful than just telling them the answer.
Nauman Khan
Ranch Hand

Joined: Aug 07, 2003
Posts: 49
I solved this problem 10 days before because there was a classpath issue in it,because this problem occurs when you call the EJB through client.So,Client has a connection issue with the server in which obviously we miss the right jar file in the classpath and also the jndi setting as you mentioned above.When i was solving this issue,I saw lots of messages but not with a right solution and in the initial stage,it wastes your lot of time.
As for J2EE 1.3 RI is not supported with XP version and I downloaded but it's not being installed that's why i moved to 1.4 version
Regards,
 
 
subject: InitialContext problem in AdviceCleint