wood burning stoves*
The moose likes EJB and other Java EE Technologies and the fly likes Problem of EJB module deploy & access 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 "Problem of EJB module deploy & access" Watch "Problem of EJB module deploy & access" New topic
Author

Problem of EJB module deploy & access

Mike Sever
Ranch Hand

Joined: Jul 24, 2006
Posts: 56
IBM WEBSPHERE APPLICATION SERVER, v. 6.0.2
1. install application[1]: one ear file includes one ejb module and web module[1]
2. install application[2]: one web module[2]
I can access ejb module by web module[1], but can NOT by web module[2], (see below exception when narrowing TestEJBHome). Is it due to they locating in different applications???
If true, I can not share the ejb module in two web modules, can I? That means I should bind web module with it as one application once I want to access ejb module.
Then can I access ejb module from a different machine (by modifying the ip of url when creating InitialContext)?

The below is the detailed infomation, jsp file and web.xml are same in web module[1] and web module[2], and the two class files TestEJB & TestEJBHome are archived as a jar file located in web module's lib folder.

---web module---
jsp file:


web.xml:


---ejb module---
ejb-jar.xml:


Error log:


Anyone who knows it helps me please, thanks a lot! (Waiting in sweat...)


<i>Mike</i>
Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 10102
    
165

Object ref = initCtx.lookup("java:comp/env/ejb/TestEJB");


You are looking up a local home object and *not* a remote one. So your code should look like:



[My Blog] [JavaRanch Journal]
Mike Sever
Ranch Hand

Joined: Jul 24, 2006
Posts: 56
Thanks for reply, but ...
1. Pls note: code in jsp file can run well in web module[1] which locates in the same application with ejb module, but exception occurs when called from web mdoule[2];
2. After using "TestEJBLocalHome testEJBLocalHome= (TestEJBLocalHome) ref;" in web module[1], it threw "Unable to load class: com.citigroup.apac.cpbol.middleware.test._TestEJBHome_Stub".

The configuration of calling remote object (web.xml, ejb-jar.xml) seems available and calling from web module within the same application works, but if that web module is not in the same application with ejb module, it seems NOT ...

I am not familiar with websphere at all. Previously in weblogic 8.1, I can just do below:
1. ear (including ejb module) under "Deployments\Applications"
2. web module[1], web module[2] under "Deployments\Web Application Modules"
And since global JNDI name can be access, ejb-jar.xml & weblogic-ejb-jar.xml are enough. Then, calling ejb from web module[1] and web module[2] are both ok.
Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 10102
    
165

[7/25/06 10:28:23:982 CST] 00000039 SystemErr R java.lang.ClassCastException


Looks like the classloader issue. Do you have the remote/local interface classes in 2 different jars? I guess, yes(one in jar files of webmodule[2] and one in jar files on ejb module[1]). If that's the case, do you have classloader isolation of the 2 applications. I *guess*, since the remote/local interface classes are being loaded by two different classloaders, you are seeing the ClassCastException. Just as a *temporary* test, remove the remote/local interfaces from one of the jars(ideally, webmodule[2]) and try out.

I am not aware about how Classloading isolation is achieved in Websphere, so am not able to pinpoint as to what exactly might be the issue.
Mike Sever
Ranch Hand

Joined: Jul 24, 2006
Posts: 56
scenario:
1. app1: ejb module, web module
2. app1: ejb module, web module[1]
app2: web module[2]
3. app1: ejb module
app2: web module[2]
I've reviewed the configuration of weblogic. All web module and ejb module are in the same application instance...
Then, in scenario 2 &3, accessing ejb module from web module[2] is not available because they are in different application instances, thus, the relevant stub class files generated in app1, can not be seen (in class loader of app2) in web module[2] in app2.
Thanks pai!
So, if web module[2] want to access ejb module in app1, adding it into ear of app1 should be a simple solution.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Problem of EJB module deploy & access