java - Issue with stateful ejb on servlet without @EJB injection -


i trying use stateful ejb servlet, understood shouldn't use @ejb injection that, , lookup instead.

the problem is, far way managed achieve using anotation on servlet:

@ejb(name="loginremote", beaninterface = loginremote.class) loginremote loginhandler; 

then lookup:

loginhandler = (loginremote) new initialcontext().lookup("java:comp/env/loginremote"); 

otherwise javax.servlet.servletexception: javax.naming.namenotfoundexception error.

is acceptable or should avoid @ejb injection completely?

thanks

no, don't want inject instance servlet. instead, can use @ejb annotation on servlet class declare reference without injecting:

@ejb(name="loginremote", beaninterface = loginremote.class) public class myservlet { 

you can use @ejbs if want declare multiple references in same servlet.

(note when using annotation on field in example, beaninterface parameter redundant field type, required when using class-level annotation class.)


Comments

Popular posts from this blog

java - Oracle EBS .ClassNotFoundException: oracle.apps.fnd.formsClient.FormsLauncher.class ERROR -

c# - how to use buttonedit in devexpress gridcontrol -

nvd3.js - angularjs-nvd3-directives setting color in legend as well as in chart elements -