Note that there are some explanatory texts on larger screens.

plurals
  1. POglassfish 3.1 jdni lookup on EJB3
    primarykey
    data
    text
    <p>I have the following Interfaces <strong>MyLocalBean, MyRemoteBean</strong> and the stateless <strong>MyBean</strong> <em>implements</em> MyLocalBean, MyRemoteBean Which of the following i don't need to get a simple java application to test this ...</p> <p><strong>ejb-jar.xml, glassfish-ejb-jar.xml, gf-client.jar</strong></p> <p>Here's ejb-jar.xml</p> <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;ejb-jar xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:ejb="http://java.sun.com/xml/ns/javaee/ejb-jar_3_0.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/ejb-jar_3_1.xsd" version="3.1"&gt; &lt;enterprise-beans&gt; &lt;session&gt; &lt;ejb-name&gt;MyEJB&lt;/ejb-name&gt; &lt;home&gt;test.ejb.MyLocalBean&lt;/home&gt; &lt;remote&gt;test.ejb.MyRemoteBean&lt;/remote&gt; &lt;ejb-class&gt;test.ejb.MyBean &lt;/ejb-class&gt; &lt;session-type&gt;Stateless&lt;/session-type&gt; &lt;transaction-type&gt;Container&lt;/transaction-type&gt; &lt;/session&gt; &lt;/enterprise-beans&gt; &lt;/ejb-jar&gt; </code></pre> <p>what's missing here? would i be able to lookup using MyEJB?</p> <p>and here's my lookup code</p> <pre><code>InitialContext ic; ic = new InitialContext(); MyRemoteBean remoteBean = (MyRemoteBean ) ic.lookup("java:comp/env/MyEJB"); </code></pre> <p>[EDIT]</p> <p>I've update the ejb-jar.xml as follows</p> <pre><code>&lt;enterprise-beans&gt; &lt;session&gt; &lt;ejb-name&gt;MyEJB&lt;/ejb-name&gt; &lt;ejb-class&gt;test.ejb.MyBean&lt;/ejb-class&gt; &lt;ejb-local-ref&gt; &lt;ejb-ref-name&gt;MyEJB&lt;/ejb-ref-name&gt; &lt;ejb-ref-type&gt;Session&lt;/ejb-ref-type&gt; &lt;local&gt;test.ejb.MyLocalBean&lt;/local&gt; &lt;ejb-link&gt;MyEJBClient.jar#MyEJB&lt;/ejb-link&gt; &lt;/ejb-local-ref&gt; &lt;/session&gt; &lt;/enterprise-beans&gt; </code></pre> <p>I get an error ...</p> <blockquote> <p>cannot Deploy MyBeanEAR Deployment Error for module: MyBeanEAR: Error occurred during deployment: Exception while deploying the app [MyBeanEAR] : Error: Unresolved : MyEJBClient.jar#MyEJB. Please see server.log for more details.</p> </blockquote> <p>[\EDIT]</p> <p>[EDIT]</p> <p>Hi bkail, let me brake down the problem using the correct names.. Initially, this is what my eclipse-sts IDE created by default</p> <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;ejb-jar xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:ejb="http://java.sun.com/xml/ns/javaee/ejb-jar_3_0.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/ejb-jar_3_1.xsd" version="3.1"&gt; &lt;display-name&gt;BatchOverrideEJB&lt;/display-name&gt; &lt;ejb-client-jar&gt;BatchOverrideEJBClient.jar&lt;/ejb-client-jar&gt; &lt;/ejb-jar&gt; </code></pre> <p>and this is how i tried accessing the EJB </p> <pre><code>Properties p = new Properties(); p.put("org.omg.CORBA.ORBInitialHost","localhost"); p.put("org.omg.CORBA.ORBInitialPort","3700"); InitialContext ctx = new InitialContext(p); ic = new InitialContext(p); BatchOverrideManagerRemote batchOverrideRemote = (BatchOverrideManagerRemote) ic.lookup("java:comp/env/BatchOverrideEJB"); </code></pre> <p>running this i got the following error </p> <pre><code>javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:645) at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:288) at javax.naming.InitialContext.getURLOrDefaultInitCtx(InitialContext.java:325) at javax.naming.InitialContext.lookup(InitialContext.java:392) at za.co.sanlam.batchovveride.test.BatchOverrideTester.main(BatchOverrideTester.java:33) </code></pre> <p>I thought this error meant that my EJB its not bound to the context, so i modified the ejb-jar.xml as follows</p> <pre><code>&lt;ejb-jar xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:ejb="http://java.sun.com/xml/ns/javaee/ejb-jar_3_0.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/ejb-jar_3_1.xsd" version="3.1"&gt; &lt;enterprise-beans&gt; &lt;session&gt; &lt;ejb-name&gt;BatchOverrideEJB&lt;/ejb-name&gt; &lt;ejb-class&gt;com.test.ejb.BatchOverrideManagerBean&lt;/ejb-class&gt; &lt;ejb-local-ref&gt; &lt;ejb-ref-name&gt;BatchOverrideEJB&lt;/ejb-ref-name&gt; &lt;ejb-ref-type&gt;Session&lt;/ejb-ref-type&gt; &lt;local&gt;com.test.batchoverridemanager.ejb.BatchOverrideManagerLocal&lt;/local&gt; &lt;ejb-link&gt;BatchOverrideEJB&lt;/ejb-link&gt; &lt;/ejb-local-ref&gt; &lt;/session&gt; &lt;/enterprise-beans&gt; &lt;/ejb-jar </code></pre> <p>but now i get javax.naming.NameAlreadyBoundException: Use rebind to override [/EDIT]</p>
    singulars
    1. This table or related slice is empty.
    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. 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