本文介绍了在eclipse上的TomEE,如何从JSF Managed bean调用远程EJB?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 我想在一个TomEE服务器实例中调用在不同的TomEE服务器下运行的远程EJB(两者都显然在不同的端口上运行)的JSF 2.0页面。 这是我在eclipse中所做的... AppEJB - 是一个EJB项目,包含所有ejb代码。 AppEJBInterfaces - 该项目包含所有远程接口,其想法是将此jar添加到包含JSF前端的Web应用程序项目的类路径中。 AppWeb - 是包含JSF前端的动态Web应用程序项目。 AppEAR - 这包含AppEJB。 以下是AppEJB中的ejb @Stateless(name =UserManager) @LocalBean public class UserManagerImpl实现UserManager { public void createUser(User user){} } 以下是AppEJBInterfaces中的远程接口 @Remote public interface UserManager { public void createUser(User user); } 这是我在JSF托管的bean中所做的工作 @ManagedBean @SessionScoped public class UserLoginManager实现Serializable { @EJB(mappedName =UserManager ) UserManager userManager; } 我已经在eclipse中创建了一个服务器,并将其指向TomEE 1.6 plus安装。我已将WebApp添加到服务器。当我右键单击服务器时,我看不到添加AppEAR项目的选项,所以我有的问题是 如何添加/部署EJB项目或AppEAR到服务器(在eclipse中的TomEE)? 如何让JSF托管的bean查找远程EJB? 如果我们假设我将ejb转换为本地bean如何指定jndi名称/ config?解决方案实际上,TomEE实现了大部分JavaEE 6完整配置文件(它没有经过认证,但在TomEE +中可用,例如JAXWS,JAXRS,JMS,Connector ...)。 @Remote EJB是在webprofile ditribution中。 要查找可以使用RemoteInitialContextFactory或TomEE远程EJB注入功能(不可移植)。 请参阅 http://tomee.apache.org/clients.html 和 http://tomee.apache.org/ejb-refs.html (页尾) ) 编辑:您可以部署ear或ejbmodule来使用(参见tomee.xml)。只需放入您将在tomee home中创建的应用程序文件夹中的二进制文件 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")@LocalBeanpublic class UserManagerImpl implements UserManager { public void createUser(User user) { }}Following is the remote interface in AppEJBInterfaces @Remotepublic interface UserManager {public void createUser(User user);}This is what I do in the JSF managed bean @ManagedBean@SessionScopedpublic 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 areHow 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? 解决方案 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 这篇关于在eclipse上的TomEE,如何从JSF Managed bean调用远程EJB?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
09-01 17:51