8 Replies Latest reply on Apr 15, 2010 7:42 AM by shavo26

    Problems with crud application generated using Seamgen

    chrismalan

      The application is the Seam in Action exploded war example.  I used JBoss 5.0.0.GA and Seam 2.1.0.SP1.  Everything works up to and including getting the generated home page in the browser.  There are some links at the top, mainly collections of entities and one log in link.  Logging in works fine.  However, clicking on any other link throws the following exceptions:


      javax.faces.FacesException: javax.el.ELException: /FacilityList.xhtml @99,61 rendered="#{empty facilityList.resultList}": Error reading 'resultList' on type org.open18.action.FacilityList_$$_javassist_4
      ...
      Caused by: java.lang.IllegalArgumentException: org.hibernate.hql.ast.QuerySyntaxException: Facility is not mapped [select facility from Facility facility]




      I got it to work on another machine deploying the whole thing as an archived ear.  A war caused the same problems.  Spending a lot of time looking at the generated code was fruitless.


      This has been reported in early October.  See https://jira.jboss.org/jira/browse/JBSEAM-3501


      The last word on it was



      Pete Muir - 03/Oct/08 11:41 AM
      Stan, I can reproduce with any seam-gen project e.g. the release test database. I don't think this has anything to do with Seam, but is about how Hibernate is mapping entities in the WAR (they are mapped, but the query fails?!).

      Could you take a look?

      I could find nothing else on it.  This problem still seems to be alive and well and living with its parents, Seam and Hibernate.  Anyway to get past this?  I want to try out the hot deployment of code changes that come with an exploded war.

        • 1. Re: Problems with crud application generated using Seamgen
          chrismalan

          A quick update:  before going to work I quickly deployed the app to JBoss-4.2.2.GA.  No problems now.  Everything works as it should.


          The same Seam-2.1.0, the same code generated by Seam.  The finger points to JBoss-5.0.0.  What worked once does not work anymore.  If it ain't broken, forget about not fixing it, break it?  BTW, 4.2.2 starts 30 seconds faster than 5.0.0 on my system - Gentoo Linux, Sun JDK 1.6, 2MB Ram.

          • 2. Re: Problems with crud application generated using Seamgen
            hapacur

            Any updates on that subject? Is there a fix for JBoss AS 5.0.0 ?

            • 3. Re: Problems with crud application generated using Seamgen
              oguzyalcin.oguzhanyalcin.gazi.edu.tr

              Hi, In another topic someone mentioned same error. I2ve faced with this error on jboss as 5.0. I think the problem is with the jndi and persistencecontext. You can jump over this exception by simply adding your entities into the persistence.xml file like


              <class>your.package.entiy.entityname</class>



              Persitence.xml is under your src/main/META-INF folder.

              • 4. Re: Problems with crud application generated using Seamgen
                chrismalan

                Hi Oguzhan,


                Thanks.  This worked perfectly. 


                Chris Malan

                • 5. Re: Problems with crud application generated using Seamgen
                  worldofnic

                  On JBossAS 5.1.0.GA with Seam 2.1.2, this fix doesn't work. :-(


                  (I'm using Sun Java 1.6.0_12 on 32-bit Vista).


                  Anyone any idea?


                     <persistence-unit name="cron" transaction-type="JTA">
                        <provider>org.hibernate.ejb.HibernatePersistence</provider>
                        <jta-data-source>java:/cronDatasource</jta-data-source>
                        <class>org.domain.cron.entity.Dbcron</class>
                        <properties>
                           <property name="hibernate.dialect" value="org.hibernate.dialect.PostgreSQLDialect"/>
                           <property name="hibernate.hbm2ddl.auto" value="create"/>
                           <property name="hibernate.show_sql" value="true"/>
                           <property name="hibernate.format_sql" value="true"/>
                           <property name="hibernate.default_schema" value="nems"/>
                           <!-- Only relevant if Seam is loading the persistence unit (Java SE bootstrap) -->
                           <property name="hibernate.transaction.manager_lookup_class" value="org.hibernate.transaction.JBossTransactionManagerLookup"/>
                                </properties>
                     </persistence-unit>
                  



                  Yet I still get:






                  Caused by: org.hibernate.hql.ast.QuerySyntaxException: Dbcron is not mapped [select dbcron from Dbcron dbcron]



                  This is making a mockery of getting seam up and running quickly :-(


                  nic



                  • 6. Re: Problems with crud application generated using Seamgen
                    chrismalan

                    Hi Nic,


                    Try removing the transaction-type="JTA">  See if that makes any difference. Your last property seems to indicate the hibernate transaction manager.  I don't have that line
                    (<property name="hibernate.transaction.manager_lookup_class" value="org.hibernate.transaction.JBossTransactionManagerLookup"/>), either.


                    Chris


                    • 7. Re: Problems with crud application generated using Seamgen
                      vrxyz
                      Hi,

                      I tried adding this <class>org.domain.oneseamproj.entity.Orgperson</class> into the persistence.xml but I still get the error:

                      Caused by: java.lang.IllegalArgumentException: org.hibernate.hql.ast.QuerySyntaxException: Orgperson is not mapped [select orgperson from Orgperson orgperson]

                      I tried the one suggested by Chris, removing the <property name="hibernate.transaction.manager_lookup_class" value="org.hibernate.transaction.JBossTransactionManagerLookup"/> from the file. But still, I get that error.

                      I'm using BossAS 5.1.0.GA with Seam 2.2.0.GA.

                      Please help me solve this. Thanks in advance! :)
                      • 8. Re: Problems with crud application generated using Seamgen
                        shavo26

                        I found this problem too on jboss 5.1.0.GA and using seam 2.2 when deploying dan allens seam in action example.


                        He explains the problem here:
                        JBossASIssue


                        So in web.xml i added element persistence-unit-ref:



                        <persistence-unit-ref>
                          <persistence-unit-ref-name>open18/emf</persistence-unit-ref-name>
                          <persistence-unit-name>open18</persistence-unit-name>
                         </persistence-unit-ref>





                        and in components.xml



                         <persistence:managed-persistence-context  name="entityManager"
                                                                        persistence-unit-jndi-name="java:comp/env/open18/emf"
                                                             auto-create="true"/>





                        removing attribute entity-manager-factory.


                        Deployed again and this exception did not occur.