LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Can't locate ejb via jndi - Please help (https://www.linuxquestions.org/questions/programming-9/cant-locate-ejb-via-jndi-please-help-417375/)

dickgregory 02-19-2006 11:23 PM

Can't locate ejb via jndi - Please help
 
First the vitals:

Mandrive Linux 2006
1GB memory
J2SE 1.5
J2EE / SJSAS 1.4.2

The bean (Bean1) was deployed by Netbeans and shows up on SJSAS console.

The code:

try {
Context initial = new InitialContext();
Context myEnv = (Context)initial.lookup("java:comp/env");
Object obj = myEnv.lookup("ejb/Bean1");
HelloRemoteHome home = (HelloRemoteHome) javax.rmi.PortableRemoteObject.narrow(obj, HelloRemoteHome.class);
HelloRemote hello = home.create();
Heading.setText(hello.Hello());
hello.remove();
}
catch (javax.naming.NameNotFoundException ex) {
Error1.setText("Could not locate context");
Error2.setText(ex.getMessage());
}
catch (Exception ex) {
Error1.setText("System error locating bean");
Error2.setText(ex.getMessage());
}

The error messages are "Could not locate context"
and "No object bound for java:comp/env"

So it is apparent that it only got to the second line with the try block. The code up to that point is identical to that in the Sun tutorial. I have tried 3 different tutorials and all give similar results from slightly different code variations.

I am running this on localhost. Is there something I am supposed to do to point it to the server machine? None of the turorials are very clear about how to do this.

I'm new to J2EE, but not new to Java. If someone can point me in the right direction I would really appreciate it.

mrcheeks 02-21-2006 05:31 PM

I never read a lot about Java Entreprise Edition but i think you can configure jndi properties. Your initialContext is a kind of hashmap, and there must be a property you can set like.
initialContext.put("jndi.host", "http://hostnameLikeLocalHost:tcpPortNumber/service");

Try reading a lit bit more on j2ee and ejb in general.


All times are GMT -5. The time now is 01:04 PM.