问题
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