By passing System.getProperties() into the InitialContext constructor,
you'll need to define the JNDI naming properties in the system
properties. Alternatively, you could use the no-arg InitialContext
constructor, which will attempt to find a jndi.properties file in the
CLASSPATH.
In general, the app can't find the class used as the
InitialContextFactory, which it's assuming is in the properties used to
construct the InitialContext.
Mike
--- Anders Dahlberg <[EMAIL PROTECTED]> wrote:
> Hello,
>
> I'm very new to j2ee and are trying to get my first app to run. I've
> written a stateless session bean and added it to an ear file and
> deployed this to application-deployments. when I try to run my
> HelloClient I gt the following error:
>
> C:\WINDOWS\Profiles\Anders\Visual Studio Projects\Hello>java
> hello.HelloClient
> 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(Unknown
> Source)
> at javax.naming.InitialContext.getDefaultInitCtx(Unknown
> Source)
> at javax.naming.InitialContext.getURLOrDefaultInitCtx(Unknown
> Source)
> at javax.naming.InitialContext.lookup(Unknown Source)
> at hello.HelloClient.main(HelloClient.java:14)
>
> /Anders
>
> // HelloClient.java:
> package hello;
>
> import javax.ejb.*;
> import javax.naming.*;
> import javax.rmi.*;
> import java.util.Properties;
>
> public class HelloClient{
>
> public static void main(String args[]){
> try{
> Properties props = System.getProperties();
> Context context = new InitialContext(props);
> java.lang.Object objref = context.lookup("HelloHome");
> HelloHome home = (HelloHome)PortableRemoteObject.narrow(objref,
> HelloHome.class);
>
> Hello hello = home.create();
>
> System.out.println(hello.hello());
> hello.remove();
> }catch(Exception e){
> e.printStackTrace();
> }
> }
> }
>
> // orion-application.xml
> <?xml version="1.0"?>
> <!DOCTYPE orion-application PUBLIC "-//Evermind//DTD J2EE Application
> runtime 1.2//EN"
> "http://www.orionserver.com/dtds/orion-application.dtd">
>
> <orion-application deployment-version="1.1.37">
> <ejb-module remote="false" path="HelloWorld.jar" />
> <client-module path="HelloClient.jar" deployment-time="e0d64eb260"
> auto-start="false" />
> <persistence path="persistence" />
> <principals path="principals.xml" />
> <log>
> <file path="application.log" />
> </log>
> <namespace-access>
> <read-access>
> <namespace-resource root="">
> <security-role-mapping>
> <group name="administrators" />
> </security-role-mapping>
> </namespace-resource>
> </read-access>
> <write-access>
> <namespace-resource root="">
> <security-role-mapping>
> <group name="administrators" />
> </security-role-mapping>
> </namespace-resource>
> </write-access>
> </namespace-access>
> </orion-application>
>
> // orion-ejb-jar.xml
> <?xml version="1.0"?>
> <!DOCTYPE orion-ejb-jar PUBLIC "-//Evermind//DTD Enterprise JavaBeans
> 1.1 runtime//EN" "http://www.orionserver.com/dtds/orion-ejb-jar.dtd">
>
> <orion-ejb-jar deployment-version="1.1.37"
> deployment-time="e0c7693860">
> <enterprise-beans>
> <session-deployment name="HelloHome" location="HelloHome"
> wrapper="HelloHome_StatelessSessionHomeWrapper19" timeout="10"
> persistence-filename="HelloHome" />
> </enterprise-beans>
> <assembly-descriptor>
> <default-method-access>
> <security-role-mapping impliesAll="true" />
> </default-method-access>
> </assembly-descriptor>
> </orion-ejb-jar>
>
>
__________________________________________________
Do You Yahoo!?
Kick off your party with Yahoo! Invites.
http://invites.yahoo.com/