ejb - Unknown JNDI Lookup String -


i new ejb concept. have seen following in different website :

sample 1:

@stateless @ejb(name="audit", beaninterface=anotherejblocal.class) public class employeebean implements employeeservicelocal, employeeserviceremote {   @persistencecontext(unitname = "employeeservice")   private entitymanager manager;    public void doaction(){     try {       context ctx = new initialcontext();       anotherejblocal audit = (anotherejblocal) ctx.lookup("java:comp/env/audit");       audit.doanother();   } catch (namingexception e) {       throw new ejbexception(e);   }    } } 

sample 2:

public static void main(string[] a) throws exception {      employeeserviceremote service = null;     service = (employeeserviceremote) new initialcontext().lookup("employeebean/remote");       service.doaction();      } 

sample 3:

obj = ctx.lookup(ejb/cbdwebappear/cbdwebapp.jar/<ejb name>/<remote interface class name>); 

cbdwebapp project name in bean resides.

my question is:

  1. what need & meaning of java:comp/env/audit

  2. why same type of string not used in case of sample 2. guess remote ejb not local.

  3. why meaning of ejb string in sample 3.

  1. the java:comp/env/audit string looking ejb reference declared earlier @ejb(name="audit", beaninterface=anotherejblocal.class). names declared @ejb (and @resource , other ee references) implicitly declared in java:comp/env context. reference, deployer can retarget "audit" reference ejb in application implements anotherejblocal interface, or if deployer doesn't specify anything, javadoc @ejb annotation requires target single ejb within same application implements interface.

  2. this main method (probably) declared standalone java program. in case, (probably) configured via system properties connect jndi server of application server, return remote reference client. name looked vendor-specific, , configured ejb during deployment.

  3. this similar #2, difference being specific string being used. in case, relying on application server's "default" binding name if none configured ejb during deployment using pattern ejb/<app>/<module>/<bean>/<interface>.


Comments

Popular posts from this blog

Java 3D LWJGL collision -

spring - SubProtocolWebSocketHandler - No handlers -

methods - python can't use function in submodule -