This week's book giveaway is in the Jobs Discussion forum.
We're giving away four copies of Soft Skills and have John Sonmez on-line!
See this thread for details.
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


Win a copy of Soft Skills this week in the Jobs Discussion forum!
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
Author

Problem with Chap 1 AdviceBean in HF-EJB

Songxun Lin
Greenhorn

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:
http://wickedlysmart.com/HeadFirst/HeadFirstEJB/HeadFirstEJBNotes.html

3) Provide properties in a JNDI.properties 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. http://java.sun.com/j2ee/sdk_1.3/

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

Any ideas? Thanks in advance!!!


Regards

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

SCJP 1.4 SCWCD 1.4
ash ok
Greenhorn

Joined: Jan 24, 2005
Posts: 1
Hi..,

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 jndi.properties file, which specifies the value for
java.naming.factory.initial.

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


Hope this helps...
Songxun Lin
Greenhorn

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 jndi.properties files in your classpath, make sure the appserv-rt.jar is put in the first position. Otherwise, other jndi.properties 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: http://aspose.com/file-tools
 
subject: Problem with Chap 1 AdviceBean in HF-EJB