Techieexchange’s Techblog

How to make JBoss Seam work with Eclipse (for Windows)

Posted on: February 1, 2008

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)
http://www.eclipse.org/downloads/

Try to download the last GAs from the JBoss websites.

JBoss Seam 2.0.X (of course)
http://labs.jboss.com/jbossseam/download/index.html

And the JBoss Application Server 4.2.X
http://labs.jboss.com/jbossas/downloads/

And you will need a database, I used MySQL. Download the proper JDBC Driver
http://dev.mysql.com/downloads/connector/j/5.0.html

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:

folder 

Download and install Database

Download the MySQL Database from this Page
http://dev.mysql.com/downloads/mysql/5.0.html

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
“cd C:\Development\jboss-seam-2.0.X.GA”.

Now it is time to setup JBoss Seam.

Type: “seam setup”

Seam welcomes us but wants to know some things about our project.

Seam

Enter the project folder. That will be our workspace
“C:\Development\workspace”

Enter the Directory of the JBoss Application Server
“C:\Development\jboss-4.2.2.GA”

Give the Seam project a name.
“MyFirstSeamProj”

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.

“com.mydomain.MyFirstSeamProj.session”

Enter the package name of your entity beans.


“com.mydomain.MyFirstSeamProj.entity”

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


“C:\Development\mysql-connector-java-5.0.8\mysql-connector-java-5.0.8-bin.jar”

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.

“jdbc:mysql://localhost:3306/test”

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”

There it is!

Seam finished

That’s enough console hacking for now.


Start Eclipse

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”.

7eclipsenew.jpg 

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.

8t.jpg 

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.

Error solved 

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!

11webside.jpg

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

New error

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.

Example

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.

Database 

Everything works, very good.

Advertisements

66 Responses to "How to make JBoss Seam work with Eclipse (for Windows)"

“The JBoss Tools project has got strange extends and imports in the source files”

What do you mean ? It uses the exact same templates as your example so I’m really curious what you mean here ?

“if I copy the files from the Seam examples in it, it will not work”

Again I would like to know the details about what is failing for you, what files are you copying ?

I would encourage you to take these up in the jboss tools forum so we can get i sorted out.

Hallo Max,
At the first point you are right, if I generate an entity with seam-gen there are the same extends of EntityHome and EntityQuery. I have not tested it in the first place.

If I select EAR, in JBoss Tools I get 4 projects instead of one, but I really only need one, like generated by seam-gen. Each Example of JBoss Seam has got only one folder/project, too.

If I select WAR, I get one project plus a test project, which seams ok. But if I copy the files from the Registration example in it, it does not work. I get a class not found and class not bound exception. Maybe it is because of EJB3, but I am not sure.

But it seams strange to me, that Seam-gen goes another way than Jboss Tools. Even the folder structure of the projects is completely different. However I will correct the text in my tutorial.

Best regards,
Christoph Gernert for TechieExchange’s Blog

The 2 additional projects for EAR serves multiple purposes:

Eclipse WTP wants it like that for their tooling to work

Without it the classpath would not be correct when running tests, code completion etc.

there are both plus and minuses…I should write about them at some point ,)

btw. jbosstools also works with seam-gen’ed projects (at least the code gen option) – we are working on having the wizards and other parts working on non-wtp projects like seamgen for upcoming versions.

Max said:
there are both plus and minuses…I should write about them at some point ,)

Please! The four folders per project in Eclipse is a real bummer.

Adam.

Hello!
I´m a bloody beginner with JEE and Seam, and I just wanted to say that this tutorial is the first complete Step by Step I found and I was able to get running!
Thanks!!

No single book on Seam gets you up and running like this tutorial.

Great job, thanks.

Thanks for the tutorial.
The following is not clear. I am not sure if there is a typo.
“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.”
I was able to make a new package in src/model and name it
but I am not sure how to do the copy.
i.e. “Copy “User.java” from the example in this package.
The newly created package? That seems to be empty.
Thanks

Hi,

This is the best example I see so far.
But can you please advise me where can I the source code of the MyFirstSeamProj?

Many thanks,
Peter.

Hi Max,

I managed to find out the source codes.

Thanks again,
Pete

Now you must correct the package entry in the source files in your eclipse project to “com.mydomain.My…”. In “RegisterAction.java” –> what does this mean that i change com.mydomain.MyFirstSeamProj.session to 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.–> what does this mean, because i copied every file from folder “Registration” and now the server wont start

This tutorial is nice. I try to follow but I get the error when I type the “seam setup”. The error message said that build failed and java.lang.UnsupportedclassVersionError: org/jboss/seam/tool/NormalizeProjectNameTask .

Hello All:-
I am new to JBoss Seam. I want to use JSF, Richfaces, and EJB3.0 but the thing is that I don’t want these to run in Eclipse. I want to deploy Web Application in Tomcat and EJBs in JBoss. Only When I want to deploy them by clicking Export. And Both WAR and EAR files should be deployed in WebServer(Tomcat) and Application Server(JBoss) respectively. So please tell me that how I can do that. Please response me about this As Soon As Possible. My email address is “smanaqvi83@msn.com”

Bye
Syed Muhammad Ali Naqvi

Thanks for posting such a beautiful blog on installing and get the first hands on Seam. I was so much compelled to try it, after reading it. I have followed word to word of it and am facing an issue while deploying the seam project on JBoss. The following is the configuration/setup on my windows XP laptop/machine:

JBoss 4.2.2.GA, Ant 1.6.5, JDK 1.6.0_05 [Updated today & before that 1.6.0_03], Seam 2.0.1.GA [Even tried with higher versions].

The following is the error/exception which I am getting in the JBoss logs:

2008-04-03 14:45:39,997 DEBUG [org.jboss.ejb3.Ejb3Module] Initialization failed jboss.j2ee:service=EJB3,module=MyFirstSeamProj.jar
org.jboss.xb.binding.JBossXBRuntimeException: Failed to create a new SAX parser

Can you please help me in debugging this? I searched Google extensively and couldn’t find any links for it. I have put the JBoss client endorsed libraries as well in the path, still no luck !!

~Murali.

Hi friends!

I try the jboss-seam-2.0.1.GA , jboss-4.2.2.GA, and mysql, but not work, the error is:

BUILD FAILED
C:\seam\jboss-seam-2jboss-seam-2.0.1.GA\seam-gen\build.xml:468: Use a resource collection to copy directories.

I have XP SP2

help my!!!

hi,
I followed all this step
for Dialect=Oracle10g(Later i did not use it)

“jdbc:oraclel:thin:@199…103:ASHOK

The username was “ashok” and the password “oracle”.

But when i running i browser :8080/registration
it displaying page,but when i submit data it showing error as seam can not instatiate register

Plese any one can clear me as giving a simple example

Hi,

I have really enjoyed reading this piece of article. I am the community content coordinator for DZone and I’d be honor if you would give me permission to repost this article on our website.

Please shoot me an email at Weiling@dzone.com, I look forward to talking to you soon!

Thanks!
-Wei Ling

Hi, pyanqn
Thanks for posting such a beautiful problem.
Make sure that you have coppied jboss and seam properly, if not then again extract te Zip file in your working directory. And for MySql database you coppied mysql-connector-java-5.0.8-bin.jar” in jboss/server/default/lib directory. For the timing of seam setup just press Enter in the follwing step
Enter the path to the JDBC driver. In this case it is
Enter(no need to set again the path of driver)

Thanks!
Ashok…

Beautiful tutorial for sure, you don’t want to add maven2 integration on that :p

Finally, a seam tutorial that works! Congratulations for your initiative.

Very nice, useful tutorial. Keep giving us tutorial like these.

Very nice (good working) tutorial bro! I’m also new to seam but got it up and running in no time.

Also got the error during seam setup: Use a resource collection to copy directories.

Ignored it and went ahead with seam create-project, had to manually put the mysql driver jar in jboss ../deploy/lib directory.

Once again, great manual!!!

Hi,
I really liked your step by step explanation. But my question is, i tried to install seam by following your procedure, but i see that the worspace in the directory is not created and there is no “MyFirstSeamProj”. Please help me out because i am very new to this technology. I tried second time by changing the workspace name to another one but its the same problem.
Thanks!!!

I found this tutorial indispensible – what a great resouce. After getting the Registration example working, I next tried a more advanced example: the DVD Store. But alas, despite my best efforts, I failed to get it up and running with Eclipse. This was a great disappointment, as I wanted to use the DVD Store example as the basis for a new Eclipse project. Has anyone else succeeded in getting DVD Store working with Eclipse ? ( I used the HSQLDB database )

Thanks for a great job!This instruction set is not only good for tunning examples, but also as a starting point for own applications.

Thanks a lot.

Server JBoss v4.2 at localhost was unable to start within 50 seconds. If the server requires more time, try increasing the timeout in the server editor.

what should i do now??

plz help me …..

Thankxxxxxxxx……..

Thanks a ton for this great post! It was very helpful. I wonder why the seam guys don’t incorporate this into their own site as a doc?

I was about to give up on Seam as being too problematic to get working. Now that I’m working better I think I’ll try some more.

HI,
After a long search i found this site and i really obliged for the help you provided for the seam , and i just want to know that if i just want to develop a web project in eclipse as we are doing with all other framework so is there any way for that.

Please response me and once again thanks a lot.

Rajveer Singh
Noida

Great job, thanks for this guide!

Hi,

Only seam EL out-of-the-box components autocompletion is available.

Does anyone managed to enable EL code completion for components defined in the src/action folder ?

Thanks

i need this code and im try it to run it ,but it does’t work

thanks

Not that if you use JBoss server 4.2.3, you need to change the build.properties to jboss-4.2.3 otherwise it will generate a build.xml for JBoss 4.2.2.

Even when you have correctly setup your Seam environment…..

You need to change that build.properties in your generated Eclipse project, otherwise it will deploy to the wrong server.

Finally a guide that worked. Most of the older JBoss+Eclipse+? tutorials are just plain rubbish. This tutorial took me about half an hour included figuring out some small hassles. Finding the wright source applications took me a lot more time though as they might be platform independent but surely not version independent.
All in all, I used the following:

eclipse-jee-europa-winter-win32 (had a hard time finding this one)
jdk-1_5_0_15-windows-i586-p
mysql-5.0.67-win32
mysql-connector-java-5.0.8
jboss-4.2.2.GA
jboss-seam-2.0.1.GA

Cheers

HI,
I tried to use this tutorial in linux 4.
Though I delete myfirstseamproj.ear in server/default/deploy and rebuild it, it keeps saying “failed to copy … (is a directory and I could not delete the corrupt …)

please help me out.
thanks.

Hi Joshua,
Stop Jboss and try to force manual delete and restart again.

thanks for make the first example work. Now i need help with the other examples. Tried everything and … i need some help. Like in the messages example. Crazy erros … i´m lost. Any help will be appreciated : rebouns@hotmail.com

Hi Bruno,
please ask Seam forum (http://seamframework.org/Community/Forums) for more infos.

how can i contact with delphi or .net to layer jboss seam

Hi all,
I am not able to access the project through localhost. When i tried
http://localhost:8080/ is displaying the Oracle 10g EXPRESS EDITION LICENSE
AGREEMENT is getting loaded. One more thing when i started my server in
eclipse, automatically the application is also getting started and working
properly. Plz analyse the situation and let me know what to do…

Regards,
Uday

Hi Uday,
Please check your port settings. I think Oracle has already taken your localhost with 8080.

Really very very thanks. I dont have word to express my thanks to you. I run my application without any problem.

Thanks,

Binod Kumar Suman

Server JBoss v4.2 at localhost was unable to start within 50 seconds. If the server requires more time, try increasing the timeout in the server editor.

what should i do now??

plz help me …..

thanks in advance

thank you very much for this tutorial.

It’s way more user-friendly than the official tutorial 🙂

In response to “Server JBoss v4.2 at localhost was unable to start within 50 seconds.”

Double click on the server (or right click and select open) and then select the timeouts section. Change it to 180 seconds or whatever you want.

Hi,
I think ,that we don’t need to run ant after import the project into eclipse .because the project it was deployed automatically

I’m having the same problem as rimom (26)….
How did you fix this? I didn’t see the answer.

Thanks

for vanessa.
you have just double click your jboss server at server’s onglet to edit ,and modify timeoute by increasing to 120 or more

Hi techieexchange.
I am a beginner in jboss seam development.
Just read your useful tutorial. By the way, after I walk through the end of this tutorial I still can’t run my project on my browser. If i type http:\\localhost:8080 the jboss can show itself. But, if I write http:\\localhost:8080\MySeam, seam says that the requested resource is not available.

can you r anybody tell me what’s going on?

Thank you.
Regards,
iCHi

Nice Tutorial. A couple of things.

1) Why are you using an EAR? You should use a WAR unless your project is using EJBs.

2) In you build.xml the default target is “deploy” which packages the WAR and copies it. If you change it to “explode” it will only copy the files that have changed. This will also eliminate the copy errors you are getting. It is suggested to use explode during development.

Thanks a lot for publishing such a helpful and practical tutorial.

thanks. good start for seam novice

I think that people who is trying SEAM must have an idea about jboss development studio.

I want to know what do you think about this product, and if you think it is rigth to be used for development of commercial applications.

can anybody let me know your thoughts ?

Thanks buddy for such a great tutorial.

thanks cgernert, it is a great tutorial for beginners like.

when i am creating new server (in eclipse) i get this error after setting APPLICATION SERVER DIRECTORY TO:

C:\Development\jboss-4.2.2.GA_itec

error:->

Missing classpath entry C:\Development\jboss-4.2.2.GA_itec\server\default\lib\mail.jar

please help me out what is the error

Hi,

I am getting the following error. “Server JBoss v5.1.0 at localhost was unable to start within 50 seconds. If the server requires more time, try increasing the timeout in the server editor.”

I tried increasing the time out value to 200 and 600 seconds. Still i am getting the same error. “… unable to start within 600 seconds….”.

I have been searching for resolution but couldn’t find anythhing.

Please help me to solve this.

hi,

i’ve experience the same problem, but i found the way to solve it. if you use jboss 5.1, use eclipse plugins from here: http://www.cs.hs-rm.de/~knauf/public/

regards.

Hi,

This is a great tutorial. I just got a problem when starting the server. I am also getting the following error: “Server JBoss v5.1.0 at localhost was unable to start within 50 seconds. If the server requires more time, try increasing the timeout in the server editor.”

I tried increasing the time out value but still getting the same error.

Please help me. Thank you so much 🙂

it was so nice

Thank you

Hi…
Ur post is extremely good…
I getting little error when i am trying to register by application.
The type of error is as below

Caused by javax.servlet.ServletException with message: “Could not instantiate Seam component: register”

Is any one help me…?

Thanks in advance……

Cool. I have a mammoth task of converting an app in a very dodgy mvc that was tightly coupled into the JSF/Seam app stack and this sample gave me a headstart

Hi Babu,

I have the same error like you so do you have any solution for this problem.
please answer me to my email : zakaria.bentahar@gmail.com.

Thank you so much.

I was fine until i got here-

“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. ”

I deleted MyFirstSeamProj.ear folder. then restarted the server but it gives me an error saying

DEPLOYMENTS IN ERROR
Deployment “vfszip:/C:/…Myfirstseamproj.ear/” is in error due to org.jboss.deployers.spi.DeploymentException.

Please let me know what is the error here and how to fix it. I have put in so much effort in this and its not working.

Three days looking for this answer!!!… i can´t beleve .. Jboss – Seam – anybody else had the answer!! …. you save my day ,…

Thanks so much …
(Y)

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: