• Post Reply Bookmark Topic Watch Topic
  • New Topic

EJB Local home lookup - URGENT  RSS feed

 
Ernest Lee
Ranch Hand
Posts: 145
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am trying to access an EJB thru Local Home (in a separate jar file) from an Webapp (in a war file)?
But so far, I have no luck, the lookup keep failing!!

Is this possible to achieve at all?

thanks!
 
Ernest Lee
Ranch Hand
Posts: 145
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
More details:

in the web.xml
<ejb-local-ref>
<ejb-ref-name>ejb/SessionEJB</ejb-ref-name>
<ejb-ref-type>Session</ejb-ref-type>
<local-home>ejb.SessionEJBLocalHome</local-home>
<local>ejb.SessionEJBLocal</local>
<ejb-link>SessionEJB</ejb-link>
</ejb-local-ref>


then in the ejb-jar.xml, I have

<session>
<display-name>SessionEJB</display-name>
<ejb-name>SessionEJB</ejb-name>
<local-home>ejb.SessionEJBLocalHome</local-home>
<local>ejb.SessionEJBLocal</local>
<ejb-class>ejb.SessionEJBBean</ejb-class>
<session-type>Stateless</session-type>
<transaction-type>Container</transaction-type>
</session>


the web app and ejb are in separate jaf files (war and jar, not packaged up in ear)....

When I deploy the Web App, it keeps complaining:

weblogic.deployment.EnvironmentException: [J2EE:160101]Error: The ejb-link 'SessionEJB' declared in the ejb-ref or ejb-local-ref 'ejb/SessionEJB' in the application module 'sessio
Test.war' could not be resolved. The target EJB for the ejb-ref could not be found. Please ensure the link is correct.]
 
Dilip Karki
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The reason why it doesn't work when you deploy war and jar separately (as opposed to deploying withinn the same ear file) is due to the way WebLogic has its classloader hierarchy. Heres a link which tells you more:

http://e-docs.bea.com/wls/docs81/programming/classloading.html#1073491

I would suggest deploying as an ear (which would contain the war and jar). In addition to resolving your problem, you may actually improve your performance as well.
 
Ernest Lee
Ranch Hand
Posts: 145
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How does classloader effect EJB lookup?
 
Chris Mathews
Ranch Hand
Posts: 2712
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Ernest Lee:
How does classloader effect EJB lookup?

Well, for one the J2EE Specification mandates that components should only be able to access local ejbs that are packaged in the same ear. Therefore, if you want to access your local ejbs from your war then you must package them together in an ear deployment.

Most problems that people have with J2EE packaging and deployment are related directly to classloading. In fact, many problems that people have with Java in general are related to classloading. So yes, classloaders definitely play a big role in J2EE.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!