• 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
  • Tim Cooke
  • Devaka Cooray
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Martijn Verburg
  • Frits Walraven
  • Himai Minh

Error when accessing statefull session bean pg 219

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
From the client code

lookup
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 AdviceClient.go(AdviceClient.java:17)
at AdviceClient.main(AdviceClient.java:10)

This is my client code

import javax.naming.*;
import java.rmi.*;
import javax.rmi.*;
import headfirst.*;
import javax.ejb.*;

public class AdviceClient {

public static void main(String[] args){
new AdviceClient().go();
}

public void go() {
try {
Context ic = new InitialContext();
System.out.println(" lookup");
Object o = ic.lookup("AdvisorStateful");
System.out.println(" getting home");
AdviceHome home = (AdviceHome) PortableRemoteObject.narrow(o,AdviceHome.class);
System.out.println(" got home");
Advice advisor = home.create("clover");
System.out.println(advisor.getMessage());

}

catch (Exception ex)
{
ex.printStackTrace();
}
}

I got this from the sun-j2ee-ri.xml of the client jar I created using SUN RI
JNDI name is correct

<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE j2ee-ri-specific-information PUBLIC '-//Sun Microsystems Inc.//DTD J2EE Reference Implementation 1.3//EN' 'http://localhost:8000/sun-j2ee-ri_1_3.dtd'>

<j2ee-ri-specific-information>
<rolemapping />
<enterprise-beans>
<module-name>ejb-jar-ic.jar</module-name>
<unique-id>-798659632</unique-id>
<ejb>
<ejb-name>AdviceBean</ejb-name>
<b> <jndi-name>AdvisorStateful</jndi-name> </b>
<ior-security-config>
<transport-config>
<integrity>supported</integrity>
<confidentiality>supported</confidentiality>
<establish-trust-in-target>supported</establish-trust-in-target>
<establish-trust-in-client>supported</establish-trust-in-client>
</transport-config>
<as-context>
<auth-method>username_password</auth-method>
<realm>default</realm>
<required>false</required>
</as-context>
<sas-context>
<caller-propagation>supported</caller-propagation>
</sas-context>
</ior-security-config>
<gen-classes>
<remote-home-impl>headfirst.AdviceBean_RemoteHomeImpl</remote-home-impl>
<remote-impl>headfirst.AdviceBean_EJBObjectImpl</remote-impl>
</gen-classes>
</ejb>
</enterprise-beans>
</j2ee-ri-specific-information>


I am runing xp prof java 1.4. Did anyone get this error too ?

Laxmi V
 
Ranch Hand
Posts: 211
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This problem has been addressed here numerous times. Please do a search to see relevant posts in this forum.
 
Good night. Drive safely. Here's a tiny ad for the road:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic