Seam book examples updated to JBoss AS 4.2.0 GA
I have just updated all the 17 sample applications in my JBoss Seam book to JBoss AS 4.2.0 GA (w/ Seam 1.2.1 GA). You can now download the sample projects for both JBoss AS 4.0.5 and 4.2.0. If you find those examples useful, I’d appreciate if you can buy a copy of the book as well.
Since a lot of people seem to be confused about this, let me list the steps you need to convert a Seam application from JBoss AS 4.0.5 to JBoss AS 4.2.0:
1. Edit the resources/WEB-INF/web.xml file, and remove the MyFaces listener.
2. Edit the resources/META-INF/application.xml file, and remove the modules referencing el-api.jar and el-ri.jar.
3. Remove the el-api.jar and el-ri.jar files from the final application archive (edit the build.xml file for the ear or war tasks).
4. Edit the resources/WEB-INF/faces-config.xml file and add the SeamELResolver using the new JSF 1.2 XML schema declaration.
Do NOT miss the crucial step of removing el-*.jar from both the application and from the application.xml. If you do not remove those JARs and their references, your application will hang on JBoss AS 4.2.0 GA with a cryptic error message (before you ask, yes, we are fixing it). So, be aware!!
Note: Evidentially, the Seam security package still has some residue dependency on the Sun EL RI package. So, you might consider leaving el-ri.jar in the app if you use those features. It is confirmed to work in JBoss AS 4.2.1 GA. See comments below.
May 30th, 2007 at 1:16 am
So we don’t need to specify com.sun.faces.config.ConfigureListener in web.xml as it is specified in some Seam CVS examples? Your examples seem to work without it…
May 30th, 2007 at 1:20 am
Yes, Seam works fine without the JSF listener …
May 30th, 2007 at 2:48 am
I have followed these instructions and could not successfully switch to JBoss 4.2.GA with my Seam 1.2.1 application. I was getting error:
“Function ’s:hasRole’ not found”
After I completely replaced Seam 1.2.1 jars with the Jboss Seam CVS version, and modified my configuration to look like projects generated with seam-gen from CVS, application started to work correctly.
May 31st, 2007 at 9:49 am
Hi,
I am facing a small problem with contactlist application… Could you please provide me with some details on how to use hibernate3 in this project?
June 14th, 2007 at 4:05 am
Hi we are developing a portal using seam with eclipse-exadel.we saw a link from u in which u configured seam gen with eclipse as in the link below.Can u say how to configure seam to exadel.And a example to connect seam with database.we using facelet as front end.
http://michaelyuan.com/download/seam/rhds-20070306.html.
June 19th, 2007 at 4:11 am
i had to add commons-digester*.jar and commons-beanutils*.jar to WEB-INF/lib folder (editing build.xml file) in order to get it starting
But there is an UnboundedFifoError
June 20th, 2007 at 8:28 am
I deployed all applications (like booking) at Jboss 4.0.5 installed using JEMS (actually only jems-installer-1.2.0.CR1 is good); They work fine. But I try to deply all your new codes under Jboss 4.20, Seam 1.3 and JDK 1.5.
It always reports errors on java.lang.NullPointerException and DatabasePersistencePolicy.listTimerHandles.
I try each ways to get same result.It drives me crazy!
Quinten
June 20th, 2007 at 8:43 am
javawurm: Which version of Seam and JBoss are you running? Those examples are tested against Seam 1.2.1 and JBoss 4.2.0.
quinten: Not Seam 1.3 ALPHA yet … It is an ALPHA and we are still working on it.
June 24th, 2007 at 3:36 am
The examples work great with JBoss 4.2. However I couldn’t set them up with the examples from the original Seam 1.2.1 distribution although I followed the instructions in your book in chapter 23. That took me many hours and I was very frustrated. Your updates samples saved my trust in Seam, I think I’ll use it in my next big project.
Thanks for that great framework.
June 24th, 2007 at 9:35 am
I have just noticed that the JBoss AS 4.2 updated hotel booking application doesn’t handle workspaces correctly as outlined in chapter 8.1 in your book (although the demo on seam.demo.jboss.com does). Why is that?
June 24th, 2007 at 9:58 am
Okay, the updated booking example handles multiple workspaces correctly if one starts with two browser tabs or windows. But if you start with only one browser and right click on a “view hotel” link to open in a new window, then view a different hotel in the initial window and then go back to the new window and book you get the wrong hotel.
The seam.demo.jboss.com demo does not show this behaviour. Would be really cool if we could find out why that is.
June 24th, 2007 at 7:26 pm
Hello,
I have never used jboss or Seam, but have programed in java, grails and c#.
Would your book on jboss Seam be ok for a newbie?
Thanks
Frank
June 24th, 2007 at 10:37 pm
Frank,
If you have J2EE experience (I think Grails experience also counts :)), then the book is for you.
cheers
Michael
July 6th, 2007 at 8:23 am
Hike Mike, i have to admit I a lot confused regarding the problem with the class loaders and the libraries.
Seam : 1.2.1
JBoss : 4.2.0 GA (clean)
created a new application with Seam Gen!Nice
red @ page 314 of your book regarding the changes on the MyFaces section el..jars!
Nope still doesn’t work!
Exception sending context initialized event to listener instance of class org.jboss.web.jsf.integration.config.JBossJSFConfigureListener
java.lang.NoClassDefFoundError: org/apache/commons/digester/Digester
These exceptions…are preventing from getting started..and it is bad. I though Seam was going to boost my perfomance!
July 6th, 2007 at 9:02 am
Actually it worked only after I have included in the war lib directory lots of Commns library (Not the logging one)
July 14th, 2007 at 2:14 am
Hi Michael, would like to say this is a really wonderful book to get especially for someone who has some experience with JSF and no previous experience in Seam framework. I’ve to admit though, the bit regarding the integration of jBPM is slightly hard to grasp if you haven’t use jBPM framework before.
July 20th, 2007 at 8:16 am
I’m having trouble creating a new application based on your examples, as you suggest in your book.
If I download your examples, modify build.properties to point to my JBoss install, go into helloworld and run ant main deploy, the app builds, deploys to JBoss, and works just fine.
However, if I copy helloworld to a new directory, copy examples/lib/* and examples/build.properties into my new copy, and modify the copy’s build.xml to point to build.properties and lib instead of ../build.properties and ../lib, the app no longer works. It builds and deploys, but when JBoss loads it I get:
10:09:55,624 WARN [ServiceController] Problem starting service persistence.units:ear=helloworld.ear,jar=app.jar,unitName=helloworld
java.lang.ClassCastException: org.hibernate.ejb.HibernatePersistence
And then a longer stack trace. Why would moving the source code to a different location cause different runtime behavior like this? I’m having no luck trying to get a basic, template seam app running.
July 20th, 2007 at 9:05 am
Dan,
You are moving JARs from “lib” (examples/lib) to “applib” (examples/helloworld/lib) in your setup. Since everything in applib is included in the app.jar, you are including conflicting JARs (e.g., both JSF RI and MyFaces etc.)
The simple way to fix this is to remove the reference to applib in build.xml.
cheers
Michael
July 24th, 2007 at 12:21 am
My copy of your book “JBoss(R) Seam: Simplicity and Power Beyond Java(TM) EE (Prentice Hall JBoss) (Paperback) ” just arrived. But now that Seam 2.0 (beta) has been released, how relevent the contents of this book would still be? Moreover, are you going to make available some updates to your book for Seam 2.0 in some form eg. on your blog etc.
Thanks
Vimal
July 24th, 2007 at 12:33 am
Well, Seam 2 adds some new features but for the features discussed in the book, there is little change except for configuration files. Yes, I will update all my examples to Seam 2 once it reaches GA release.
July 30th, 2007 at 3:28 am
Hi Michael, I have your book, and it has been very helpful. I’m noticing exactly the same problem Dejan is getting: s:hasRole is not found. The problem is clearly in org.jboss.seam.util.EL and org.jboss.seam.jsf.SeamELFunctionMapper, which, as of Seam 1.2.1, include the Sun EL RI packages. Therefore they will not work reliably following your advice to remove the el-ri.jar. If I’m understanding this correctly, there should be a patch release for Seam 1.2.1 to fix this, otherwise it will never work reliably without the Sun EL RI jars.
July 30th, 2007 at 6:53 am
Chiral,
Could you perhaps raise a JIRA issue for this? Seam 1.2 *should* work without the Sun EL RI packages. I will update the instruction for now. Thanks.
cheers
Michael
July 30th, 2007 at 10:45 am
Done: http://jira.jboss.org/jira/browse/JBSEAM-1740 . So should I include the offending jars? Your previous instructions were clear that they should be gone. Won’t the RI jars cause problems?
This seems like a very small bug so hopefully it could be fixed quickly.
It’s a bit surprising that the whole rest of Seam EL works fine. Those classes must only be used in the security part of it.
July 30th, 2007 at 11:29 am
Actually, it is important NOT to include the el-*.jar in application.xml. But it is okay to leave them in the EAR/WAR — at least this is what I think (not tested)!
July 30th, 2007 at 2:52 pm
Okay, it is confirmed that you need to leave el-ri.jar in both the EAR/WAR and in application.xml for this to work on JBoss AS 4.2.1 GA.
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4068883#4068883
July 30th, 2007 at 5:54 pm
I posted notes on this in my blog. We have previous blog entries dealing with other issues for getting Seam apps to work in JBoss AS 4.2. And we did some experimentation with Seam-gen on JBoss 4.2. It’s a bit tricky to track down these things but it does all work once everything is right. And once it all works, it is quite amazing what it can do.
August 1st, 2007 at 2:36 pm
I am having trouble getting my app ported from JBoss AS 4.0.5 to 4.2.1 - I’ve followed the advice and comments on this page and have gotten _very_ close. My app starts up and behaves properly until I submit a form that triggers a Hibernate Validators validation error - then I get a bizzare EL error saying it can’t resolve the s:hasRole EL function used in a render attribute in my menu.xhtml (which, fwiw, renders fine for all cases except failed validation).
http://www.jboss.com/index.html?module=bb&op=viewtopic&t=114722&postdays=0&postorder=desc&start=0
Is this a familiar symptom to anyone?
I’ve posted complete details of all the changes (which should summarize what others have been posting here), as well as my stack trace. I’ve compared by config with the ajax4jsf example from Michael’s book - I can’t spot a difference. Can anyone help?
Thanks much!
August 1st, 2007 at 5:52 pm
We have run into exactly the same problem of s:hasRole in JBoss 4.2. Click that link to read what we have found on that. Bottom line: We tried the obvious stuff and none of it works. We ended up working around the problem by using rendered=”#{currentUser.admin}” instead of the hasRole stuff. The problem is that Seam’s security code has the Sun RI hard-coded in. That means if you supply the Sun RI implementation jar, that gets it working during the phase when the sec. annotations are being processed on class files. However, only one EL implementation can be used during the page processing, and if it is the Sun EL, it breaks everything, and if it’s not the Sun EL, it breaks the UI hasRole annotations.
So you must work around it for now. Fortunately for me, our only use of this hasRole UI switch is in a menu.xhtml file so when the next release of Seam comes out this won’t be a problem.
August 1st, 2007 at 5:55 pm
And to be clear about it, this is definitely a bug in Seam 1.2.1. Two files include the Sun RI packages, and they should not, because Seam 1.2 should not have any dependencies on Sun EL RI. This will be fixed, so just work around it by not using the role-based rendered switch in UI components for now (ie, rendered=”#{currentUser.admin}” if there is a User.isAdmin() method).
August 1st, 2007 at 7:34 pm
Thank you Chiral! I’d read your blog postings, but had not put two and two together. Thanks for confirming the behavior and the proposed work around — I’ll review our code and see if it’s something we can adapt.
August 11th, 2007 at 9:48 pm
I tried building your HelloWorld example with JBoss AS 4.2.1 GA and Seam 1.2.1 GA. I get the start page, but on pressing the Say Hello button, I get this exception:
javax.faces.FacesException: #{manager.sayHello}:
javax.faces.el.EvaluationException: javax.ejb.EJBException: java.lang.RuntimeException: java.lang.LinkageError: javax/persistence/Query
Any ideas?
Thanks,
S.
August 21st, 2007 at 6:24 pm
I have not been able to get the seam jpa example working on websphere. [Tried Seam 2.0.0.BETA1 & 1.2.1GA with both WAS xpress 6.1.1 & WAS std 6.1.0.3...most success with WAS express & 2.0.0BETA1]
It deploys but all actions fail. Could it be related to:
java.lang.ClassCastException: org.jboss.seam.persistence.EntityManagerFactory incompatible with javax.persistence.EntityManagerFactory
My understanding is that WAS does not support EJB 3.0 without a beta feature pack. Is this example using the embeddable EJB3.0?
Any pointers would be really appreciated. (I’m new to seam & WAS, so could easily be a config issue.) Thanks.
August 23rd, 2007 at 11:46 am
[...] Luckily, those steps are chronicled here (by Michael Yuan) and here (by Nicolas Leroux). Oh, and Michael’s site has updated samples from his book. [...]
August 27th, 2007 at 4:50 am
hi michael,
I was looking for the portal example in the “17 examples” but couldn’t find one? Do u have any example for the portal case?
Thanks.
October 2nd, 2007 at 1:33 am
Hi Michael,
You have published a very good example’s, which would make any one comfortable to start working with seams in jboss, but it would be good to have some working example which would work with weblogic 10 and any latest application server which supports jee5.
By this I am sure that seam would be one of the favourite frame works of any j2ee developer in future.
As I still have lot of issue in deploying the seam sample application in weblogic 10 and which really stops me to use this frame work in our future development.
Thanks
October 2nd, 2007 at 9:44 am
For non-JBoss examples, please see the “jpa” and “jee5″ examples in Seam distribution.
But the last time I tried WebLogic 10, it has some EJB3 issues. So, for now, you can only use JPA + Seam POJO in WebLogic 10.
October 15th, 2007 at 1:56 pm
HI Micheal yuan
I have read almost all the chapters in your boook. Real cool stuff…no junk
I’m new to J2EE but want to start with the currrent technologies. Well i want to also do real time developments. I’ve been trying for a month to develop a crud example with RHDS. its always given me a problem. I’ve managed to get around all the obstacles except one that says FaroukOnline not bound…well i dont kno want that means….and nothing i’ve done has worked.
So i stoped using that ide.
I have developed an enterprise application with EJB3 and JSF without seam in netbeans 6. done all the redundant coding since Seam made it all easy. I want to deploy on JBoss 4.2.1 that ejb deploys but the client doesnt…i get error 404 but the war is in the deploy folder
please help me
and how can i use seam in netbeans 6 since there is no update center option in the tools drop down
December 14th, 2007 at 7:58 am
hi i get:
java.lang.NoClassDefFoundError: javax/el/ELResolver
if i remove the el-ri-jboss-seam-1.2.1.GA.jar, i get more error about el…
and ELResolver is included in this packages
January 17th, 2008 at 9:45 am
Hi Michael,
I’ve built helloworld.ear as described in
chapter 2. I am using JBoss 4.2.1.GA, jboss-seam-2.0.0.GA, JDK 1.6.0_03.
At JBoss deployment time I have the following exceptions:
10:23:30,068 WARN [ServiceController] Problem starting service jboss.web.deploy
ment:war=app.war,id=1562089102
org.jboss.deployment.DeploymentException: URL file:/C:/jboss-4.2.1.GA/server/def
ault/tmp/deploy/tmp55842helloworld.ear-contents/app-exp.war/ deployment failed
at org.jboss.web.tomcat.service.TomcatDeployer.performDeployInternal(Tom
catDeployer.java:379)
at org.jboss.web.tomcat.service.TomcatDeployer.performDeploy(TomcatDeplo
yer.java:104)
at org.jboss.web.AbstractWebDeployer.start(AbstractWebDeployer.java:375)
————————-
Any idea what’s going on and how to fix the problem.
Regards,
Vitaly
January 18th, 2008 at 10:09 am
Hi Michael
You said for for non-JBoss examples, please see the “jpa” and “jee5″ examples in Seam distribution. I am trying to run “tomcatjpa” example from seam book on tomcat and I am getting
Error configuring application listener of class com.sun.faces.config.ConfigureListener
java.lang.NoClassDefFoundError: javax/el/CompositeELResolver
I have succesfully run “tomcatjpa” with old seam book distribution ( before you updated to 2.0.0).
I followed all steps in your book to run “tomcatjpa” application. Are there any changes in steps for seam 2.0.0?
Geeta
January 25th, 2008 at 10:49 am
I solved the problem.