File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes EJB Certification (SCBCD/OCPJBCD) and the fly likes Problem with Chap 1 AdviceBean in HF-EJB Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » EJB Certification (SCBCD/OCPJBCD)
Bookmark "Problem with Chap 1 AdviceBean in HF-EJB" Watch "Problem with Chap 1 AdviceBean in HF-EJB" New topic

Problem with Chap 1 AdviceBean in HF-EJB

Songxun Lin

Joined: Jan 01, 2005
Posts: 4
Hi, folks,

Sorry for asking this question, as the similar question was posted before! However, as I searched through all the posts regarding the question, I still CANNOT find the solution.

I followed the steps in Chapter 1 for running the AdviceClient example, in the following environment:
1)J2SDK 1.5
2)J2EE SDK 1.4 and Sun Java Application Server v8
3)XP pro

And I was reported the following error:

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

I had tried several suggestions regarding the same problem posted in the forum, none of which is working for me!
1) Provide the interpreter java with j2ee.jar file and other archive files
java -cp c:\AppServer\lib\j2ee.jar;AdviceAppClient.jar;. AdviceClient

Note c:\AppServer\ is J2EE SDK 1.4 directory

2) Change getAdvice to getMessage posted on the following link:

3) Provide properties in a file
4)Hard-code properties in the AdviceClient

Here is my question:

MUST I use J2EE SDK 1.3 in order to run the example? However, the link for downloading j2EE SDK 1.3 or 1.3.1 is down currently.

But I think J2EE 1.4 should be able to run the example, which I cannot do it.

Any ideas? Thanks in advance!!!


[ February 08, 2005: Message edited by: Songxun Lin ]

SCJP 1.4 SCWCD 1.4
ash ok

Joined: Jan 24, 2005
Posts: 1

This solution is specific for Sun App Server-8. To solve this exception " javax.naming.NoInitialContextException ", you have to specify a resource for java.naming.factory.initial

To do that just add appserv-rt.jar in the Sun\AppServer\lib folder to your classpath.

This jar has file, which specifies the value for

If you are using some other server, just find the file and add it to your classpath.., that'll solve ur problem.

Hope this helps...
Songxun Lin

Joined: Jan 01, 2005
Posts: 4

Thanks Ash, ur solution really works!

BTW, I want to tell other persons who may encountered the same problem. If there are more than one files in your classpath, make sure the appserv-rt.jar is put in the first position. Otherwise, other files which might contain "uncorrect" properties will be retrieved instead of the "correct" one.

Before Ash told me, I imported all the jar files from AppServer\lib, and the result is error!!!

Thanks Ash!!!

[ February 10, 2005: Message edited by: Songxun Lin ]
I agree. Here's the link:
subject: Problem with Chap 1 AdviceBean in HF-EJB
jQuery in Action, 3rd edition