> Where can I find a J2EE tutorial that demonstrates a remote client
> accessing an EJB? The Sun tutorial are all localized examples. Does a
> remote client have to run on a J2EE server?
No. You only need the corresponding J2EE classes in your CLASSPATH.
-marek
> Where can I find a J2EE tutorial that demonstrates a remote client
> accessing an EJB?
What's the Problem?
Properties p = new Properties();
p.put(...); [*]
Context ctxt = new InitialContext(p);
Object o = ctxt.lookup("java:comp/ejb/Bla");
BlaHome home = (BlaHome) PortableRemoteObject.narrow(o, BlaHome.class);
Bla b = home.create();
[*] Check your Appservers documentation.
Johann
> Brauchst du Wissensmanagement-Lösungen? Aus einer Hand?
Was aus einer Hand kommt, klebt entweder, oder es stinkt.
(ich und Guido Hennecke in <slrnbi0msv.14u.gh@usenet.kicks-a.s.org>)
Christian Friedl - 18 Nov 2003 12:28 GMT
>> Where can I find a J2EE tutorial that demonstrates a remote client
>> accessing an EJB?
[quoted text clipped - 11 lines]
>
> Johann
Concerning JBoss there's xml file specifying initial JNDI properties.
You can find it in the following directory:
[Jboss-install-dir]/server/default/conf/jndi.properties or put the
properties dynamically, as suggested.
Concerning a tutorial I recommend – “Mastering Enterprise Java Beans”,
which is freely available on theserverside.com. As far as I remember
there's also an example with remote clients, which of course do not have
to run on the J2EE server.
HTH,
Christian
Ray - 19 Nov 2003 23:51 GMT
When I run this code without using runclient I get the error:
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:640)
at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:243)
at javax.naming.InitialContext.getURLOrDefaultInitCtx(InitialContext.java:280)
at javax.naming.InitialContext.lookup(InitialContext.java:347)
at ConverterClient.main(ConverterClient.java:22)
I am executing this on a remote machine. How do I get a context
instance remotely?
Thanks,
-Ray
> > Where can I find a J2EE tutorial that demonstrates a remote client
> > accessing an EJB?
[quoted text clipped - 12 lines]
>
> Johann
Christian Friedl - 20 Nov 2003 08:28 GMT
> When I run this code without using runclient I get the error:
>
[quoted text clipped - 13 lines]
>
> -Ray
As your running your client on a remote machine, you have to specify
JNDI properties. The vendor's manual contains the required options.
Concerning JBoss the XML File I mentioned in this thread does this job.
One possibility is to copy this file to your remote machine and
dynamically load by means of a FileInptStream.
Properties myProps = new Properties();
Properties sysProps = System.getProperties();
try {
myProps.load(new FileInputStream("c://JNDI.properties"));
sysProps.putAll(myProps);
System.setProperties(sysProps);
} catch (Exception ex) {
ex.printStackTrace();
}
try {
//get naming context
Context context = new InitialContext();
Of course you have to set up the right URL to the naming provider,
which’s your app server IP.
HTH,
Christian