Java – accessing EJBs from POJOs

Can I access EJBs from POJOs? I tried

@EJB MyClass obj

But it doesn't work

Solution

If you use JSR - 199 (Java context and dependency injection), which can convert anything into managed components, you can inject Therefore, if your POJO is a CDI managed bean, you can:

@Inject MyEjb service

Without CDI, you will have to find it

You can also have a look

> Contexts and Dependency Injection for the Java EE Platform > Dependency Injection in Java EE 6 Provides Unified EJB and JSF Programming Model > CDI,JSF & Dependency Injection in Java EE 6

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>