Hi There
I've got a JNDI problem...I've written a very small ejb session bean..and sucessfully installed it onto orion...I've written a seperate client (stand alone) and got the initial context working. Whenever I try to lookup my bean, I get the following exception...
javax.naming.NamingException: java:comp/env namespace is only available from wit
hin a J2EE component
at com.sun.enterprise.naming.java.javaURLContext.getComponentContext(jav
aURLContext.java:392)
at com.sun.enterprise.naming.java.javaURLContext.lookup(javaURLContext.j
ava:51)
at javax.naming.InitialContext.lookup(InitialContext.java:354)
at ejbtest.DemoClient.main(DemoClient.java:29)
at java.lang.reflect.Method.invoke(Native Method)
at com.borland.jbuilder.util.BootStrap.invokeMain(Unknown Source)
at com.borland.jbuilder.util.BootStrap.main(Unknown Source)
Please help me on this problem.... Here is my client source:
package ejbtest;
import javax.ejb.*;
import javax.naming.*;
import javax.naming.spi.*;
import java.rmi.*;
import java.util.Properties;
import com.evermind.ejb.*;
import com.evermind.naming.*;
import java.io.*;
public class DemoClient {
static String user = "admin";
static String password = "admin";
static String url = "ormi://localhost/";
public static void main(String[] args) {
System.out.println("\nBegin DemoClient...\n");
parseArgs(args);
try {
// Context ctx = getInitialContext();
DemoHome fssh;
System.out.println("Initial context");
Context ctx = getInitialContext();
System.out.println("Initial context");
System.out.println("Looking up");
fssh = (DemoHome) ctx.lookup("java:comp/env/demo");
System.out.println("Creating Demo\n");
Demo demo = fssh.create();
System.out.println("The result is " + demo.demoSelect());
}
catch (Exception e) {
System.out.println(" => Error <=");
e.printStackTrace();
}
System.out.println("\nEnd DemoClient...\n");
}
static void parseArgs(String args[]) {
if ((args == null) || (args.length == 0)) return;
for (int i = 0; i < args.length; i++) {
if (args[i].equals("-url")) url = args[++i];
else if (args[i].equals("-user")) user = args[++i];
else if (args[i].equals("-password")) password = args[++i];
}
}
static public Context getInitialContext() throws Exception {
Properties p = new Properties();
p.put(Context.PROVIDER_URL, url);
p.put("host", "ormi://localhost/");
if (user != null) {
System.out.println ("user: " + user);
p.put(Context.SECURITY_PRINCIPAL, user);
if (password == null) password = "";
p.put(Context.SECURITY_CREDENTIALS, password);
p.put(Context.INITIAL_CONTEXT_FACTORY, "com.evermind.server.rmi.RMIInitialContextFactory");
// p.put("java.naming.factory.initial", "com.evermind.server.ApplicationClientInitialContextFactory");
}
return new InitialContext(p);
}
}
THANK YOU!!
----------------------------------------------------------------
MARTIN COETZEE - The talent to make it happen
Java Programmer - CCH (FutureJ)
Email: [EMAIL PROTECTED] (work)
[EMAIL PROTECTED] (personal)
Tel: 082-9033416 (Mobile)
082-1319033416 (Fax)
011-8043772 - ext 2219 (Work)
Homepage: http://www.crosswinds.net/~martincoetzee/
