Perform the following steps:
1. Establish a test web module
2. Create an idea ejb module and compile an ejb
3 compile and package
4. Write test page
5. Release ejb, web test module, and test ejb
1. Establish a web test module.
In the default user_projectsdomainsmydomainapplications Directory, create a folder named web. This folder is the web module for testing ejb.
Create a new WEB-INF folder under the web folder and a new lib folder under the WEB-INF.
Create a web. xml file in the WEB-INF with the following content:
<? Xml version = "1.0" encoding = "UTF-8"?>
<! DOCTYPE web-app PUBLIC "-// Sun Microsystems, Inc. // DTD Web Application 2.3 //" http://java.sun.com/dtd/web-app_2_3.dtd ">
<Web-app>
</Web-app>
OK. The web test module is complete.
2. Create an idea ejb module and compile an ejb
Open idea, select file-new-ejb modules, and change module name to "EjbSamples", as shown in the figure below:
In the server option, select weblogic, and the rest are set by default. Click finish.
Create a new package in the src folder. Package name: com. diegoyun. ejb. slb, as shown in the following figure:
Right-click the module name and choose new-sessionBean from the shortcut menu. Then, in the pop-up property box, set as follows:
<Ejb-name>: enter Helloworld.
Package: Select/enter com. diegoyun. ejb. slb
The remaining information idea will be automatically set for you. The attributes of the entire attribute box are as follows:
Click OK.
In this case, the ejb attribute configuration interface is displayed, as shown in the following figure:
In Display name, enter HelloworldEJB
Switch to the weblogic server page and enter the following jndi name: ejb/session/HelloworldEJB.
The interface is as follows:
Close this property page. Idea has helped you write the configuration information of ejb. You can open META-INF and ejb-jar.xml under weblogic-ejb-jar.xml/for viewing.
At this time, under com. diegoyun. ejb. slb, there should be three files: Helloworld, HelloworldBean and HelloworldHome.
Add a method to the Helloworld interface as follows:
Public interface Helloworld extends EJBObject {
Public String getGreeting (String name) throws RemoteException;
}
Add a method to the HelloworldBean interface as follows:
Public class HelloworldBean implements SessionBean {
...............
// Omit others
Public String getGreeting (String name ){
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