File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes EJB and other Java EE Technologies and the fly likes EJB 2.1 Basics Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "EJB 2.1 Basics" Watch "EJB 2.1 Basics" New topic

EJB 2.1 Basics

Jayakrishnan.C Chandramohan

Joined: Aug 08, 2012
Posts: 11
Hi All,,,

Am new to ejb....... just i want to know how to establish the connection between two different machines. i.e) i have server code with two interfaces and session bean( am working ejb 2.1) remote and home.. i want to write my client code in a different machine..... so for that what should i do??? where should i mention the ip address and port etc. can anyone give the sample code for this or likely

Jayakrishnan Chandramohan
Ranganathan Kaliyur Mannar

Joined: Oct 16, 2003
Posts: 1101

First of all, I would like to know why you are using EJB 2.1. There have been 2 versions of EJB released after this (3.0, 3.1). EJB 3.1 is much easier, so, you should look to develop EJBs with 3.1

Secondly, normally EJBs are invoked from within web applications, typically servlets. With JEE 6, that would be much easier to do with Annotations.

Invoking a EJB from a Java client is possible, but will need some work to do. The client will need the EJB interfaces in the classpath.
Normally, you would do a JNDI lookup to the server to get the EJB which is done by creating a InitialContext object. The InitialContext class has an overloaded constructor which will take a Properties object.
You will need to populate this Properties object with the provider url (which will have the ip, portno and the protocol used). It will also need a context factory which will be app server specific.

Consider Paul's rocket mass heater.
subject: EJB 2.1 Basics
It's not a secret anymore!