9 Replies Latest reply on Jul 27, 2009 6:04 PM by Arbi Sookazian

    No query is executed

    Hussein Baghdadi Novice


      Would you please check this:

      public class GroupManager implements Serializable {
          private EntityManager entityManager;
          private List<Group> groupList;
          public void loadGroups() {
              groupList = entityManager.createQuery("select grp from Group grp").getResultList();

                  <h:dataTable var="grp" value="#{groupList}">
                          <f:facet name="header">
                              <h:outputText value="Name"/>
                          <h:outputText value="#{grp.name}"/>

      Upon requesting groups.seam , the data table is empty and no HQL query is executed (according to the log file) and there is no exception at all during the booting.

      Any ideas what is might going wrong?

      Tomcat 6.0.18

      Seam 2.1.2

      Thanks for help and time.

        • 1. Re: No query is executed
          Shervin Asgari Master

          Have you copied and run the SQL generated to see if there is any output? Maybe the data is empty

          • 2. Re: No query is executed
            Hussein Baghdadi Novice
            No SQL is generated at all (show_sql is set to true).

            The database is loaded with data.
            • 3. Re: No query is executed
              Shervin Asgari Master

              Oh I'm sorry, I thought you wrote the oposite.
              Your code looks fine to me.

              In persistence.xml

                       <property name="hibernate.show_sql" value="true"/>
                       <property name="hibernate.format_sql" value="true"/>

              Does the entityManager work other places? Or only with this code it fails?

              • 4. Re: No query is executed
                Hussein Baghdadi Novice

                This is my first page/action.

                The log shows no exception at all.

                • 5. Re: No query is executed
                  Shervin Asgari Master

                  Then maybe you haven't set your persistence.xml or components.xml correctly up. Did you use seam-gen to create the project? That is advisable.

                  • 6. Re: No query is executed
                    Hussein Baghdadi Novice

                    Yes, I used seam-gen to generate the application but then I tweaked it by hand in order to make it run on tomcat.

                        <persistence-unit name="SmsBulkSend" transaction-type="RESOURCE_LOCAL">
                                <property name="hibernate.dialect" value="org.hibernate.dialect.MySQL5Dialect"/>
                                <property name="hibernate.hbm2ddl.auto" value="validate"/>
                                <property name="hibernate.jdbc.batch_size" value="20"/>

                        <core:manager concurrent-request-timeout="500"
                        <web:hot-deploy-filter url-pattern="*.seam"/>
                        <persistence:entity-manager-factory name="SmsBulkSend" persistence-unit-name="SmsBulkSend"/>
                        <persistence:managed-persistence-context name="entityManager" auto-create="true"
                        <transaction:entity-transaction entity-manager="#{entityManager}"/>

                    • 7. Re: No query is executed
                      Hussein Baghdadi Novice

                      Hey, I found the problem.

                      I was deploying the exploded application to Tomcat, it seems to me it is a feature for JBoss AS based development.

                      • 8. Re: No query is executed
                        Arbi Sookazian Master

                        From 2.1.2\examples\readme.txt:

                        How to Build and Deploy the Example on Tomcat
                        1. Download and install Tomcat 6
                           NOTE: Due to a bug, you must install Tomcat to a directory
                           path with no spaces. The example does not work in a default
                           install of Tomcat.
                        2. Install Embedded JBoss as described in the "Configuration" chapter of the
                           Seam reference documentation. 
                        3. Make sure you have an up to date version of Seam: 
                        4. Open the "build.properties" file at the root of the Seam distribution in
                           your editor and change tomcat.home to point to your Tomcat directory
                        5. (Optional) Build Seam by running "ant" the Seam root directory
                           Only required if you are working from an SVN checkout.
                        6. Build and deploy the example by running the following command from the Seam
                           "examples/${example.name}" directory:
                           ant tomcat.deploy
                           To undeploy the example, run:
                           ant tomcat.undeploy
                           To redeploy/restart the deployed application, run:
                           ant tomcat.deploy
                        7. Start Tomcat
                        8. Point your web browser to:
                           Note that examples deployed to Tomcat use the context path prefix
                           jboss-seam- rather than seam- like with the JBoss AS deployment.

                        also, look at the jpa example for guidance with tomcat config/deploy.

                        Tomcat with JBoss Embedded:
                          * Install Tomcat
                          * Install JBoss Embedded
                          * ant jboss-embedded
                          * Deploy dist-jboss-embedded/jboss-seam-jpa.war
                          * Start Tomcat
                          * Access the app at http://localhost:8080/jboss-seam-jpa/
                        Tomcat (5.5 or 6) without JBoss Embedded:
                          * Install Tomcat
                          * Copy lib/hsqldb.jar from this distribution into $TOMCAT_HOME/common/lib (Tomcat 5.5) or $TOMCAT_HOME/lib (Tomcat 6)
                          * ant tomcat55 or ant tomcat6
                          * Deploy dist-jboss/jboss-seam-jpa.war
                          * Start Tomcat
                          * Access the app at http://localhost:8080/jboss-seam-jpa/

                        • 9. Re: No query is executed
                          Arbi Sookazian Master

                          I just built and deployed the jpa example onto tomcat 6 successfully.


                          <Context path="/jboss-seam-jpa" docBase="jboss-seam-jpa"
                                  debug="5" reloadable="true" crossContext="true">
                            <Resource name="jdbc/TestDB" auth="Container" type="javax.sql.DataSource"
                                         maxActive="100" maxIdle="30" maxWait="10000"
                                         username="sa" driverClassName="org.hsqldb.jdbcDriver"


                          <?xml version="1.0" encoding="UTF-8"?>
                          <components xmlns="http://jboss.com/products/seam/components"
                                          "http://jboss.com/products/seam/core http://jboss.com/products/seam/core-2.1.xsd 
                                           http://jboss.com/products/seam/persistence http://jboss.com/products/seam/persistence-2.1.xsd 
                                           http://jboss.com/products/seam/transaction http://jboss.com/products/seam/transaction-2.1.xsd 
                                           http://jboss.com/products/seam/security http://jboss.com/products/seam/security-2.1.xsd
                                           http://jboss.com/products/seam/components http://jboss.com/products/seam/components-2.1.xsd">
                              <core:manager conversation-timeout="120000" 
                              <transaction:entity-transaction entity-manager="#{em}"/>
                              <persistence:entity-manager-factory name="bookingDatabase"/>
                              <persistence:managed-persistence-context name="em"
                              <security:identity authenticate-method="#{authenticator.authenticate}"/>  


                          <?xml version="1.0" encoding="UTF-8"?>
                          <persistence xmlns="http://java.sun.com/xml/ns/persistence" 
                                       xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd" 
                             <persistence-unit name="bookingDatabase" transaction-type="RESOURCE_LOCAL">
                                   <property name="hibernate.hbm2ddl.auto" value="create-drop"/>
                                   <property name="hibernate.show_sql" value="true"/>
                                   <property name="hibernate.cache.provider_class" value="org.hibernate.cache.HashtableCacheProvider"/>
                                   <!-- RESOURCE_LOCAL
                                   <property name="hibernate.transaction.manager_lookup_class" value="org.hibernate.transaction.JBossTransactionManagerLookup"/>
                                   <!-- alternative
                                   <property name="jboss.entity.manager.factory.jndi.name"