Running the example

Before we can run the example, we need to start the GlassFish Server and deploy our JEE application in it:

  1. Start the GlassFish Server.
  2. Once it is started, right-click on the GlassFish Server in the Servers view and select the Add and Remove... menu option:
Figure 7.23: Adding a project to GlassFish for deployment
  1. Select the EAR project and click on the Add button. Then, click Finish.
    The selected EAR application will be deployed in the server:
Figure 7.24: Application deployed in GlassFish
  1. To run the JSF page, course.xhtml, right-click on it in Project Explorer
    and select Run As | Run on Server. The page will be opened in the internal Eclipse browser and courses in the MySQL database will be displayed on the page.

Note that we can use CourseBean (EJB) as a local bean in CourseJSFBean, because they are in the same application deployed on the same server. To do this, add a reference of the CourseManagementEJBs project in the build path of CourseManagementWeb (open the project properties of CourseManagementWeb, select Java Build Path, select the Projects tab, and click the Add... button. Select the CourseManagementEJBs project and add its reference).

Then, in the CourseJSFBean class, remove the declaration of CourseBeanRemote and add one for CourseBean:

  //@EJB 
  //CourseBeanRemote courseBean; 
   
  @EJB 
  CourseBean courseBean; 

When you make any changes in the code, the EAR project needs to be redeployed in the GlassFish Server. In Servers view, you can see whether redeployment is needed by checking the status of the server. If it is [Started, Synchronized], then no redeployment is needed. However, if it is [Started, Republish], then redeployment is required. Just click on the server node and select the Publish menu option.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.145.166.149