Intellij idea Create a new EJB project (ii)

Source: Internet
Author: User

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)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.