From the blog: http://www.cnblogs.com/yangyquin/p/5328344.html You can learn how to use IntelliJ idea to build an EJB module and create a new test module.
But I found that the new EJB project could be optimized to create a JSP file inside the EJB module to invoke the EJB project. 1, in IntelliJ idea New EJB project (a) new EJB projects are included in the Web application, so first optimize the project structure, the main Meta-inf unified to the Web directory, and the Lib folder in the Web-inf directory. 2. Create a new jboss-ejb-client.properties file in the SRC directory:
endpoint.name=client-Endpointremote.connectionprovider.create.options.org.xnio.Options.SSL_ENABLED= false remote.connections=defaultremote.connection. default. host=localhostremote.connection. default. Port = 4447remote.connection. default. connect.options.org.xnio.options.sasl_policy_noanonymous=false Remote.connection. default. username=yangremote.connection. default. password=123456
3. Modify the index.jsp file:
<%--Created by IntelliJ. User:gao Date:16-3-28Time : PM 4:22 to change ThisTemplate Use File | Settings |File Templates.<%@ page contenttype= "Text/html;charset=utf-8" language= "Java"%>--%><%@ page language= "java" ContentType = "text/html; charset=gb18030 "pageencoding=" GB18030 "%><! DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01 transitional//en" HTTP://WWW.W3.ORG/TR/HTML4/LOOSE.DTD "><% @pageImport= "Javax.naming.InitialContext"%><% @pageImport= "Com.ejb.HelloWorld"%><% @pageImport= "Javax.naming.NamingException"%><%@ pageImport= "java.util.Hashtable"%><%@ pageImport= "Javax.naming.Context"%>Hello World!!!!! <%FinalString appName = ""; FinalString modulename = "ejbtest_war_exploded"; FinalString distinctname = ""; FinalString beanname = "HELLOWORLDEJB"; FinalString viewclassname = HelloWorld.class. GetName (); FinalString namespace = "EJB:" + appName + "/" +ModuleName+ "/" + Distinctname + "/" + Beanname + "!" +Viewclassname; System.out.println (namespace); Try { FinalHashtable jndiproperties =NewHashtable (); Jndiproperties.put (Context.url_pkg_prefixes,"Org.jboss.ejb.client.naming"); FinalContext context =NewInitialContext (jndiproperties); HelloWorld HelloWorld=(HelloWorld) Context.lookup (namespace); System.out.println (HelloWorld); String s= Helloworld.sayhello ("Yangyuqin"); System.out.println (s); }Catch(namingexception e) {e.printstacktrace (); }%></body>4. Run the Ejbtest project with JBoss.
5. Running Result: Browser page:Intellij idea Create a new EJB project (ii)