3 Replies Latest reply on Aug 26, 2011 3:26 PM by Thomas Clifford

    stripersist example on JBoss

    Sidney Zurch Novice

      Would someone who is familiar with the intricacies of JBoss and JPA be interested in trying to get this .war to work in something later than JBoss 4.2.3.GA?

       

      Stripersist is a slick DAO layer that works with the increasingly popular Stripes framework.

       

      The attached .war is basically the stock example from http://sourceforge.net/projects/stripes-stuff/files/Stripersist/1.0.3/stripersist-1.0.3-example.war/download  with some jars in WEB-INF/lib removed for use with JBoss.

       

      The stock .war works in Tomcat, and the attached .war works fine in 4.2.3, but in anything after JBoss5, the deployer fails with a message stating that a JTA transaction is required for the persistence unit.

       

      I've tried (for days) using a <non-jta-data-source>, but then the deployer has problems trying to locate the datasource.  I'm sure it's probably me.

       

      This should be really simple for someone who knows what they're doing.

       

      One tip: I had to put the c3P0 jar in server/default/lib to get pooling to work on 4.2.3.  If you don't want to mess with pooling, just comment it out in persistence.xml

        • 1. Re: stripersist example on JBoss
          Thomas Clifford Newbie

          Sidney:

           

          Did you ever get an answer for your question ?

           

          I'm trying to get the example working on JBoss 5.1.0, and it's telling me:

           

          12:38:35,772 INFO  [STDOUT] 12:38:35,769 ERROR Stripersist:82 -

          javax.persistence.PersistenceException: [PersistenceUnit: SPERPU] Unable to build EntityManagerFactory

                  at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:678)

                  at org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:127)

                  at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:52)

                  at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:34)

          ...more...

           

          Caused by: org.hibernate.HibernateException: Could not find datasource: java:/SPER-DS

                  at org.hibernate.connection.DatasourceConnectionProvider.configure(DatasourceConnectionProvider.java:8

          2)

                  at org.hibernate.connection.ConnectionProviderFactory.newConnectionProvider(ConnectionProviderFactory.

          java:138)

                  ... 86 more

           

          My xxxxx-ds.xml:

           

          [code]

          <?xml version="1.0" encoding="UTF-8"?>

           

          <!-- ===================================================================== -->

          <!--                                                                       -->

          <!--  stripersist JBoss db connection configuration                        -->

          <!--                                                                       -->

          <!-- ===================================================================== -->

           

          <datasources>

            <local-tx-datasource>

           

              <jndi-name>Stripersisttest-DS</jndi-name>

           

              <connection-url>jdbc:mysql://localhost:3306/test</connection-url>

              <driver-class>com.mysql.jdbc.Driver</driver-class>

              <user-name>tom</user-name>

              <password>(password-for-db)</password>

           

              <min-pool-size>2</min-pool-size>

           

              <!--set this any higher than max_connections on your

               MySQL server, usually this should be a 10 or a few

               of connections, not hundreds or thousands -->

           

              <max-pool-size>20</max-pool-size>

           

              <!-- Don’t allow connections to hang out idle too long,

               never longer than what wait_timeout is set to on the

               server...A few minutes is usually okay here,

               it depends on your application

               and how much spikey load it will see -->

           

              <idle-timeout-minutes>5</idle-timeout-minutes>

           

              <!-- If using Connector/J 3.1.8 or newer, you can use

                 our implementation of these to increase the robustness

                 of the connection pool. -->

           

              <exception-sorter-class-name>com.mysql.jdbc.integration.jboss.ExtendedMysqlExceptionSorter</exception-sorter-class-name>

              <valid-connection-checker-class-name>com.mysql.jdbc.integration.jboss.MysqlValidConnectionChecker</valid-connection-checker-class-name>

              <connection-property name="autoReconnect">true</connection-property>

              <metadata>

                 <type-mapping>mySQL</type-mapping>

              </metadata>

           

            </local-tx-datasource>

          </datasources>

          [/code]

           

          And my persistence.xml:

           

          [code]

          <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="TestPU">

                    <jta-data-source>java:/STRIPERSISTTESTDS</jta-data-source>

                   

                  <class>org.stripersist.example.model.SimpleEntity</class>

                    <properties>

                       <property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect"/>

                       <property name="hibernate.hbm2ddl.auto" value="validate"/>

                    </properties>

             </persistence-unit>

          </persistence>

          [/code]

           

          [/code]

           

          In my base action bean:

           

          [code]

           

           

          // ....and my method to get the list of records:

           

          public List<SimpleEntity> getSimpleEntities()

          {

               ValidationErrors errors = getContext().getValidationErrors();

           

               ArrayList simpleEntities = new ArrayList<SimpleEntity>();

           

               try

               {

                    Query thisq = em.createQuery( "from SimpleEntity" );

                    simpleEntities = (ArrayList<SimpleEntity>) thisq.getResultList();

               }

               catch( NullPointerException npe )

               {

                    log.error("Could not get SimpleEntity list!");

                    return new ArrayList<SimpleEntity>();

               }

               return simpleEntities;

          }

           

          [/code]

           

          Thanks.....Tom C.

          • 2. Re: stripersist example on JBoss
            Sidney Zurch Novice

            "Not a peep" - in over two months.

             

            I think I even sent a msg to the stripersist author.

             

            The really sad thing is that it's probably something pretty simple.

             

            Thanks!

            • 3. Re: stripersist example on JBoss
              Thomas Clifford Newbie

              Yeah....that figures.

              I've googled stripersist, but there appears little interest in it.

              If I find something I'll post it here.