This week's book giveaway is in the OCAJP forum.
We're giving away four copies of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) and have Khalid A Mughal & Rolf W Rasmussen on-line!
See this thread for details.
Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

EJB call with websphere 6

 
Thomas Fourest
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 com.ibm.rmi.javax.rmi.PortableRemoteObject.narrow(PortableRemoteObject.java:366)
at javax.rmi.PortableRemoteObject.narrow(PortableRemoteObject.java:157)
at TestAppelEjb.<init>(TestAppelEjb.java:153)
at TestAppelEjb.main(TestAppelEjb.java:30)

(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 = "com.ibm.websphere.naming.WsnInitialContextFactory";
String securityParam = "TFT";
String credentialParam = "Tttttt2";
String appelParam = "T9AS"; //"CallServer";

Properties env = new Properties();
env.setProperty(Context.PROVIDER_URL, URLParam);
env.setProperty(Context.INITIAL_CONTEXT_FACTORY,contextParam);
env.setProperty("java.naming.security.principal",securityParam);
env.setProperty("java.naming.security.credentials", 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");
ne.printStackTrace(System.err);
}
}
catch (Exception e)
{
e.printStackTrace();
}

thanks for your help,
Thomas
 
Thomas Fourest
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
sorry I was mistaken in the first post:

I USED IBM JRE PROVIDE BY WEBSPHERE

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.*****.fw.services.CallServerBean;
 
Roger Chung-Wee
Ranch Hand
Posts: 1683
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It looks as if the stub class (generated by Websphere) of CallServerHome is not on the client's classpath.
 
Thomas Fourest
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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;
%ROOT_DIR%\Coplib\commons-collections-3.0.jar;
%ROOT_DIR%\Coplib\commons-dbcp-1.2.1.jar;
%ROOT_DIR%\Coplib\commons-io-1.0.jar;
%ROOT_DIR%\Coplib\commons-lang-2.0.jar;
%ROOT_DIR%\Coplib\commons-mail.jar;
%ROOT_DIR%\Coplib\commons-pool-1.2.jar;
%ROOT_DIR%\Coplib\db2fs.jar;
%ROOT_DIR%\Coplib\db2java.jar;
%ROOT_DIR%\Coplib\db2jcc.jar;
%ROOT_DIR%\Coplib\db2jcc_javax.jar;
%ROOT_DIR%\Coplib\db2jcc_license_cisuz.jar;
%ROOT_DIR%\Coplib\db2jcc_license_cu.jar;
%ROOT_DIR%\Coplib\db2policy.jar;
%ROOT_DIR%\Coplib\groovy-all-1.0-jsr-03.jar;
%ROOT_DIR%\Coplib\iText.jar;
%ROOT_DIR%\Coplib\jakarta-oro-2.0.8.jar;
%ROOT_DIR%\Coplib\jboss-j2ee.jar;
%ROOT_DIR%\Coplib\jdom.jar;
%ROOT_DIR%\Coplib\jt400.jar;
%ROOT_DIR%\Coplib\jtds-1.1.jar;
%ROOT_DIR%\Coplib\mail.jar;
%ROOT_DIR%\Coplib\mysql-connector-java-3.0.15-ga-bin.jar;
%ROOT_DIR%\Coplib\objectprofiler.jar;
%ROOT_DIR%\Coplib\ojdbc14.jar;
%ROOT_DIR%\Coplib\ooffice.jar;
%ROOT_DIR%\Coplib\QuickServer.jar;
%ROOT_DIR%\Coplib\xerces.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
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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

By,
Thomas
 
Thomas Fourest
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It 's working

thanks for your help.

Thomas
 
Paul Michael
Ranch Hand
Posts: 697
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Thomas Fourest:

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

By,
Thomas


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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic