TomEE on eclipse, How to call a remote EJB from a JSF Managed bean?

我的未来我决定 提交于 2019-12-23 05:25:30

问题


I want to have JSF 2.0 page in one instance of TomEE server calling a Remote EJB running under a different TomEE server, (both obviously running on different ports).

This is what I have done in eclipse...

AppEJB - is a EJB project that contains all the ejb code.
AppEJBInterfaces - This project contains all the remote interfaces, the idea is that this jar will be added to the class path of the web application project containing JSF front end.
AppWeb - is the Dynamic Web Application project containing the JSF front end.
AppEAR - this contains AppEJB.

Following is the ejb in AppEJB

@Stateless(name="UserManager")
@LocalBean
public class UserManagerImpl implements UserManager {
    public void createUser(User user) {
    }
}   

Following is the remote interface in AppEJBInterfaces

@Remote
public interface UserManager {
public void createUser(User user);
}

This is what I do in the JSF managed bean

@ManagedBean
@SessionScoped
public class UserLoginManager implements Serializable{  
@EJB(mappedName="UserManager")
UserManager userManager;
}

I have created a server in eclipse and pointed it to the TomEE 1.6 plus installation. I have added the WebApp to the server. When I right click on the server I don't see the option to add the AppEAR project, so the questions I have are

How do I add/deploy the EJB project or the AppEAR to the server (TomEE in eclipse)? How do I get the JSF managed bean to lookup the remote EJB? If we assume that I convert the ejbs to local beans How do I specify the jndi names/config?


回答1:


Actually TomEE implements most part of JavaEE 6 Full Profile (it is not certified but available in TomEE+, for instance JAXWS, JAXRS, JMS, Connector...). @Remote EJB is in webprofile ditribution.

To lookup you can use RemoteInitialContextFactory or TomEE remote EJB injection feature (not portable).

See http://tomee.apache.org/clients.html and http://tomee.apache.org/ejb-refs.html (end of the page)

edit: you can deploy ear or ejbmodule to tomee using (see tomee.xml). Just drop the binary inside apps folder you'll create in tomee home



来源:https://stackoverflow.com/questions/22097027/tomee-on-eclipse-how-to-call-a-remote-ejb-from-a-jsf-managed-bean

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!