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

    No query is executed

    hubaghdadi

      Hey,


      Would you please check this:


      @Name("groupManager")
      @Scope(ScopeType.CONVERSATION)
      public class GroupManager implements Serializable {
      
          @In
          private EntityManager entityManager;
      
          @DataModel
          private List<Group> groupList;
      
          @SuppressWarnings("unchecked")
          @Factory("groupList")
          public void loadGroups() {
              groupList = entityManager.createQuery("select grp from Group grp").getResultList();
          }
          
      }





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



      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
          cash1981

          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
            hubaghdadi
            No SQL is generated at all (show_sql is set to true).

            The database is loaded with data.
            • 3. Re: No query is executed
              cash1981

              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
                hubaghdadi

                This is my first page/action.


                The log shows no exception at all.

                • 5. Re: No query is executed
                  cash1981

                  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
                    hubaghdadi

                    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">
                            <provider>org.hibernate.ejb.HibernatePersistence</provider>
                            <jta-data-source>java:comp/env/jdbc/SmsBulkSendDS</jta-data-source>
                            <properties>
                                <property name="hibernate.dialect" value="org.hibernate.dialect.MySQL5Dialect"/>
                                <property name="hibernate.hbm2ddl.auto" value="validate"/>
                                <property name="hibernate.jdbc.batch_size" value="20"/>
                            </properties>
                        </persistence-unit>





                        <core:manager concurrent-request-timeout="500"
                                      conversation-timeout="120000"
                                      conversation-id-parameter="cid"
                                      parent-conversation-id-parameter="pid"/>
                    
                        <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"
                                                                 entity-manager-factory="#{SmsBulkSend}"/>
                    
                        <transaction:entity-transaction entity-manager="#{entityManager}"/>





                    • 7. Re: No query is executed
                      hubaghdadi

                      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
                        asookazian

                        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: 
                        
                           http://seamframework.org/Download
                        
                        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:
                        
                           http://localhost:8080/jboss-seam-${example.name}
                           
                           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
                          asookazian

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


                          context.xml:


                          <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"
                                         url="jdbc:hsqldb:."/>
                           
                          </Context>



                          components.xml


                          <?xml version="1.0" encoding="UTF-8"?>
                          <components xmlns="http://jboss.com/products/seam/components"
                                      xmlns:core="http://jboss.com/products/seam/core"
                                      xmlns:persistence="http://jboss.com/products/seam/persistence"
                                      xmlns:transaction="http://jboss.com/products/seam/transaction"
                                      xmlns:security="http://jboss.com/products/seam/security"
                                      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                                      xsi:schemaLocation=
                                          "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" 
                                            concurrent-request-timeout="500"
                                            conversation-id-parameter="cid"/>
                                            
                              <transaction:entity-transaction entity-manager="#{em}"/>
                                            
                              <persistence:entity-manager-factory name="bookingDatabase"/>
                              
                              <persistence:managed-persistence-context name="em"
                                                         auto-create="true" 
                                              entity-manager-factory="#{bookingDatabase}"/>
                                              
                              <security:identity authenticate-method="#{authenticator.authenticate}"/>  
                              
                          </components>



                          persistence.xml:


                          <?xml version="1.0" encoding="UTF-8"?>
                          <persistence xmlns="http://java.sun.com/xml/ns/persistence" 
                                       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                                       xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd" 
                                       version="1.0">
                             <persistence-unit name="bookingDatabase" transaction-type="RESOURCE_LOCAL">
                                <provider>org.hibernate.ejb.HibernatePersistence</provider>
                                <jta-data-source>java:comp/env/jdbc/TestDB</jta-data-source>
                                <properties>
                                   <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" 
                                        value="java:/jpaBookingEntityManagerFactory"/>
                                   -->
                                </properties>
                             </persistence-unit>
                          </persistence>