Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / JavaBeans / November 2003

Tip: Looking for answers? Try searching our database.

J2EE Tutorial With Remote Client

Thread view: 
Ray - 13 Nov 2003 07:28 GMT
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?

Thanks,

-Ray
Marek Lange - 13 Nov 2003 09:10 GMT
> 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
Johann Burkard - 13 Nov 2003 17:38 GMT
> 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


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.