jndi - glassfish 3.1 jdni lookup on EJB3 -


i have following interfaces mylocalbean, myremotebean , stateless mybean implements mylocalbean, myremotebean of following don't need simple java application test ...

ejb-jar.xml, glassfish-ejb-jar.xml, gf-client.jar

here's ejb-jar.xml

<?xml version="1.0" encoding="utf-8"?> <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">    <enterprise-beans>       <session>          <ejb-name>myejb</ejb-name>          <home>test.ejb.mylocalbean</home>          <remote>test.ejb.myremotebean</remote>          <ejb-class>test.ejb.mybean </ejb-class>          <session-type>stateless</session-type>          <transaction-type>container</transaction-type>       </session>    </enterprise-beans> </ejb-jar> 

what's missing here? able lookup using myejb?

and here's lookup code

initialcontext ic; ic = new initialcontext(); myremotebean remotebean =          (myremotebean ) ic.lookup("java:comp/env/myejb"); 

[edit]

i've update ejb-jar.xml follows

<enterprise-beans>     <session>         <ejb-name>myejb</ejb-name>         <ejb-class>test.ejb.mybean</ejb-class>         <ejb-local-ref>             <ejb-ref-name>myejb</ejb-ref-name>             <ejb-ref-type>session</ejb-ref-type>             <local>test.ejb.mylocalbean</local>             <ejb-link>myejbclient.jar#myejb</ejb-link>         </ejb-local-ref>     </session> </enterprise-beans> 

i error ...

cannot deploy mybeanear deployment error module: mybeanear: error occurred during deployment: exception while deploying app [mybeanear] : error: unresolved : myejbclient.jar#myejb. please see server.log more details.

[\edit]

[edit]

hi bkail, let me brake down problem using correct names.. initially, eclipse-sts ide created default

<?xml version="1.0" encoding="utf-8"?> <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">   <display-name>batchoverrideejb</display-name>   <ejb-client-jar>batchoverrideejbclient.jar</ejb-client-jar> </ejb-jar> 

and how tried accessing ejb

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"); 

running got following error

javax.naming.noinitialcontextexception: need specify class name in environment or system property, or applet parameter, or in application resource file:  java.naming.factory.initial     @ javax.naming.spi.namingmanager.getinitialcontext(namingmanager.java:645)     @ javax.naming.initialcontext.getdefaultinitctx(initialcontext.java:288)     @ javax.naming.initialcontext.geturlordefaultinitctx(initialcontext.java:325)     @ javax.naming.initialcontext.lookup(initialcontext.java:392)     @ za.co.sanlam.batchovveride.test.batchoverridetester.main(batchoverridetester.java:33) 

i thought error meant ejb not bound context, modified ejb-jar.xml follows

<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">     <enterprise-beans>         <session>             <ejb-name>batchoverrideejb</ejb-name>             <ejb-class>com.test.ejb.batchoverridemanagerbean</ejb-class>             <ejb-local-ref>                 <ejb-ref-name>batchoverrideejb</ejb-ref-name>                 <ejb-ref-type>session</ejb-ref-type>                 <local>com.test.batchoverridemanager.ejb.batchoverridemanagerlocal</local>                 <ejb-link>batchoverrideejb</ejb-link>             </ejb-local-ref>         </session>     </enterprise-beans> </ejb-jar 

but javax.naming.namealreadyboundexception: use rebind override [/edit]

try <ejb-link>myejb</ejb-link>. said, test.ejb.mylocalejb doesn't sound home interface extends ejbhome, perhaps meant use <business-remote> rather <remote> , <home>? if you're using container supports ejb 3.1, you'll find easier use annotations:

@stateless public class mybean implements mylocal { ... } @local public interface mylocal { ... } @remote public interface myremote { ... } 

as aside mylocalbean , myremotebean unusual names business interfaces. typically, bean suffix reserved ejb class itself.

edit #2:

for second edit, see link:

http://glassfish.java.net/javaee5/ejb/ejb_faq.html#nonjavaeewebcontainerremoteejb


Comments