4.2. Setting up a new Seam project
Start up Eclipse and select the Seam perspective.
Go to .
![](https://access.redhat.com/webassets/avalon/d/JBoss_Enterprise_Application_Platform_Common_Criteria_Certification-5-Seam_Reference_Guide-en-US/images/f743dfa9dcb020c64eabbae7881a0692/new_web_project_0.png)
First, enter a name for your new project. This tutorial uses
helloworld
as the project name.
Now, we need to tell JBoss Developer Studio about JBoss Enterprise Application Platform runtime. In this example, we are using JBoss Enterprise Application Platform 5. Selecting the JBoss Enterprise Application Platform is a two step process. First, we need to define a runtime environment. Again, we'll choose predefined JBoss Enterprise Application Platform from JBDS in this case:
![](https://access.redhat.com/webassets/avalon/d/JBoss_Enterprise_Application_Platform_Common_Criteria_Certification-5-Seam_Reference_Guide-en-US/images/dea8e3c6fcf763fbe4e023b5575bdaf0/new_server_runtime_1.png)
Enter a name for the runtime, and locate it on your hard drive:
![](https://access.redhat.com/webassets/avalon/d/JBoss_Enterprise_Application_Platform_Common_Criteria_Certification-5-Seam_Reference_Guide-en-US/images/cec4801c86d0fa1e88cad4a79dc22c04/new_server_runtime_2.png)
Next we need to define a server where JBoss Developer Studio can deploy the project. Make sure to select JBoss Enterprise Application Platform 5.0 and the runtime you defined in the last step, give the server a name and press
:
![](https://access.redhat.com/webassets/avalon/d/JBoss_Enterprise_Application_Platform_Common_Criteria_Certification-5-Seam_Reference_Guide-en-US/images/074da0d1a3da72986c4204080491aeaf/new_server_1.png)
On the next screen, check the server settings and press
:
![](https://access.redhat.com/webassets/avalon/d/JBoss_Enterprise_Application_Platform_Common_Criteria_Certification-5-Seam_Reference_Guide-en-US/images/58aae2fd1cbba5155699c105dd7a1deb/new_server_2.png)
Make sure the runtime and server you just created are selected. Under Configurations, select Dynamic Web Project with Seam 2.2, then click on Next:
![](https://access.redhat.com/webassets/avalon/d/JBoss_Enterprise_Application_Platform_Common_Criteria_Certification-5-Seam_Reference_Guide-en-US/images/309f5e4323135b119f2e45906bb190f7/new_web_project_1.png)
You can further customize your project over the next three screens, but the defaults suit our purposes. Click
until you reach the final screen.
Here, JBoss Developer Studio requires information about your Seam download. Add a new
, making sure to name it, and select as the version:
![](https://access.redhat.com/webassets/avalon/d/JBoss_Enterprise_Application_Platform_Common_Criteria_Certification-5-Seam_Reference_Guide-en-US/images/7206def345eb24c67bed533e08a7e1c0/new_seam_runtime.png)
The most important choice here is whether to deploy your project in EAR or WAR. EAR projects support Enterprise JavaBeans 3.0 (EJB3) and require Java EE 5. WAR projects do not support EJB3, but can be deployed to a J2E environment. WAR packaging is also easier to understand. This tutorial assumes you are using an WAR deployment, but you can follow these steps even if your project is EAR-deployed. The Enterprise Application Platform supports either type of deployment.
Next, select the type of database you are using. For this tutorial, we assume you have MySQL installed with an existing schema. You will need to tell JBoss Developer Studio about the database, select
as the database, and choose a MySQL connection profile type. Select and give it a name.
![](https://access.redhat.com/webassets/avalon/d/JBoss_Enterprise_Application_Platform_Common_Criteria_Certification-5-Seam_Reference_Guide-en-US/images/edc0a3090ce51a8949d0065b8cb68dbb/new_connection_profile_1.png)
Select existing MySQL driver from dropdown and specify database name, JDBC URL and JDBC username and password:
![](https://access.redhat.com/webassets/avalon/d/JBoss_Enterprise_Application_Platform_Common_Criteria_Certification-5-Seam_Reference_Guide-en-US/images/fa23d12f6debcfc094d2bb6355c0d612/new_connection_profile_2.png)
JBoss Developer Studio comes with common drivers for any database. In the case of MySQL you need to tell the JBoss Developer Studio where the location of your MySQL JDBC driver is. Tell it about the driver location by clicking on the delta icon on the right next to the dropdown list.
You need to set the location of MySQL 5 JDBC driver on second tab -
and click :
![](https://access.redhat.com/webassets/avalon/d/JBoss_Enterprise_Application_Platform_Common_Criteria_Certification-5-Seam_Reference_Guide-en-US/images/a43b4ebc1e0bc7f390c975a2aed63cbb/new_connection_profile_3.png)
Finally, choose the newly created driver.
If you are working with an existing data model, make sure to tell JBoss Developer Studio that tables already exist in the database.
Review the username and password used to connect, test the connection with the
button, and when the test passes, click on to return to the Seam Project Wizard.
Finally, review the package names for your generated beans, and if you are happy, click
:
![](https://access.redhat.com/webassets/avalon/d/JBoss_Enterprise_Application_Platform_Common_Criteria_Certification-5-Seam_Reference_Guide-en-US/images/ab3f53d3a205f82a9e76e40aa39aff22/new_web_project_2.png)
JBoss Developer Studio has sophisticated support for hot redeployment of WARs and EARs. Unfortunately, due to bugs in the JVM, repeated redeployment of an EAR - which is common during development - eventually causes the JVM to run out of permanent generation (perm gen) space. For this reason, we recommend running JBoss Enterprise Application Platform in a JVM with a large perm gen space at development time. If you use the predefined JBoss Enterprise Application Platform 5.0 runtime, the best values are set in, but you can customize these to fit your environment.
If your available memory is limited, the following is our minimum recommendation:
-Xms256m -Xmx512m -XX:PermSize=128m -XX:MaxPermSize=256
Right-click on the server in the
and select :
![](https://access.redhat.com/webassets/avalon/d/JBoss_Enterprise_Application_Platform_Common_Criteria_Certification-5-Seam_Reference_Guide-en-US/images/5420b5b352ed39b02abf2919db299970/server_properties_0.png)
Then, in opened Server properties, click on
and alter the VM arguments:
![](https://access.redhat.com/webassets/avalon/d/JBoss_Enterprise_Application_Platform_Common_Criteria_Certification-5-Seam_Reference_Guide-en-US/images/420eba3a296d1fad9c21ad45fd3ac3fc/server_properties_1.png)
To start JBoss Enterprise Application Platform, and deploy the project, right click on the server you created, and click
, (or to start in debug mode):
![](https://access.redhat.com/webassets/avalon/d/JBoss_Enterprise_Application_Platform_Common_Criteria_Certification-5-Seam_Reference_Guide-en-US/images/26dfd81dbe88b0bc5a57dceeb823cff7/start_server.png)
XML configuration documents will be generated in the project directory. These may appear complicated, but they are comprised primarily of standard Java EE, and require little alteration, even between Seam projects.