Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


advertisement
 

A Practical Guide for Integrating EJB and Struts : Page 6

EJB and the Struts framework each have received plenty of coverage individually, but what about leveraging EJB and Struts together? This tutorial lays out a complete step-by-step guide to integrating these two technologies.


advertisement
Package for Deployment
Now you're ready to package your application and deploy it to the JBoss application server. You can package your application in many ways, but this tutorial uses the packaging capability within Eclipse.

Create the EJB.jar file

  1. Right click on your project StrutsEJBTutorial in the package explorer, click properties, and then click Packaging Configurations.
  2. Right click in the large white space on the right, click Add Archive, and name the file StockEJB.jar. Click OK (see Figure 16).

    Figure 16: Dialog box for Adding StockEJB.jar
  3. Right click on StockEJB.jar and choose Add Folder. Click Project Folder, select WEB-INF/classes, and then click OK. In the Includes text box type: lum/stock/ejb/bean/*.class,lum/stock/ejb/interfaces/*.class,lum/staticvalues/*.class,lum/stock/*.class, and click OK (see Figure 17).



    Figure 17: Dialog Box for Adding the WEB-INF/classes Folder
  4. Right click on StockEJB.jar and choose Add File. Click Project Folder, and select ejb-jar.xml under the /META-INF directory. In the prefix box, type: META-INF (see Figure 18).

    Figure 18: Dialog Box for Adding the ejb-jar.xml File
  5. Right click on StockEJB.jar and choose Add File. Click Project Folder, and select jboss.xml under the /META-INF directory. In the prefix box, type: META-INF. Click OK.

Create the EJB-client.jar File

  1. Right click in the large white space on the right, click Add Archive, and name the file StockEJB-client.jar. Click OK.
  2. Right click on StockEJB-client.jar and choose Add Folder. Click Project Folder, select WEB-INF/classes, and then click OK. In the Includes text box, type: lum/stock/ejb/interfaces/*.class, and click OK.
  3. Right click on StockEJB-client.jar and choose Add File. Click Project Folder, and select ejb-jar.xml under the /META-INF directory. In the prefix box, type: META-INF. Click OK.
  4. Right click on StockEJB-client.jar and choose Add File. Click Project Folder, and select jboss.xml under the /META-INF directory. In the prefix box, type: META-INF. Click OK (see Figure 19).

    Figure 19: StockEJB-client.jar Structure
Create the .war File
  1. Right click in the large white space on the right, click Add Archive, and name the file StockWeb.war. Click OK.
  2. Right click on StockWeb.war and choose Add Folder. Click Project Folder, select WEB-INF, and then click OK. In the Includes text box, type: *.xml,*.tld, and in Prefix, type: WEB-INF. Click OK (see Figure 20).

    Figure 20: Dialog Box When Adding WEB-INF
  3. Right click on StockWeb.war and choose Add File. Click Project Folder, and select index.jsp. Click OK.
  4. Right click on StockWeb.war and choose Add File. Click Project Folder, and select application.properties under the /WEB-INF/classes/resources/ directory. In the prefix box, type: WEB-INF/classes/resources, and click OK (see Figure 21).

    Figure 21: Structure After Adding application.properties
  5. Right click on StockWeb.war and choose Add Folder. Click Project Folder, select pages, and then click OK. In the Prefix, type: pages, and click OK.
  6. Right click on StockWeb.war and choose Add Folder. Click Project Folder, select WEB-INF/classes, and then click OK. In the Includes text box, type: lum/staticvalues/*.class,lum/stock/*.class,lum/stock/action/*.class,lum/stock/facade/*.class, and in the Prefix, type: WEB-INF/classes, and click OK.
  7. Right click on StockWeb.war and choose Add File. Click Project Folder, and type: /StockEJB-client.jar after your project name. Here, you're telling Eclipse to package your EJB-client.jar in the .war file, even though you have not created it yet. In the prefix box, type: WEB-INF/lib and click OK (see Figure 22).

    Figure 22: Manually Inputting StockEJB-client.jar
  8. Right click on StockWeb.war and choose Add Folder. Click Project Folder, select WEB-INF/lib, and then click OK. In the Prefix, type: WEB-INF/lib, and click OK (see Figure 23).

    Figure 23: Structure After Adding WEB-INF/lib

Create the .ear File

  1. Right click in the large white space on the right, click Add Archive, and name the file Stock.ear. Click OK.
  2. Right click on Stock.ear and choose Add File. Click Project Folder, and select application.xml under the /META-INF directory. In the Prefix, type: META-INF, and click OK.
  3. Right click on Stock.ear and choose Add File. Click Project Folder, and type: /StockEJB.jar after your project name. Again, you are telling Eclipse to package a file that you have not yet created. Click OK (see Figure 24).

    Figure 24: Adding StockEJB.jar to Your .ear
  4. Right click on Stock.ear and choose Add File. Click Project Folder, and type: /StockWeb.war after your project name. Again, you are telling Eclipse to package a file that you have not yet created. Click OK (see Figure 25).

    Figure 25: Adding StockWeb.war to Your .ear
  5. Click OK in the bottom right corner. You'll notice that Eclipse has created a packaging-build.xml file for you.
  6. To run your packaging file, right click on your project StrutsEJBTutorial in the package explorer, and click Run Packaging.



Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap