1 Reply Latest reply on Apr 11, 2009 6:56 PM by nubknacker

    Seam with tomcat - more trouble than it's worth?

      I have been trying to setup seam to run with tomcat all day long simply because it takes jboss as 10 minutes or so to startup on my computer (really crudd HDD). I finally managed to create a new project from within eclipse using jboss tools and I thought everything worked till I tried to hit the database.


      My configuration..


      persistence.xml:


      <?xml version="1.0" encoding="UTF-8"?>
      <!-- Persistence deployment descriptor for dev profile -->
      <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="seamt1" 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.dialect" value="org.hibernate.dialect.MySQL5Dialect"/>
               <property name="hibernate.hbm2ddl.auto" value="validate"/>
               <property name="hibernate.show_sql" value="true"/>
               <property name="hibernate.format_sql" value="true"/>
               <!--<property name="hibernate.transaction.manager_lookup_class" value="org.hibernate.transaction.JBossTransactionManagerLookup"/>-->
            </properties>
         </persistence-unit>
          
      </persistence>
      


      I had to replace the jta-data-source to make it work with tomcat.


      My context.xml required for tomcat:



      <Context path="/seamtom" 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="erc" password = "erc"
                driverClassName="com.mysql.jdbc.Driver"
                url="jdbc:mysql://localhost:3306/erc"/>
           
      </Context>
      




      My 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:drools="http://jboss.com/products/seam/drools"
                  xmlns:bpm="http://jboss.com/products/seam/bpm"
                  xmlns:transaction="http://jboss.com/products/seam/transaction"
                  xmlns:security="http://jboss.com/products/seam/security"
                  xmlns:mail="http://jboss.com/products/seam/mail"
                  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/drools http://jboss.com/products/seam/drools-2.1.xsd
                       http://jboss.com/products/seam/bpm http://jboss.com/products/seam/bpm-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/mail http://jboss.com/products/seam/mail-2.1.xsd
                       http://jboss.com/products/seam/components http://jboss.com/products/seam/components-2.1.xsd">
      
         <core:init debug="true" jndi-pattern="@jndiPattern@"/>
      
         <component name="org.jboss.seam.debug.hotDeployFilter">
            <property name="urlPattern">*.seam</property>
         </component>
      
         <core:manager concurrent-request-timeout="500"
                       conversation-timeout="120000"
                       conversation-id-parameter="cid"
                       parent-conversation-id-parameter="pid"/>
      
        <!-- <transaction:entity-transaction entity-manager="#{entityManager}"/> -->    
         
         <persistence:managed-persistence-context name="entityManager"
                                           auto-create="true"
                                entity-manager-factory="#{seamt1EntityManagerFactory}"/>
      
         <persistence:entity-manager-factory name="seamt1EntityManagerFactory"
                            persistence-unit-name="seamt1"/>
      
         <drools:rule-base name="securityRules">
            <drools:rule-files><value>/security.drl</value></drools:rule-files>
         </drools:rule-base>
      
         <security:rule-based-permission-resolver security-rules="#{securityRules}"/>
      
         <security:identity authenticate-method="#{authenticator.authenticate}" remember-me="true"/>
      
         <event type="org.jboss.seam.security.notLoggedIn">
            <action execute="#{redirect.captureCurrentView}"/>
         </event>
         <event type="org.jboss.seam.security.loginSuccessful">
            <action execute="#{redirect.returnToCapturedView}"/>
         </event>
      
         <mail:mail-session host="localhost" port="2525" username="test" password="test" />
      
         <!-- For use with jBPM pageflow or process management -->
         <!--
         <bpm:jbpm>
            <bpm:process-definitions></bpm:process-definitions>
            <bpm:pageflow-definitions></bpm:pageflow-definitions>
         </bpm:jbpm>
         -->
      
      </components>




      I read in a thread on these forums (can't remember the link) that the line


      <transaction:entity-transaction entity-manager="#{entityManager}"/>


      must be added manually to projects created using eclipse. This is where the problem starts. If I comment that line, the server even refuses to show me the default home.seam page, simply returns a redirect loop error. If I uncomment that line, the EntityManager in my entity beans is null.


      What am I doing wrong?


      P.S. Please be gentle. :)