• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

InitialContext problem in AdviceCleint

 
Nauman Khan
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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,
 
Roger Chung-Wee
Ranch Hand
Posts: 1683
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
Roger Chung-Wee
Ranch Hand
Posts: 1683
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 7729
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Nauman Khan
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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,
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic