JBoss Weld is designed to be used in a Java EE container such as Geronimo, Glassfish, JBoss AS, WebLogic, WebSphere, etc. with JavaServer Faces 1.2 and above. The extension-based approach employed by the JBoss team developing the reference implementation for JSR-299 makes it relatively easy to use Weld in other environments such as Java SE or a standard Servlet Container such as Jetty or Tomcat.
*** THIS ARTICLE IS CURRENTLY IN A DRAFT STATUS ***
In order to build the sample application and have it run on the Google App Engine platform, you will need to have the following software downloaded and installed locally.
You can download the Google AppEngine SDK v1.3.5
and install it locally on your system; however, this tutorial is written from the Eclipse perspective using the Google Plugin for Eclipse
The following steps should be performed in advance of the process outlined below.
- Download and install Eclipse SDK 3.6.
- Follow the instructions outlined on the "Quick Start" page to install the Google Plugin for Eclipse.
Creating a New Project
- From the 'New' sub-menu on the 'File' menu, select the "Google Web Application Project".
- Give your project a name in the 'Project Name' field. For the purposes of this tutorial, we will use "Google AppEngine JBoss Weld".
- Enter your project's default package name in the 'Package' field. For the purposes of this tutorial, we will use "com.wildstartech.gae.weld".
- Remove the check mark from the 'Use Google Web Toolkit' box in the "Google SDKs" portion of the dialog.
- Ensure the "Use Google App Engine" option has a check mark beside it.
- Left-click on the 'Finish' button.
Importing the JBoss Weld Files
- In the "Project Explorer" tab, located on the left side of your IDE, expand your project and navigate to and left-click on the WEB-INF/lib directory.
- Left-click on the 'File' menu and select the 'Import...' menu item.
- When presented with the "Import" dialog, left-click on the 'File System' item under the "General" option.
- Left-click on the 'Next' button.
- Left-click on the 'Browse...' button and select the folder on your local hard disk drive into which you uncompressed the files found in the weld-1.0.1-Final.zip archive you downloaded from the "Weld Distribution Downloads" page. When you have selected the directory, left-click on the 'Open' button.
- Left-click on the arrow appearing to the left of the weld-1.0.1-Final folder.
- Left-click on the arrow appearing to the left of the artifacts folder.
- Left-click on the cdi folder.
- Place a check mark beside the cdi-api.jar file as shown in the figure below.
- Left-click on the weld folder.
- Place check marks beside the weld-api.jar, weld-core.jar, and weld-servlet.jar files as shown in the figure below.
- Left-click on the 'Finish' button to complete the process of importing the files.
- You will see that you now have an artifacts folder in your WEB-INF/lib folder.
- Expand the artifacts folder.
- Expand the cdi folder.
- Left-click on the cdi-api.jar file and drag it up and drop it onto the lib folder.
- Expand the weld folder.
- Select the weld-api.jar, weld-core.jar, and weld-servlet.jar files and drag them up an drop them onto the lib folder.
- Steps 14 through 18 will move the JBoss Weld libraries out of their sub-folders and into the WEB-INF/lib directory.
- Right-click on the artifacts folder to display the pop-up menu for the folder.
- Left-click on the 'Delete' menu option.
- When presented with the "Confirm Delete" dialog, simply left-click on the 'OK' button.
- After completing the process outlined above, the WEB-INF/lib folder in your web application should look similar to what is shown in the figure below.
Configuration File Changes
Edit the appengine-web.xml file found in the WEB-INF directory of the project to allow the web application to store data in the session created for clients visiting our site. Add the <sessions-enabled>true</sessions-enabled> line as shown below.
<?xml version="1.0" encoding="utf-8"?>
<!-- Configure java.util.logging -->
<property name="java.util.logging.config.file" value="WEB-INF/logging.properties"/>
Do not forget to modify the contents of the <application></application> tag to reflect the name of your App Engine project. Save the changes to the appengine-web.xml file and close it.
Edit the web.xml file found in the WEB-INF directory of the project to add org.jboss.weld.environment.servlet.Listener class ServletContextListener, ServletRequestListener, and HttpSessionListener.
<?xml version="1.0" encoding="utf-8"?>
<!-- JBoss Weld 1.0.1 Compatibility -->
Modifying the Web Application's Default Page
A Google App Engine web project will, by default, setup the index.html file as the default file for your web application. In the section above, we specified a change to the <welcome-file-list> configuration parameter which instructs the App Engine's runtime environment to look for the index.jsp page as the default page.
As such, we we will rename the AppEngine's default index.html file to index.jsp.
- Locate and right-click on the index.html file in the war directory shown in the "Package Explorer" window.
- When the context-sensitive menu is displayed, left-click on the 'Rename...' menu item.
- When presented with the "Rename Resource" dialog, ensure the 'New name:' field indicates the index.html file should be renamed to index.jsp.
- Left-click on the 'OK' button to complete the file rename operation.
Copyright © 2010, Wildstar Technologies, LLC.