K
kevin wright
Hi Guys
I'm trying to create a Simple EJB application based on Ed Romans Mastering EntepriseJava beans.
So far I have:
1. Downloaded and installed J2EE
2. Written an compiled The Remote interface, the local interface, the Home interface, the local home interface
and the bean itself.
3. Created the deployment description in xml.
4. jarred the deployment descriptor and class files into an ejb-jar file.
5. Deployed the jar file
6. Startup up the ejb server.
Now my problems start when I try to run some client code:
package examples;
import javax.naming.Context;
import javax.naming.InitialContext;
import java.util.Properties;
public class HelloClient{
public static void main(String[] args) throws Exception{
System.out.println("start of program");
Properties props = System.getProperties();
Context ctx = new InitialContext(props);
Object obj = ctx.lookup("HelloHome");
HelloHome home = (HelloHome) javax.rmi.PortableRemoteObject.narrow(
obj, HelloHome.class);
Hello hello = home.create();
System.out.println( hello.hello() );
hello.remove();
}
}
Code compiles but when I try to run it like this:
java -classpath /home/kevin/SUNWappserver/lib/j2ee.jar:. examples.HelloClient
I Get:
start of program
Exception in thread "main" 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
at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:645)
at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:247)
at javax.naming.InitialContext.getURLOrDefaultInitCtx(InitialContext.java:284)
at javax.naming.InitialContext.lookup(InitialContext.java:351)
at examples.HelloClient.main(HelloClient.java:16)
Please can you tell me why the code doesn't run?
Kevin Wright.
I'm trying to create a Simple EJB application based on Ed Romans Mastering EntepriseJava beans.
So far I have:
1. Downloaded and installed J2EE
2. Written an compiled The Remote interface, the local interface, the Home interface, the local home interface
and the bean itself.
3. Created the deployment description in xml.
4. jarred the deployment descriptor and class files into an ejb-jar file.
5. Deployed the jar file
6. Startup up the ejb server.
Now my problems start when I try to run some client code:
package examples;
import javax.naming.Context;
import javax.naming.InitialContext;
import java.util.Properties;
public class HelloClient{
public static void main(String[] args) throws Exception{
System.out.println("start of program");
Properties props = System.getProperties();
Context ctx = new InitialContext(props);
Object obj = ctx.lookup("HelloHome");
HelloHome home = (HelloHome) javax.rmi.PortableRemoteObject.narrow(
obj, HelloHome.class);
Hello hello = home.create();
System.out.println( hello.hello() );
hello.remove();
}
}
Code compiles but when I try to run it like this:
java -classpath /home/kevin/SUNWappserver/lib/j2ee.jar:. examples.HelloClient
I Get:
start of program
Exception in thread "main" 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
at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:645)
at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:247)
at javax.naming.InitialContext.getURLOrDefaultInitCtx(InitialContext.java:284)
at javax.naming.InitialContext.lookup(InitialContext.java:351)
at examples.HelloClient.main(HelloClient.java:16)
Please can you tell me why the code doesn't run?
Kevin Wright.