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 call with websphere 6 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 call with websphere 6" Watch "EJB call with websphere 6" New topic

EJB call with websphere 6

Thomas Fourest

Joined: Mar 27, 2006
Posts: 5
I try to call an .ear on my websphere 6.
it 's deployed with the following properties:

Module | EJB | EJB URI | Nom JNDI
T9AS | CallServer | t9as-fw.jar,META-INF/ejb-jar.xml | T9AS

and I have the following problem:

java.lang.ClassCastException: Unable to load class: com.itnsa.fw.server.interfaces._CallServerHome_Stub
at javax.rmi.PortableRemoteObject.narrow(
at TestAppelEjb.<init>(
at TestAppelEjb.main(

(I don't understand why I have a stub problem with the EJB abstraction: why the ibm can do that to me ;-)
other information:
-I use JDK 1.5
-I have configured a "JDBC provider" on my websphere and it's working (the websphere 's console 's test is good)

my client code:

String URLParam = "iiop://localhost:2809";
String contextParam = "";
String securityParam = "TFT";
String credentialParam = "Tttttt2";
String appelParam = "T9AS"; //"CallServer";

Properties env = new Properties();
env.setProperty(Context.PROVIDER_URL, URLParam);
env.setProperty("", credentialParam);

try {

InitialContext ctx = new InitialContext(env);
Object home = ctx.lookup(appelParam);
/******* my great problem **********/

Object o = PortableRemoteObject.narrow(home, CallServerHome.class);
CallServerHome clientHome = (CallServerHome) o;

CallServer client = (CallServer) PortableRemoteObject.narrow(clientHome.create(),CallServer.class);

/***** my dream *******/ client.executeExterne();

} catch(NamingException ne) {
System.err.println("Essai failed to lookup");
catch (Exception e)

thanks for your help,
Thomas Fourest

Joined: Mar 27, 2006
Posts: 5
sorry I was mistaken in the first post:


my client import :
import java.util.*;
import java.sql.*;
import javax.naming.*;
import javax.rmi.*;
import java.lang.reflect.*;
import javax.ejb.CreateException;

import com.*****.fw.iop.*;
import com.*****.fw.server.interfaces.CallServer;
import com.*****.fw.server.interfaces.CallServerHome;
import com.*****;
Roger Chung-Wee
Ranch Hand

Joined: Sep 29, 2002
Posts: 1683
It looks as if the stub class (generated by Websphere) of CallServerHome is not on the client's classpath.

SCJP 1.4, SCWCD 1.3, SCBCD 1.3
Thomas Fourest

Joined: Mar 27, 2006
Posts: 5
Thanks for your help Roger .
" import com.itnsa.fw.server.interfaces.*; "
unfortunately it doesn't solve the problem.

I don't understand a fundamental process:
when we work with the RMI IIOP protocol (in the last versions of java's standard) , we have to create just a Stub for the client with the rmic command (is it true?).

I have written a little application in RMI this weekend and I had just to add a stub on the client side (if I have a good memory) and I succed.

But the problem with the EJB (I deploy an .ear on my websphere) is the following:
I build an .ear and I deploy it on my websphere.
I build a .jar for my client (for the dependencies).
this process don't allowed me to put an stub anywhere.

to solve my pb I create stub from my class in my eclipse workspace
set ROOT_DIR=.
set JAVA_HOME=C:\Program Files\IBM\WebSphere\AppServer\java\jre
set CLASSPOT = .; %ROOT_DIR%\Coplib\activation.jar; %ROOT_DIR%\Coplib\bsf.jar; %ROOT_DIR%\Coplib\bsh-2.0b2.jar; %ROOT_DIR%\Coplib\Common.jar;
rmic -iiop -classpath %CLASSPOT% com.itnsa.fw.server.interfaces.CallServerHome
(I works good)

I build my .jar and I put the "_CallServerHome_Stub.class" in the path referenced by the ERROR with Winrar (near the "CallServerHome")

It doesn't solve my problem. The ejb client want the stub

It is incredible: I had deployed (in januar) my .ear in Oracle Application Server and after a little work , it was good....

What can i do?
Thanks for your help .
Thomas Fourest

Joined: Mar 27, 2006
Posts: 5
My boss solve the problem :

when you deploy your .ear in websphere , it modifies the .jar included in the .ear with the stub class.

The pb is the following:
My client point on my locally .jar I have modify
the solution is to point on the .jar on websphere

I 'll try this solution

Thomas Fourest

Joined: Mar 27, 2006
Posts: 5
It 's working

thanks for your help.

Paul Michael
Ranch Hand

Joined: Jul 02, 2001
Posts: 697
Originally posted by Thomas Fourest:

when you deploy your .ear in websphere , it modifies the .jar included in the .ear with the stub class.


Thanks for the hint. I'm a newbie in Websphere and I'm beginning to wonder how I would be able to generate the client jar for stubs. This post saved me a lot of time. Thanks.

SCJP 1.2 (89%), SCWCD 1.3 (94%), IBM 486 (90%), SCJA Beta (96%), SCEA (91% / 77%), SCEA 5 P1 (77%), SCBCD 5 (85%)
jQuery in Action, 3rd edition
subject: EJB call with websphere 6
It's not a secret anymore!