开发者

How to use ejb in webapplication

开发者 https://www.devze.com 2022-12-31 10:12 出处:网络
I want to call ejb from servlet via remote interface. Maybe it is a RTFM question but i cannot find solution via Google or documentation. What configuration steps I need to do than ejb be accessible f

I want to call ejb from servlet via remote interface. Maybe it is a RTFM question but i cannot find solution via Google or documentation. What configuration steps I need to do than ejb be accessible for webapps

I use Jboss 4.2, Java 1.6

Thanks for your开发者_StackOverflow answer!


Place this in your servlet:

@EJB
private YourEJBRemoteInterface remoteService;

And you will have your service injected. (you may need to set the name of the @EJB annotation)

Another way is to use JNDI lookup, but this is obsolete.

Update: Since your JBoss version seems obsolete as well, the JNDI lookup is the way to go. int your servlet init(..) method lookup the EJB through JNDI (using InitialContext), and set them as fields, as if dependency-injection has been performed.

0

精彩评论

暂无评论...
验证码 换一张
取 消