• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Problem with Chap 1 AdviceBean in HF-EJB

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ]
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


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 ]
 
reply
    Bookmark Topic Watch Topic
  • New Topic