12 Replies Latest reply on Feb 15, 2006 4:50 PM by Gavin King

    Help getting started with Seam

    Bradley Smith Master

      Hello,

      I downloaded jboss-seam-1.0beta2, pointed Jboss IDE hibernate tools at my DB and generated a simple seam app. I successfully ran the ant script and compiled/deployed my generated app. The app comes up fine, however, once I get into the CRUD screens I am getting errors when I try to create new records in my table(s).

      15:23:44,780 ERROR [[/seamapp]] Cannot set value for expression '#{ssouserEditor.instance.id}' to a new value of type java.lang.String
      javax.faces.el.EvaluationException: Cannot set value for expression '#{ssouserEditor.instance.id}' to a new value of type java.lang.String
       at org.apache.myfaces.el.ValueBindingImpl.setValue(ValueBindingImpl.java:304)
       at javax.faces.component.UIInput.updateModel(UIInput.java:226)
       at javax.faces.component.UIInput.processUpdates(UIInput.java:165)
       at javax.faces.component.UIComponentBase.processUpdates(UIComponentBase.java:428)
       at javax.faces.component.UIForm.processUpdates(UIForm.java:85)
       at javax.faces.component.UIComponentBase.processUpdates(UIComponentBase.java:428)
       at javax.faces.component.UIViewRoot.processUpdates(UIViewRoot.java:153)
       at org.apache.myfaces.lifecycle.LifecycleImpl.updateModelValues(LifecycleImpl.java:277)
       at org.apache.myfaces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:81)
       at javax.faces.webapp.FacesServlet.service(FacesServlet.java:106)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
       at org.jboss.seam.servlet.SeamExceptionFilter.doFilter(SeamExceptionFilter.java:44)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
       at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
       at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
       at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
       at org.jboss.web.tomcat.security.CustomPrincipalValve.invoke(CustomPrincipalValve.java:54)
       at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:174)
       at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:74)
       at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
       at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
       at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
       at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
       at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:868)
       at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:663)
       at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
       at org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112)
       at java.lang.Thread.run(Thread.java:595)
      Caused by: javax.faces.el.EvaluationException: com.sso.domain.SsoUser
       at org.apache.myfaces.el.PropertyResolverImpl.setValue(PropertyResolverImpl.java:155)
       at org.apache.myfaces.el.ValueBindingImpl.setValue(ValueBindingImpl.java:269)
       ... 31 more
      Caused by: javax.faces.el.EvaluationException: Bean: com.sso.domain.SsoUser, property: id
       at org.apache.myfaces.el.PropertyResolverImpl.setProperty(PropertyResolverImpl.java:372)
       at org.apache.myfaces.el.PropertyResolverImpl.setValue(PropertyResolverImpl.java:148)
       ... 32 more
      Caused by: java.lang.IllegalArgumentException: argument type mismatch
       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
       at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
       at java.lang.reflect.Method.invoke(Method.java:585)
       at org.apache.myfaces.el.PropertyResolverImpl.setProperty(PropertyResolverImpl.java:368)
       ... 33 more
      


      Is this familiar? obvious? Any help appreciated - thanks.



        • 1. Re: Help getting started with Seam
          Gavin King Master

          What type is ssouser.id?

          • 2. Re: Help getting started with Seam
            Bradley Smith Master

            Other notes - I generated this from a SQL Server database with two tables. Here is the hibernate tools script that generated this DB:

            create table sso_user (
             id numeric(19,0) identity not null,
             a_number varchar(255) not null unique,
             primary key (id)
            )
            create table user_link (
             id numeric(19,0) identity not null,
             user_id numeric(19,0) not null,
             url varchar(255) not null,
             title varchar(255) not null,
             description varchar(255) null,
             view_order numeric(19,0) null,
             update_date datetime not null,
             create_date datetime not null,
             primary key (id)
            )
            alter table user_link
             add constraint fk_user_link__user
             foreign key (user_id)
             references sso_user
            Feb 14, 2006 2:59:28 PM org.hibernate.tool.hbm2ddl.SchemaExport execute
            




            package com.sso.domain;
            // Generated Feb 14, 2006 3:20:16 PM by Hibernate Tools 3.1.0.beta4
            
            import java.math.BigDecimal;
            import java.util.HashSet;
            import java.util.Set;
            import javax.persistence.CascadeType;
            import javax.persistence.Column;
            import javax.persistence.Entity;
            import javax.persistence.FetchType;
            import javax.persistence.Id;
            import javax.persistence.OneToMany;
            import javax.persistence.Table;
            import javax.persistence.UniqueConstraint;
            
            
            /**
             * SsoUser generated by hbm2java
             */
            @Entity
            @Table(name="sso_user"
            , uniqueConstraints = { @UniqueConstraint( columnNames = { "a_number" } ) }
            )
            
            public class SsoUser implements java.io.Serializable {
            
            
             // Fields
            
             private BigDecimal id;
             private String ANumber;
             private Set<UserLink> userLinks = new HashSet<UserLink>(0);
            
            
             // Constructors
            
             /** default constructor */
             public SsoUser() {
             }
            
             /** minimal constructor */
             public SsoUser(BigDecimal id, String ANumber) {
             this.id = id;
             this.ANumber = ANumber;
             }
            
             /** full constructor */
             public SsoUser(BigDecimal id, String ANumber, Set<UserLink> userLinks) {
             this.id = id;
             this.ANumber = ANumber;
             this.userLinks = userLinks;
             }
            
            
            
             // Property accessors
             @Id
             @Column(name="id", unique=true, nullable=false, insertable=true, updatable=true, scale=0)
            
             public BigDecimal getId() {
             return this.id;
             }
            
             public void setId(BigDecimal id) {
             this.id = id;
             }
             @Column(name="a_number", unique=true, nullable=false, insertable=true, updatable=true)
            
             public String getANumber() {
             return this.ANumber;
             }
            
             public void setANumber(String ANumber) {
             this.ANumber = ANumber;
             }
             @OneToMany(cascade={CascadeType.ALL}, fetch=FetchType.LAZY, mappedBy="ssoUser")
            
             public Set<UserLink> getUserLinks() {
             return this.userLinks;
             }
            
             public void setUserLinks(Set<UserLink> userLinks) {
             this.userLinks = userLinks;
             }
            
            }
            


            • 3. Re: Help getting started with Seam
              Gavin King Master

              OK, I have not tested the Seam templates with BigDecimal properties. I had understood that JSF has a default converter for BigDecimal, but this may be wrong.

              Does anyone know how to handle this in JSF?

              • 4. Re: Help getting started with Seam
                Bradley Smith Master

                I appreciate the quick responses. Anyway, I don't need to use BigDecimal - long would be fine...do you have some suggestion for customizing the generation of these entity beans?

                THanks,
                Brad

                • 5. Re: Help getting started with Seam
                  Gavin King Master

                  Yes, the tool lets you customize JDBC type mappings. look at the hibernate.reveng.xml editor....

                  • 6. Re: Help getting started with Seam
                    Gavin King Master

                    Jacob says try adding:

                    converter="javax.faces.BigDecimal"

                    to the JSF component.

                    • 7. Re: Help getting started with Seam
                      Bradley Smith Master

                      Sorry to bug you more, but I am having trouble with the hibernate tools.

                      I tried creating a hibernate.reveng.xml file that looks like this:

                      <?xml version="1.0" encoding="UTF-8"?>
                      <!DOCTYPE hibernate-reverse-engineering PUBLIC "-//Hibernate/Hibernate Reverse Engineering DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-reverse-engineering-3.0.dtd" >
                      
                      <hibernate-reverse-engineering>
                       <table-filter match-name="sso_user" />
                       <table-filter match-name="user_link" />
                       <table name="sso_user">
                       <column name="id" jdbc-type="numeric" type="long" />
                       </table>
                       <table name="user_link">
                       <column name="id" jdbc-type="numeric" type="long" />
                       <column name="user_id" jdbc-type="numeric" type="long" />
                       </table>
                      </hibernate-reverse-engineering>
                      


                      However, it won't run successfully -

                      org.hibernate.MappingException: Could not configure overrides from file: C:\....blah blah....\hibernate.reveng.xml

                      Any tips?
                      Thanks again,
                      Brad

                      • 8. Re: Help getting started with Seam
                        Bradley Smith Master

                        My latest adventure with Seam is that the CRUD generator is generating duplicates of the some of the beans and methods.

                        sigh...

                        • 9. Re: Help getting started with Seam
                          Max Rydahl Andersen Master

                          what duplicates and what sigh ?

                          btw. that exception should have a stracktrace showing what is the root cause ...most likely a typo somewhere...e.g. numeric is probably not being accepted. Try and enter NUMERIC instead.

                          • 10. Re: Help getting started with Seam
                            Bradley Smith Master

                            First, duplicates:

                            After running the Seam generator in Eclipse, I do an Ant build - I get this:

                            Buildfile: C:\Documents and Settings\A428302\workspace\userlinks\build.xml
                            init:
                             [echo] Build Seam Application
                            compile:
                             [javac] Compiling 12 source files to C:\Documents and Settings\A428302\workspace\userlinks\build\classes
                             [javac] C:\Documents and Settings\A428302\workspace\userlinks\src\com\sso\domain\SsoUserSelector.java:135: com.sso.domain.SsoUserSelector.UserLinkSsoUserSelector is already defined in com.sso.domain.SsoUserSelector
                             [javac] public static class UserLinkSsoUserSelector implements SsoUserSelector {
                             [javac] ^
                             [javac] C:\Documents and Settings\A428302\workspace\userlinks\src\com\sso\domain\SsoUserEditor.java:25: createUserLink() is already defined in com.sso.domain.SsoUserEditor
                             [javac] public String createUserLink();
                             [javac] ^
                             [javac] C:\Documents and Settings\A428302\workspace\userlinks\src\com\sso\domain\SsoUserEditor.java:26: selectUserLink() is already defined in com.sso.domain.SsoUserEditor
                             [javac] public String selectUserLink();
                             [javac] ^
                             [javac] C:\Documents and Settings\A428302\workspace\userlinks\src\com\sso\domain\SsoUserEditorBean.java:148: selectedUserLink is already defined in com.sso.domain.SsoUserEditorBean
                             [javac] private UserLink selectedUserLink;
                             [javac] ^
                             [javac] C:\Documents and Settings\A428302\workspace\userlinks\src\com\sso\domain\SsoUserEditorBean.java:151: userlinkEditor is already defined in com.sso.domain.SsoUserEditorBean
                             [javac] private transient UserLinkEditor userlinkEditor;
                             [javac] ^
                             [javac] C:\Documents and Settings\A428302\workspace\userlinks\src\com\sso\domain\SsoUserEditorBean.java:153: createUserLink() is already defined in com.sso.domain.SsoUserEditorBean
                             [javac] public String createUserLink() {
                             [javac] ^
                             [javac] C:\Documents and Settings\A428302\workspace\userlinks\src\com\sso\domain\SsoUserEditorBean.java:161: selectUserLink() is already defined in com.sso.domain.SsoUserEditorBean
                             [javac] public String selectUserLink() {
                             [javac] ^
                             [javac] Note: Some input files use unchecked or unsafe operations.
                             [javac] Note: Recompile with -Xlint:unchecked for details.
                             [javac] 7 errors
                            
                            BUILD FAILED
                            C:\Documents and Settings\A428302\workspace\userlinks\build.xml:116: Compile failed; see the compiler error output for details.
                            
                            Total time: 3 seconds
                            
                            


                            When follow the first error, I find this:

                            package com.sso.domain;
                            // Generated Feb 15, 2006 12:32:42 PM by Hibernate Tools 3.1.0.beta4
                            
                            import java.util.ResourceBundle;
                            import javax.ejb.Interceptors;
                            import javax.ejb.Local;
                            import javax.ejb.Stateless;
                            import org.jboss.annotation.ejb.LocalBinding;
                            import static org.jboss.seam.ScopeType.CONVERSATION;
                            import org.jboss.seam.annotations.Begin;
                            import org.jboss.seam.annotations.In;
                            import org.jboss.seam.annotations.JndiName;
                            import org.jboss.seam.annotations.Name;
                            import org.jboss.seam.ejb.SeamInterceptor;
                            
                            
                            
                            @Local
                            public interface SsoUserSelector {
                            
                             public String select();
                             public String selectNone();
                            
                             public String getButtonLabel();
                             public String getPageTitle();
                            
                             public String cancel();
                            
                             public boolean isCreateEnabled();
                            
                             @Stateless
                             @Name("ssouserSelector")
                             @Interceptors(SeamInterceptor.class)
                             public static class DefaultSsoUserSelector implements SsoUserSelector {
                            
                             @In
                             private transient ResourceBundle resourceBundle;
                            
                             @In(create=true)
                             private transient SsoUserEditor ssouserEditor;
                            
                             @In(create=true)
                             private transient SsoUserFinder ssouserFinder;
                            
                             @Begin
                             public String select() {
                             ssouserEditor.setInstance( ssouserFinder.getSelection() );
                             ssouserEditor.setNew(false);
                             return "editSsoUser";
                             }
                            
                             public String selectNone() {
                             throw new UnsupportedOperationException();
                             }
                            
                             public String getButtonLabel() {
                             return resourceBundle.getString("View");
                             }
                            
                             public String cancel() {
                             throw new UnsupportedOperationException();
                             }
                            
                             public String getPageTitle() {
                             return resourceBundle.getString("Find") + " " +
                             resourceBundle.getString("SsoUser");
                             }
                            
                             public boolean isCreateEnabled() {
                             return true;
                             }
                            
                             }
                            
                             @Stateless
                             @Name("userlinkSsoUserSelector")
                             @LocalBinding(jndiBinding="com.sso.domain.UserLinkSsoUserSelector")
                             @JndiName("com.sso.domain.UserLinkSsoUserSelector")
                             @Interceptors(SeamInterceptor.class)
                             public static class UserLinkSsoUserSelector implements SsoUserSelector {
                            
                             @In
                             private transient ResourceBundle resourceBundle;
                            
                             @In(create=true)
                             private transient SsoUserFinder ssouserFinder;
                            
                             @In
                             private transient UserLinkEditor userlinkEditor;
                            
                             private void completed() {
                             CONVERSATION.getContext().remove("ssouserSelector");
                             }
                            
                             public String select() {
                             userlinkEditor.getInstance().setSsoUser( ssouserFinder.getSelection() );
                             //TODO: add child to collection on instance!!
                             completed();
                             return "editUserLink";
                             }
                            
                             public String selectNone() {
                             userlinkEditor.getInstance().setSsoUser(null);
                             completed();
                             return "editUserLink";
                             }
                            
                             public String cancel() {
                             completed();
                             return "editUserLink";
                             }
                            
                             public String getButtonLabel() {
                             return resourceBundle.getString("Select");
                             }
                            
                             public String getPageTitle() {
                             return resourceBundle.getString("Select") + " " +
                             resourceBundle.getString("SsoUser") + " " +
                             resourceBundle.getString("For") + " " +
                             resourceBundle.getString("UserLink");
                             }
                            
                             public boolean isCreateEnabled() {
                             return false;
                             }
                            
                             }
                            
                             @Stateless
                             @Name("userlinkSsoUserSelector")
                             @LocalBinding(jndiBinding="com.sso.domain.UserLinkSsoUserSelector")
                             @JndiName("com.sso.domain.UserLinkSsoUserSelector")
                             @Interceptors(SeamInterceptor.class)
                             public static class UserLinkSsoUserSelector implements SsoUserSelector {
                            
                             @In
                             private transient ResourceBundle resourceBundle;
                            
                             @In(create=true)
                             private transient SsoUserFinder ssouserFinder;
                            
                             @In
                             private transient UserLinkEditor userlinkEditor;
                            
                             private void completed() {
                             CONVERSATION.getContext().remove("ssouserSelector");
                             }
                            
                             public String select() {
                             userlinkEditor.getInstance().setSsoUser( ssouserFinder.getSelection() );
                             //TODO: add child to collection on instance!!
                             completed();
                             return "editUserLink";
                             }
                            
                             public String selectNone() {
                             userlinkEditor.getInstance().setSsoUser(null);
                             completed();
                             return "editUserLink";
                             }
                            
                             public String cancel() {
                             completed();
                             return "editUserLink";
                             }
                            
                             public String getButtonLabel() {
                             return resourceBundle.getString("Select");
                             }
                            
                             public String getPageTitle() {
                             return resourceBundle.getString("Select") + " " +
                             resourceBundle.getString("SsoUser") + " " +
                             resourceBundle.getString("For") + " " +
                             resourceBundle.getString("UserLink");
                             }
                            
                             public boolean isCreateEnabled() {
                             return false;
                             }
                            
                             }
                            
                            }
                            
                            


                            --notice the UserLinkSsoUserSelector class is generated twice (hence the duplicate).

                            Second, "sigh"... well, this is mildly frustrating and tiresome. I was at Gavin's demo in Boston - I thought the demo and his arguments for using Seam as well as the feature set make it compelling. However, with all the issues I am having, I feel that this particular release is more correctly categorized as either an "early access" or an "alpha" release but not beta. Note that I haven't even mentioned that there is an error in the generated seam.properties which must be corrected each time as well (I believe that error is mentioned elsewhere on this forum).

                            Cheers,
                            Brad

                            • 11. Re: Help getting started with Seam
                              Gavin King Master

                              The reverse engineering tool is most certainly of alpha quality, and the "beta" appellation refers to the Seam core itself, which is completely different to the reveng tool.

                              It would be much more helpful if you submitted issues to Hibernate Tools JIRA, so that we can fix them.