Hello together.

I am new in the EJB subject and I try to perform a tutorial task in order to get started.

What I am trying to do is to call an enterprise bean from a standlone java client. Both the client and the bean are on the same machine.

I have a Windows 2000 machine on which I have installed the Sun Java™ System Application Server Platform Edition 8.1 2005Q1.

Here is the directory- & file structure which I have created in order to accomplish the task:

c:\eduproject
c:\eduproject\classes
c:\eduproject\classes\business
c:\eduproject\classes\presentation
c:\eduproject\deployment
c:\eduproject\java
c:\eduproject\java\business
c:\eduproject\java\business\converter
c:\eduproject\java\business\converter\Converter.java
c:\eduproject\java\business\converter\ConverterEJB.java
c:\eduproject\java\business\converter\ConverterHome.java
c:\eduproject\java\presentation
c:\eduproject\java\presentation\converter
c:\eduproject\java\presentation\converter\ConverterCient.java


Here is my java source code of the enterprise bean:

--------------------------------------------------
Converter.java:
--------------------------------------------------
package business.converter;
import javax.ejb.EJBObject;
import java.rmi.RemoteException;

public interface Converter extends EJBObject {
    public double dollarToYen(double dollars) throws RemoteException;
    public double yenToEuro(double yen) throws RemoteException;
}
--------------------------------------------------

--------------------------------------------------
ConverterEJB.java:
--------------------------------------------------
package business.converter;

import java.rmi.RemoteException;
import javax.ejb.SessionBean;
import javax.ejb.SessionContext;

public class ConverterEJB implements SessionBean {
    public double dollarToYen(double dollars) {
        return dollars * 121.6000;
    }
    public double yenToEuro(double yen) {
        return yen * 0.0077;
    }
    public ConverterEJB() {}
    public void ejbCreate() {}
    public void ejbRemove() {}
    public void ejbActivate() {}
    public void ejbPassivate() {}
    public void setSessionContext(SessionContext sc) {}
}
--------------------------------------------------

--------------------------------------------------
ConverterHome.java
--------------------------------------------------
package business.converter;
import java.io.Serializable;
import java.rmi.RemoteException;
import javax.ejb.CreateException;
import javax.ejb.EJBHome;

public interface ConverterHome extends EJBHome {
    Converter create() throws RemoteException, CreateException;
}
--------------------------------------------------


Having this situation, I perform the following steps:

==================== Step1: =======================
I start the application server by using
Start-Programs-Sun Microsystems-Application Server PE- Start Default Server

A Command Prompt Window comes up with the following content:

Starting Domain domain1, please wait.
Log redirected to C:\Sun\AppServer\domains\domain1\logs\server.log.
Domain domain1 is ready to receive client requests. Additional services are bein
g started in background.
Press any key to continue . . .


==================== Step2: =======================
I compile the enterprise bean code with the following bat file (which I execute within the directory c:\eduproject):

--------------------------------------------------
compileEJB.bat:
--------------------------------------------------
set J2EE_HOME=c:\Sun\AppServer
set SRCPATH=c:\eduproject\java\business\converter
set CLSPATH=c:\eduproject\classes
set CPATH=.;%J2EE_HOME%\lib\j2ee.jar
javac -d %CLSPATH% -classpath %CPATH% %SRCPATH%\ConverterEJB.java %SRCPATH%\ConverterHome.java %SRCPATH%\Converter.java


after compilation, I automatically receive the following class files:

c:\eduproject\classes\business\converter\Converter.class
c:\eduproject\classes\business\converter\ConverterEJB.class
c:\eduproject\classes\business\converter\ConverterHome.class


==================== Step3: =======================
By using the deployment tool of the application server,
(Start->Programs->Sun Microsystems->Application Server PE->Deploytool) I create a new J2EE application (named ConverterApp), I create a new enterprise bean (named ConverterBaen), assign the JNDI name "TheConverterBean" to the bean, place it into the application and deploy the application by giving C:\eduproject\deployment as "Application Client Stub Directory".

After this, I automatically receive the following files:

c:\eduproject\deployment\ConverterApp.ear
c:\eduproject\deployment\ConverterAppClient.jar


==================== Step4: =======================
I compile the java client code with the following bat file (which I execute within the directory c:\eduproject):

--------------------------------------------------
compileClient.bat
--------------------------------------------------
set J2EE_HOME=c:\Sun\AppServer
set SRCPATH=c:\eduproject\java\presentation\converter
set CLSPATH=c:\eduproject\classes
set CPATH=.;%J2EE_HOME%\lib\j2ee.jar;%CLSPATH%
javac -d %CLSPATH% -classpath %CPATH% %SRCPATH%\ConverterClient.java


after compilation, I automatically receive the following class:

c:\eduproject\classes\presentation\converter\ConverterClient.class

==================== Step5: =======================
I run the java client as standalone by executing the following bat file testClient.bat within the directory c:\eduproject:

--------------------------------------------------
testClient.bat
--------------------------------------------------
set J2EE_HOME=c:\Sun\AppServer
set CLSPATH=c:\eduproject\classes
set CPATH=.;%J2EE_HOME%\lib\j2ee.jar;c:\eduproject\deployment\ConverterAppClient.jar;%CLSPATH%
java -classpath %CPATH% presentation.converter.ConverterClient


This file results to the following command:

java -classpath .;c:\Sun\AppServer\lib\j2ee.jar;c:\eduproject\deployment\ConverterAppClient.jar;c:\eduproject\classes presentation.converter.ConverterClient

And here comes the following amazing error:

Caught an unxpected exception!
javax.naming.CommunicationException: Cannot connect to ORB. Root exception is o
rg.omg.CORBA.COMM_FAILURE: vmcid: SUN minor code: 208 completed: Maybe
        at com.sun.corba.se.internal.iiop.IIOPConnection.purge_calls(IIOPConnect
ion.java:438)
        at com.sun.corba.se.internal.iiop.ReaderThread.run(ReaderThread.java:70)


I don't know what to do; the client is not even ... remote (!!!).

Thank you in advance for any hint
Kostas