Wednesday, January 21, 2009

First Seam Example

I tried a lot, to execute one simple application in SEAM. But again and again I got fail. I visited a lot of link but didnt get any clear running simple example. Even one of my friend is having some year experience in Seam and JSF, but she also didnt help me. From that day I was struggling to execute even a simple and first Seam example. Today I got success. :)

My previous post might be not run, but this post is fully tested by me and it is working. You can go throught stet by step.

Software Required.
1. jboss-seam-2.1.1.GA
2. jboss-4.2.0.GA
3. Eclipse Europa
4. PostgreSQL 8.1.0

Suppose you have all these software in C drive. (I am assuming.)
Please copy database drive jar file into jboss-seam lib. (Copy C:\PostgreSQL\8.1\jdbc\postgresql-8.1dev-403.jdbc2ee.jar INTO C:\jboss-seam-2.1.1.GA\lib)
Step1 : Create one workspace like C:\Workspace_Seam
Step2: Open dos prompt
c:\jboss-seam-2.1.1.GA>seam setup
It will ask many configuration, put value as below
Enter you java project workspace : C:\Workspace_Seam
Enter your JBoss AS home directory: c:\jboss-4.2.0.GA
Enter the Project name : Binod_SEAM_Proj
Then put three time enter key (Accepting default values)
Enter Java package name for your session bean : com.suman.session
Enter Java package name for your entity bean : com.suman.entity
Enter Java package name for your test cases : com.suman.test
What kind of database are you using : postgres
Enter the Hibernate dialect for your database : org.hibernate.dialect.PostgreSQLDialect
Enter the filesystem path to JDBC driver jar : C:\PostgreSQL\8.1\jdbc\postgresql-8.1dev-403.jdbc2ee.jar
Enter JDBC drive class for your database : org.postgresql.Driver
Enter JDBC URL for your database : jdbc:postgresql://localhost:5432/postgres
Enter database user name: postgres
Enter database password: suman
Put enter key 5 times to set default value.

Step3:c:\jboss-seam-2.1.1.GA> seam create-project
It will create one folder Binod_SEAM_Proj (Your project name) in C:\Workspace_Seam (Your workspace). And copy a lot of files including one project in Binod_SEAM_Proj folder.

Step4:
c:\jboss-seam-2.1.1.GA> seam generate
It will build the application and generate ear file i.e. Binod_SEAM_Proj.ear inside the C:\Workspace_Seam\Binod_SEAM_Proj\exploded-archives folder.

Step5:
c:\jboss-seam-2.1.1.GA> seam deploy
It will deploy the application and copy Binod_SEAM_Proj.ear to C:\jboss-4.2.0.GA\server\default\deploy

Step6: Start the jboss server
C:\jboss-4.2.0.GA\bin>run.bat
You will get message in server console like this
00:40:10,406 INFO [EARDeployer] Started J2EE application: file:/C:/jboss-4.2.0.GA/server/default/deploy/Binod_SEAM_Proj.ear/

Step7:
Open internet explorer and type
http://localhost:8080/Binod_SEAM_Proj
You will get one page having written
Welcome to Seam!
Your seam-get project is deployed! Here are some ...........

Step8:
Open Eclipse and put the workspace C:\Workspace_Seam
File -> Import -> General -> Existing Projects into Workspace -> Browse -> choose Binod_SEAM_Proj
Goto C:\jboss-seam-2.1.1.GA\examples\registration\src\org\jboss\seam\example\registration
and copy Register.java and RegisterAction.java and paste into Eclipse Binod_SEAM_Proj->src/hot-> suman.session
It will show some exception. So change the package in both java file from
package org.jboss.seam.example.registration; to package suman.session;
It will show one more exception, that would be solve in next step.

Step9:
Copy User.java from C:\jboss-seam-2.1.1.GA\examples\registration\src\org\jboss\seam\example\registration into Eclipse Binod_SEAM_Proj -> src/main -> suman.entity. Change the package name from
package org.jboss.seam.example.registration; to package suman.entity;
Now there woule not be any exception.

Step10: Go to E:\SEAM\jboss-seam-2.1.1.GA\jboss-seam-2.1.1.GA\examples\registration\view and copy all files. (index.html, register.xhtml, registered.xhtml) into Eclipse Binod_SEAM_Proj -> View. (Overwrite all files).

Step11:
Stop the jboss server
Delete Binod_SEAM_Proj.ear from C:\jboss-4.2.0.GA\server\default\deploy

Step12: Right click on build.xml -> Run As -> Ant Build
Again it will build the application and deploy the application.
Start the jboss server C:\jboss-4.2.0.GA\bin>run.bat
Open internet explorer and put
http://localhost:8080/Binod_SEAM_Proj2
You will get User Entry form having Username, Real Name, Password
Put data in all these text field and click on Register button.
You will get one confirmation message.
Now go to database, here one table is created with name users. That will have all the above given information.

Thats it .................. :)

21 comments:

  1. hi,

    Step5:
    c:\jboss-seam-2.1.1.GA> seam generate

    here is small mistake, not 'seam generate' (thats in step 4) but 'seam deploy'


    great tutorial with all details !

    ReplyDelete
  2. just question, i suppose that this tutorial is for beginners with seam - for people which want to know how it really works.

    And in real development you just install jboossTools into Eclipse a you generate seam project in this easy way new project > seam project > fill a few details > seam project is created...

    or i am wrong ?

    thank you

    ReplyDelete
  3. Hi sir,
    This is ranjeet kumar. This is very good example.
    Is there any option to download all requiremnt software you all ready mention above. if is it possible please upload.(execpt eclipse)

    ReplyDelete
  4. The only tutorial I found after trying so many, thanks dude for a nice post for beginner.

    ReplyDelete
  5. where is the source code ??

    ReplyDelete
  6. I appreciate your help and support for beginner on seam project.
    Farhan Akhter

    ReplyDelete
  7. Hi this jubin..thanks a lot for your support..i was searching the net for last one week..but i didnt get any thing like this.once again thanks a lot dude..can any tell me were i can find the examples for seam projects which is done netbeans.
    actually im new to seam.
    once again thanks & regards
    Jubin

    ReplyDelete
  8. When I am entering "Step2: Open dos prompt
    c:\jboss-seam-2.1.1.GA>seam setup" then I have an error on the command prompt that is "the JAVA_HOME environment variable should point to a jdk , not jre".....

    Please help me out....
    JON

    ReplyDelete
  9. post. I just stumbled upon your blog and wanted to say that I have really enjoyed reading your blog posts.Any way Ill be subscribing to your feed and I hope you post again soon

    Helen Neely

    ReplyDelete
  10. Thanks bro ! Great example for Seam's beginner :)

    ReplyDelete
  11. I am getting this error when i trying to register.
    I am using MySQL database..
    Can you help me?

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


    Thanks in advance

    ReplyDelete
  12. Someone posted a similar question earlier-

    When i type seam create I get an error saying unable to find tools.jar file in jre folder. Can you please tell how to fix this error? it will be very heloful for me. Thanks,

    Ecliplse beginner.

    ReplyDelete
  13. Hi Sir,That is best blogs of seam,I have read ever.Pls post the same example using Maven build tools.
    Thanks in advance...
    ------Rahi Akela----

    ReplyDelete
  14. Dear sir ..this is the bst for seam beginner..i read it run it and enjoy ...thanks a lot for this...sir this is my e-mail id kryogendra@gmail.com may i have your any contact details like mail id, Facebook id ...

    ReplyDelete
  15. I am getting this error when i trying to register.
    I am using MySQL database..
    Can you help me?

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


    Thanks in advance

    ReplyDelete
  16. I have read so many posts on the topic of the blogger lovers except this piece of writing is truly
    a pleasant post, keep it up.

    My webpage ... dream cardsharing

    ReplyDelete
  17. constantlу i used tο read ѕmaller posts that аlso cleаr thеir motive, аnd
    that iѕ also hapрening with this paragraph which I am rеading
    now.

    Have a look at my web-sіtе; http://info.finobox.ru/

    ReplyDelete
  18. You actually make іt seem so easy with yοur
    ρresеntation but І find this topіс to bе actuаlly ѕomеthing which I
    thіnk I ωould neνеr undeгѕtаnd.
    It sеems tоo complicated аnԁ extrеmely broad fοг me.
    I am loοking forωard for your next post, I'll try to get the hang of it!

    Feel free to surf to my homepage: Check Out www.comercioeletronico.org.br

    ReplyDelete
  19. I hardly comment, but after browsing some of the comments on "First Seam Example".
    I do have 2 questions for you if you do not mind.
    Could it be only me or do a few of the comments appear like
    they are left by brain dead folks? :-P And, if you are writing on additional online social sites,
    I'd like to keep up with you. Could you post a list of every one of all your public pages like your Facebook page, twitter feed, or linkedin profile?

    Take a look at my webpage; http://www.reilingen.de/wiki/index.php/Benutzer:JoannProf

    ReplyDelete
  20. I'm extremely inspired along with your writing talents and also with the structure for your weblog. Is this a paid topic or did you customize it your self? Anyway keep up the nice quality writing, it's
    uncommon to peer a nice weblog like this one today.
    .

    Here is my web page; pharmacy technician schools

    ReplyDelete
  21. Hi there to all, because I am really keen of reading this weblog's post to be updated regularly. It contains nice material.

    Feel free to surf to my web site - Natural Cleanse

    ReplyDelete