• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Problem of EJB module deploy & access

 
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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...)
 
Sheriff
Posts: 10445
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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:

 
Mike Sever
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Sheriff
Posts: 10445
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

[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
Posts: 56
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic