Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The link @Peter gave you almost solves your problem. (<a href="https://stackoverflow.com/questions/5681197/access-a-local-session-bean-from-another-ear">link</a>)</p> <p>One trick which needs to be done to solve @Xavier's problem is to provide common.jar to both ears in the same version (loaded by the same class loader). If you do it, the class cast exception will not be thrown and you will be able to use the ejb with local interface.</p> <p>To do it you need to put common.jar into glassfish/domains/domain1/lib folder (substitute domain1 with you domain name). This way this jar will be loaded by a Glassfish's shared class loader.</p> <p>I made a quick test with Eclipse and Glassfish 3 with following structure:</p> <pre><code>package com.example; JarShared - @Local class Server EarServer - EjbServer - @Stateless class ServerBean implements Server EarClient - EjbClient - @Stateless @LocalBean class ClientBean </code></pre> <p>Lookup from ClientBean:</p> <pre><code>InitialContext ic = new InitialContext(); Server server = (Server) ic. lookup("java:global/EarServer/EjbServer/ServerBean!com.example.Server"); </code></pre> <p>I did not get ClassCastException and I could call sample method from ServerBean.</p> <p>Important notes:</p> <ul> <li>both EarServer and EarClient should not contain JarShared in lib folder, they should reuse the one which is in domains lib folder</li> <li>remember to restart Glassfish after adding JarShared to it.</li> <li>to make both ejb projects compile you must add JarShared to their build paths, but nothing more</li> </ul> <p>If you have questions, post a comment.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload