9 Replies Latest reply on Feb 13, 2006 5:50 PM by phicorp

    CRUD Generator - Deployment Problem

    phicorp

      Hello All,

      I have installed Seam beta 2 and the booking example is working as expected.

      However when I use the CRUD generator in Eclipse JBoss IDE 1.5 I am unable to deploy the generated application.

      To generate the application I create a new Java 5.0 project, a Hibernate configuration file, and a Hibernate console configuration, and then run the code generator to generate a Seam skeleton app via reverse engineering using a JDBC connection.

      The generator runs without any errors or warning messages, and when I look at the generated JSPs and Java code, the JSPs look fine and all the generated Java classes look fine.

      I then carry out the instructions in the generated readme.txt and run the build.xml file which compiles all of the source code successfully and reports that the build finished successfully.

      I now start jboss-4.0.4RC1 but JBoss cannot deploy the application successfully. The error messages that I get from JBoss are as follows:

      FATAL [org.hibernate.ejb.packaging.PersistenceXmlLoader] bookingDatabase JTA // The Seam booking example now not working

      FATAL [org.hibernate.ejb.packaging.PersistenceXmlLoader] entityManager JTA // The CRUD application

      ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[localhost].[/seamapp]] Exception sending context initialized event to listener instance of class org.jboss.seam.servlet.SeamListener
      java.lang.IllegalArgumentException: java.beans.IntrospectionException: Method not found: isJndiName

      ERROR [org.jboss.deployment.MainDeployer] Could not start deployment: file:/C:/jboss-4.0.4RC1/server/default/tmp/deploy/tmp5889seamapp.ear-contents/seamapp.war
      org.jboss.deployment.DeploymentException: URL file:/C:/jboss-4.0.4RC1/server/default/tmp/deploy/tmp5889seamapp.ear-contents/seamapp-exp.war/ deployment failed

      I also note that there is no correlation between the Hibernate configuration file that I specified in the project and the persistence.xml file that was generated by the Hibernate generator.

      The Hibernate configuration file:

      <?xml version="1.0" encoding="UTF-8"?>
      <!DOCTYPE hibernate-configuration PUBLIC
       "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
       "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
      <hibernate-configuration>
       <session-factory>
       <property name="hibernate.connection.driver_class">org.postgresql.Driver</property>
       <property name="hibernate.connection.password">phicorp_booking_dev_user</property>
       <property name="hibernate.connection.url">jdbc:postgresql://localhost:5432/phicorp_booking_development</property>
       <property name="hibernate.connection.username">phicorp_booking_dev_user</property>
       <property name="hibernate.dialect">org.hibernate.dialect.PostgreSQLDialect</property>
       </session-factory>
      </hibernate-configuration>
      


      The generated persistence.xml file:
      <entity-manager>
       <persistence-unit name="entityManager">
       <provider>org.hibernate.ejb.HibernatePersistence</provider>
       <jta-data-source>java:/DefaultDS</jta-data-source>
       <properties>
       <property name="hibernate.dialect" value="org.hibernate.dialect.HSQLDialect"/>
       <property name="hibernate.transaction.manager_lookup_class" value="org.hibernate.transaction.JBossTransactionManagerLookup"/>
       <property name="hibernate.transaction.flush_before_completion" value="true"/>
       <property name="hibernate.hbm2ddl.auto" value="create-drop"/>
       <property name="hibernate.show_sql" value="true"/>
       <property name="jboss.entity.manager.factory.jndi.name" value="java:/EntityManager"/>
       </properties>
       </persistence-unit>
      </entity-manager>
      


      I have tried to correct the problem by changing the generated persistence.xml file and by creating a phicorp-booking-ds.xml file in the JBoss server/default/deploy directory, but I still get the error message which states that JBoss cannot deploy the war file.

      The changed persistence.xml file:
      <entity-manager>
       <persistence-unit name="entityManager">
       <provider>org.hibernate.ejb.HibernatePersistence</provider>
       <jta-data-source>java:/phicorpBookingDataSource</jta-data-source>
       <properties>
       <property name="hibernate.dialect" value="org.hibernate.dialect.PostgreSQLDialect"/>
       <property name="hibernate.transaction.manager_lookup_class" value="org.hibernate.transaction.JBossTransactionManagerLookup"/>
       <property name="hibernate.transaction.flush_before_completion" value="true"/>
       <!-- property name="hibernate.hbm2ddl.auto" value="create-drop"/ -->
       <!-- property name="hibernate.show_sql" value="true"/ -->
       <property name="jboss.entity.manager.factory.jndi.name" value="java:/EntityManager"/>
       </properties>
       </persistence-unit>
      </entity-manager>
      


      phicorp-booking-ds.xml:
      <?xml version="1.0" encoding="UTF-8"?>
      <datasources>
       <local-tx-datasource>
       <jndi-name>phicorpBookingDataSource</jndi-name>
       <connection-url>jdbc:postgresql://localhost:5432/phicorp_booking_development</connection-url>
       <driver-class>org.postgresql.Driver</driver-class>
       <user-name>phicorp_booking_dev_user</user-name>
       <password>phicorp_booking_dev_user</password>
       </local-tx-datasource>
      </datasources>
      


      Any help on resolving the problems that I have encountered will be much appreciated.

      I do not understand:
      (1) Why there is no correlation between the Hibernate configuration file and the generated persistence.xml file?
      (2) Why JBoss cannot deploy the war file successfully?

      Many thanks,
      Bruce.


        • 1. Re: CRUD Generator - Deployment Problem
          gavin.king

          (1) Because we did not yet implement that. Still the app should run against JBoss' default datasource.

          (2) Looks like you have an old version of the Seam jar. Make sure you are using Seam 1.0 beta 2

          • 2. Re: CRUD Generator - Deployment Problem
            gavin.king

            It also looks like you are not running the latest version of Hibernate Tools. Try the nightly build of JBoss IDE.

            http://download.jboss.org/jbosside/builds/nightly/buildResults.html


            • 3. Re: CRUD Generator - Deployment Problem
              phicorp

              I am definitely using the jboss-seam.jar file from the jboss-seam-1.0beta2.zip file that I downloaded on the 11th of February (2 days ago).

              • 4. Re: CRUD Generator - Deployment Problem
                gavin.king

                Then make sure you are using the latest nightly build of JBoss IDE.

                • 5. Re: CRUD Generator - Deployment Problem
                  phicorp

                  I am now using the latest nightly build of JBoss IDE.

                  When I deploy to jboss-4.0.4RC1 I am informed that JBoss cannot deploy the war file successfully. However this message is preceded by the following errors:

                  2006-02-13 21:10:03,203 FATAL [org.hibernate.ejb.packaging.PersistenceXmlLoader] entityManager JTA

                  2006-02-13 21:10:09,328 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[localhost].[/seamapp]] Exception sending context initialized event to listener instance of class org.jboss.seam.servlet.SeamListener
                  java.lang.IllegalStateException: Missing value() for @DataModelSelection with multiple @DataModels

                  I am using the following configuration files:

                  seam.properties

                  org.jboss.seam.core.init.jndiPattern seamapp/#{ejbName}/local
                  


                  persistence.xml
                  <persistence>
                   <persistence-unit name="entityManager">
                   <provider>org.hibernate.ejb.HibernatePersistence</provider>
                   <jta-data-source>java:/phicorpBookingDataSource</jta-data-source>
                   <properties>
                   <property name="hibernate.dialect" value="org.hibernate.dialect.PostgreSQLDialect"/>
                   <property name="hibernate.transaction.manager_lookup_class" value="org.hibernate.transaction.JBossTransactionManagerLookup"/>
                   <property name="hibernate.transaction.flush_before_completion" value="true"/>
                   <!-- property name="hibernate.hbm2ddl.auto" value="create-drop"/ -->
                   <!-- property name="hibernate.show_sql" value="true"/ -->
                   </properties>
                   </persistence-unit>
                  </persistence>
                  


                  phicorp-booking-ds.xml
                  <?xml version="1.0" encoding="UTF-8"?>
                  <datasources>
                   <local-tx-datasource>
                   <jndi-name>phicorpBookingDataSource</jndi-name>
                   <connection-url>jdbc:postgresql://localhost:5432/phicorp_booking_development</connection-url>
                   <driver-class>org.postgresql.Driver</driver-class>
                   <user-name>phicorp_booking_dev_user</user-name>
                   <password>phicorp_booking_dev_user</password>
                   </local-tx-datasource>
                  </datasources>
                  


                  Can you see any errors in my configuration, and comment on the @DataModelSelection error?

                  Many thanks,
                  Bruce.


                  • 6. Re: CRUD Generator - Deployment Problem
                    gavin.king

                    So, the exception is this:

                    Missing value() for @DataModelSelection with multiple @DataModels


                    Show the code for the component that has multiple @DataMOdels

                    • 7. Re: CRUD Generator - Deployment Problem
                      phicorp

                       

                      package test1.model;
                      
                      // Generated 13/02/2006 20:05:13 by Hibernate Tools 3.1.0.beta4
                      
                      import java.util.ArrayList;
                      import java.util.List;
                      import java.util.ResourceBundle;
                      import javax.ejb.Interceptors;
                      import javax.ejb.Remove;
                      import javax.ejb.Stateful;
                      import javax.ejb.TransactionAttribute;
                      import static javax.ejb.TransactionAttributeType.NOT_SUPPORTED;
                      import javax.faces.application.FacesMessage;
                      import javax.faces.context.FacesContext;
                      import javax.persistence.EntityManager;
                      import org.hibernate.validator.Valid;
                      import org.jboss.seam.annotations.Begin;
                      import org.jboss.seam.annotations.Destroy;
                      import org.jboss.seam.annotations.End;
                      import org.jboss.seam.annotations.IfInvalid;
                      import org.jboss.seam.annotations.In;
                      import org.jboss.seam.annotations.Name;
                      import org.jboss.seam.annotations.Outcome;
                      import org.jboss.seam.annotations.datamodel.DataModel;
                      import org.jboss.seam.annotations.datamodel.DataModelSelection;
                      import org.jboss.seam.ejb.SeamInterceptor;
                      
                      @Name("clientEditor")
                      @Stateful
                      @Interceptors(SeamInterceptor.class)
                      public class ClientEditorBean implements ClientEditor {
                      
                       @In(create = true)
                       private EntityManager entityManager;
                      
                       @Valid
                       private Client instance = new Client();
                      
                       @TransactionAttribute(NOT_SUPPORTED)
                       public Client getInstance() {
                       return instance;
                       }
                      
                       public void setInstance(Client instance) {
                       this.instance = instance;
                       }
                      
                       private boolean isNew = true;
                      
                       @TransactionAttribute(NOT_SUPPORTED)
                       public boolean isNew() {
                       return isNew;
                       }
                      
                       public void setNew(boolean isNew) {
                       this.isNew = isNew;
                       }
                      
                       private String doneOutcome = "find";
                      
                       public void setDoneOutcome(String outcome) {
                       doneOutcome = outcome;
                       }
                      
                       @In(required = false)
                       private transient ClientFinder clientFinder;
                      
                       @In
                       private transient ResourceBundle resourceBundle;
                      
                       @Begin(join = true)
                       @IfInvalid(outcome = Outcome.REDISPLAY)
                       public String create() {
                       if (entityManager.find(Client.class, instance.getId()) != null) {
                       FacesContext.getCurrentInstance().addMessage(
                       null,
                       new FacesMessage(resourceBundle.getString("Client_id")
                       + " " + resourceBundle.getString("AlreadyExists")));
                       return null;
                       }
                       entityManager.persist(instance);
                       isNew = false;
                       refreshFinder();
                       return "editClient";
                       }
                      
                       @IfInvalid(outcome = Outcome.REDISPLAY)
                       public String update() {
                       refreshFinder();
                       return null;
                       }
                      
                       @End(ifOutcome = "find")
                       public String delete() {
                       entityManager.remove(instance);
                       refreshFinder();
                       return doneOutcome;
                       }
                      
                       @End(ifOutcome = "find")
                       public String done() {
                       if (!isNew)
                       entityManager.refresh(instance);
                       return doneOutcome;
                       }
                      
                       private void refreshFinder() {
                       if (clientFinder != null)
                       clientFinder.refresh();
                       }
                      
                       @Destroy
                       @Remove
                       public void destroy() {
                       }
                      
                       @DataModel
                       public List getServiceGroupsList() {
                       return instance == null || instance.getServiceGroups() == null ? null
                       : new ArrayList(instance.getServiceGroups());
                       }
                      
                       @DataModelSelection
                       private ServiceGroup selectedServiceGroup;
                      
                       @In(create = true)
                       private transient ServiceGroupEditor servicegroupEditor;
                      
                       public String createServiceGroup() {
                       servicegroupEditor.setNew(true);
                       servicegroupEditor.setInstance(new ServiceGroup());
                       servicegroupEditor.getInstance().setClient(instance);
                       servicegroupEditor.setDoneOutcome("editClient");
                       return "editServiceGroup";
                       }
                      
                       public String selectServiceGroup() {
                       servicegroupEditor.setNew(false);
                       servicegroupEditor.setInstance(selectedServiceGroup);
                       servicegroupEditor.setDoneOutcome("editClient");
                       return "editServiceGroup";
                       }
                      
                       @DataModel
                       public List getResourceTypesList() {
                       return instance == null || instance.getResourceTypes() == null ? null
                       : new ArrayList(instance.getResourceTypes());
                       }
                      
                       @DataModelSelection
                       private ResourceType selectedResourceType;
                      
                       @In(create = true)
                       private transient ResourceTypeEditor resourcetypeEditor;
                      
                       public String createResourceType() {
                       resourcetypeEditor.setNew(true);
                       resourcetypeEditor.setInstance(new ResourceType());
                       resourcetypeEditor.getInstance().setClient(instance);
                       resourcetypeEditor.setDoneOutcome("editClient");
                       return "editResourceType";
                       }
                      
                       public String selectResourceType() {
                       resourcetypeEditor.setNew(false);
                       resourcetypeEditor.setInstance(selectedResourceType);
                       resourcetypeEditor.setDoneOutcome("editClient");
                       return "editResourceType";
                       }
                      
                       @DataModel
                       public List getLocationTablesList() {
                       return instance == null || instance.getLocationTables() == null ? null
                       : new ArrayList(instance.getLocationTables());
                       }
                      
                       @DataModelSelection
                       private LocationTable selectedLocationTable;
                      
                       @In(create = true)
                       private transient LocationTableEditor locationtableEditor;
                      
                       public String createLocationTable() {
                       locationtableEditor.setNew(true);
                       locationtableEditor.setInstance(new LocationTable());
                       locationtableEditor.getInstance().setClient(instance);
                       locationtableEditor.setDoneOutcome("editClient");
                       return "editLocationTable";
                       }
                      
                       public String selectLocationTable() {
                       locationtableEditor.setNew(false);
                       locationtableEditor.setInstance(selectedLocationTable);
                       locationtableEditor.setDoneOutcome("editClient");
                       return "editLocationTable";
                       }
                      
                      }
                      
                      



                      • 8. Re: CRUD Generator - Deployment Problem
                        gavin.king

                        Oh, OK, this is a bug in the templates.

                        Please report in Hibernate Tools JIRA.

                        Should be:

                        @DataModelSelection("locationTablesList")

                        etc

                        • 9. Re: CRUD Generator - Deployment Problem
                          phicorp

                          Many thanks.