Packaging Persistence Unit Definition

  1. The file persistence.xml must be packaged along with the EJB class files. This is done by accessing the project properties, and selecting the Packaging Configurations section:

    Packaging Configurations

  2. Select the calculator.jar item and right-click in the area to pop-up the menu and choose Add File.... A File Selection dialog appears.

    This dialog allows to select which file (local to workspace or in the file system) to include into the package:

    File Selection Dialog

  3. Click on the Project File... button. A Select a File dialog appears.

    Select the /Calculator/bin/META-INF/persistence.xml file and click the OK button.

    In the Prefix field enter META-INF. This is the location within the archive where persistence.xml should be placed:

    File Chooser Dialog

    Click the OK button.

  4. We need to add the Entity Object class too. Eclipse has generated the compiled classes into the bin folder (declared as the default output dir of the project).

    Select the calculator.jar item and right-click in the area to pop-up the menu and choose Add Folder.... A Folder Selection dialog appears.

    This dialog allows to select which folder (local to workspace or in the file system) to include into the package, to specify include and exclude filters and to set a prefix that will be append when building the package.

  5. Click on the Project Folder... button. A Folder Chooser dialog appears.

    This dialog allows selecting which folder to include. This folder can be choosen among all the opened projects.

    Select the /Calculator/bin folder and click the OK button.

  6. The folder is now /Calculator/bin.

    As we only want the Entity Object class, specify the following as an include filter:

    by/iba/domain/*.class

    Click the OK button.

    Include Filter

  7. The packaging configuration for the calculator.jar is now complete.

    Click the OK button to save the packaging configuration.

    Packaging Configuration

  8. Right-click on the Calculator project and select Run Packaging. The packaging will display its output in the console. The output should look like this:

    Buildfile: C:\ejb3workspace\Calculator\packaging-build.xml
    N65540:
          [jar] Building jar: C:\ejb3workspace\Calculator\calculator.jar
    _packaging_generation_:
    BUILD SUCCESSFUL
    Total time: 1 second
    								

  9. After the execution, you should have a project that looks like this:

    Project with Persistence Unit Definition

    The contents of the calculator.jar should be as follows:

    C:\ejb3workspace\Calculator>jar tvf calculator.jar
         0 Wed Nov 15 12:28:52 EET 2006 META-INF/
       106 Wed Nov 15 12:28:50 EET 2006 META-INF/MANIFEST.MF
       286 Wed Nov 15 11:10:48 EET 2006 META-INF/persistence.xml
         0 Mon Nov 06 17:17:18 EET 2006 by/
         0 Tue Nov 14 14:15:52 EET 2006 by/iba/
         0 Wed Nov 15 09:42:44 EET 2006 by/iba/ejb/
       409 Wed Nov 15 09:46:04 EET 2006 by/iba/ejb/PersistentCalculator.class
      4067 Wed Nov 15 12:09:54 EET 2006 by/iba/ejb/PersistentCalculatorBean.class
       305 Mon Nov 06 17:17:18 EET 2006 by/iba/ejb/StatefulCalculator.class
      1800 Mon Nov 06 17:17:18 EET 2006 by/iba/ejb/StatefulCalculatorBean.class
       268 Mon Nov 06 17:17:18 EET 2006 by/iba/ejb/StatelessCalculator.class
       907 Mon Nov 06 17:17:18 EET 2006 by/iba/ejb/StatelessCalculatorBean.class
         0 Tue Nov 14 14:15:54 EET 2006 by/iba/domain/
      2368 Wed Nov 15 11:50:22 EET 2006 by/iba/domain/Operation.class
    								

  10. OPTIONALLY: Undeploy the previous calculator.jar EJB module as described here: Undeploying An EJB JAR file.

  11. In the Project Explorer View right click the calculator.jar file and select Run As > Run on Server context menu.

  12. In the Console View, you should see some deployment activity. The EJB JAR is now deployed:

    12:31:07,162 INFO  [JmxKernelAbstraction] installing MBean: jboss.j2ee:jar=calculator.jar,name=PersistentCalculatorBean,service=EJB3 with dependencies:
    12:31:07,162 INFO  [JmxKernelAbstraction] 	jboss.j2ee:jar=calculator.jar,name=StatelessCalculatorBean,service=EJB3
    12:31:07,162 INFO  [JmxKernelAbstraction] 	persistence.units:jar=calculator.jar,unitName=calculator
    12:31:07,162 INFO  [JmxKernelAbstraction] installing MBean: jboss.j2ee:jar=calculator.jar,name=StatefulCalculatorBean,service=EJB3 with dependencies:
    12:31:07,162 INFO  [JmxKernelAbstraction] 	jboss.j2ee:jar=calculator.jar,name=StatelessCalculatorBean,service=EJB3
    12:31:07,162 INFO  [JmxKernelAbstraction] installing MBean: jboss.j2ee:jar=calculator.jar,name=StatelessCalculatorBean,service=EJB3 with dependencies:
    12:31:07,178 INFO  [EJBContainer] STARTED EJB: by.iba.ejb.StatelessCalculatorBean ejbName: StatelessCalculatorBean
    12:31:07,240 INFO  [EJBContainer] STARTED EJB: by.iba.ejb.PersistentCalculatorBean ejbName: PersistentCalculatorBean
    12:31:07,271 INFO  [EJBContainer] STARTED EJB: by.iba.ejb.StatefulCalculatorBean ejbName: StatefulCalculatorBean
    12:31:07,287 INFO  [SimpleStatefulCache] Initializing SimpleStatefulCache with maxSize: 100000 timeout: 300 for jboss.j2ee:jar=calculator.jar,name=StatefulCalculatorBean,service=EJB3
    12:31:07,287 INFO  [EJB3Deployer] Deployed: file:/C:/jboss4/server/default/deploy/calculator.jar								
    								

Professional hosting     Belorussian informational portal         Free SCWCD 1.4 Study Guide     Free SCDJWS 1.4 Study Guide     SCDJWS 1.4 Quiz     Free IBM Certified Associate Developer Study Guide     IBM Test 000-287. Enterprise Application Development with IBM WebSphere Studio, V5.0 Study Guide     Free Mock Exam Engine