How to Make JBoss Seam Work with Eclipse (for Windows)
Join the DZone community and get the full member experience.Join For Free
this is a step-by-step tutorial. i made this tutorial, because i was not happy with the four project folders generated by jboss tools 2.0.0 when i select a new seam ear project. the work is a bit confusing. if i create a new seam war project i only get two projects (one of them is a test project). i had a lot of trouble with the war project. i was not able to not get the ejb3 examples work with it. never the less the folder structure is different from the seam-gen generated projects. this tutorial works completely without jboss tool. you can use jboss tools anyway, it has nice functions do build a richfaces jsf page, but keep in mind that new generated projects are difficult to handle, since you have to keep an overview of all four projects and the changes you made in each of them.
download and extract the files
first of all you need to download a few things.
eclipse for java ee developers (second entry)
try to download the last gas from the jboss websites.
jboss seam 2.0.x (of course)
and the jboss application server 4.2.x
and you will need a database, i used mysql. download the proper jdbc driver
extract these files where you like but keep in mind not to use blanks ” ” or special characters “áä”.
i used “c:\development” as path. create a new workspace folder here.
now the folder should look like this:
download and install database
download the mysql database from this page
next we need to get our database up and running.
run the setup and make a “typical” installation. at the end of the setup configure the mysql server. choose “standard configuration”. do not change anything in the next screen. now set root password for the db. i used “mysql” at this point (very inventive, huh?). go to the next screen and finish the configuration.
setup jboss seam and create a new project
you need to create a new seam project
enter the console, start => run an enter “cmd”
enter “c:” and change the directory to the jboss seam installation
now it is time to setup jboss seam.
type: “seam setup”
seam welcomes us but wants to know some things about our project.
enter the project folder. that will be our workspace
enter the directory of the jboss application server
give the seam project a name.
richfaces is fine. hit enter.
the bluesky theme is fine, too. hit enter.
ear, ok. hit enter
enter the package name of your session beans.
enter the package name of your entity beans.
the package for the test cases is ok. enter.
i use mysql, so i enter “mysql”.
dialect is ok. enter.
enter the path to the jdbc driver. in this case it is
this is the driver class, hit enter.
now it gets a bit tricky. enter the connection url to your database.
i used the test database in my mysql installation.
the username was “root” and the password “mysql”.
there is no db catalog in this case. enter.
there are no tables so far. enter.
i want to keep my tables. enter.
the setup is finished. that was a lot of work, so where is my project?
there is no project till now.
enter “seam create-project”
that’s enough console hacking for now.
start eclipse and choose our workspace “c:\development\workspace”.
close the welcome screen (if you already haven’t)
create a new java project. file => new => project.. => java => java project
choose “create project from existing source” and enter the seam project path “c:\development\workspace\myfirstseamproj”.
enter project name “myfirstseamproj” and click “finish”.
switch to java ee perspective (top right)
click on the “servers” tab. right click and create a new one.
choose jboss v4.2, than next. enter application server directory “c:\development\jboss-4.2.2.ga”, than click “finish”.
start the server by right click, “start”.
open the project, right click the ant file “build.xml” and click “run as” => “ant build”.
an error appears! why? the windows file system does not like a file and a directory with the same name.
stop the server.
open the explorer and go to “c:\development\jboss-4.2.2.ga\server\default\deploy” and delete the myfirstseamproj.ear folder.
let’s try again. start the server. that’s a bit better.
now it is time to open the page of our new seam project.
open the browser and enter http://localhost:8080/myfirstseamproj/
there it is, your first seam project!
get the example running
now it is time to test a seam example. i used the simple “registration” example.
go to “c:\development\jboss-seam-2.0.1.ga\examples\registration”
the source files are in “\src\org\jboss\seam\example\registration”
copy register.java, registeraction.java and insert it in your eclipse project at src/action in the package “com.mydomain.myfirstseamproj.session”.
another error appears! well not really, it is the same as before, but now we have got an additional window
it is the windows file system again.
go to “c:\development\jboss-4.2.2.ga\server\default\deploy” again and delete the “myfirstseamproj.ear” file this time. the error should now be solved.
go back to the eclipse project and make a new package in “src/model” and name it “com.mydomain.myfirstseamproj.entity”. copy “user.java” from the example in this package.
now you must correct the package entry in the source files in your eclipse project to “com.mydomain.my…”. in “registeraction.java” you have to import user from “com.mydomain.myfirstseamproj.entity.user”. save all files.
go to the root directory of the registration example and copy all files from the view folder into the view folder of your eclipse project and override the existing.
the deploy method is explode, what does this mean?
open your browser and to http://localhost:8080/myfirstseamproj/ again.
the seam registration example is already running.
but to be sure that nothing went wrong, stop and start the server in eclipse again.
now you can register a new user in the browser and look into your database with the query browser.
everything works, very good.
Opinions expressed by DZone contributors are their own.