4 Replies Latest reply on May 29, 2009 6:50 PM by Moissane Hernández

    Tutorial for new project in Tomcat 6?

    Karl Beowulph Newbie

      Hello,


      I've recently been mandated to switch servers from JBoss 5 to Tomcat 6, and I'm running into problems.


      While I can get the jpa war example working, when I create a new Seam Web Project and attempt to deploy it to Tomcat (no changes) I get the following:


      27-May-2009 5:50:31 PM org.apache.tomcat.util.digester.SetPropertiesRule begin
      WARNING: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.jee.server:tester' did not find a matching property.
      27-May-2009 5:50:31 PM org.apache.catalina.core.AprLifecycleListener init
      INFO: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: C:\Program Files\Java\jre1.5.0_14\bin;.;C:\WINDOWS\system32;C:\WINDOWS;C:/Program Files/Java/jre1.5.0_14/bin/client;C:/Program Files/Java/jre1.5.0_14/bin;C:\PROGRA~1\Serena\vm\win32\bin;C:\PROGRA~1\Serena\vm\common\bin\win32;C:\Oracle\Ora80\bin;C:\PVSW\BIN;C:\ORACLE\ORA81\BIN;C:\PROGRAM FILES\ORACLE\JRE\1.1.7\BIN;C:\WINDOWS\SYSTEM32;C:\WINDOWS;C:\WINDOWS\SYSTEM32\WBEM;C:\PROGRAM FILES\COMMON FILES\AUTODESK SHARED\;C:\PROGRAM FILES\TRUEARC\SHARED FILES;C:\ORACLE\ORA80\JDK\BIN;C:\PROGRAM FILES\DOCUMENTUM\SHARED;C:\Program Files\ABB\sidl\bin;C:\Program Files\ABB\bin;C:\Program Files\ABB\WS500\;C:\WS500ExtendedDialogs\;C:\WS500ExtendedDialogs\TeleUSE\bin;C:\WS500ExtendedDialogs\TeleUSE\server;C:\Program Files\IDM Computer Solutions\UltraEdit-32;C:\Program Files\Microsoft SQL Server\80\Tools\Binn\;C:\Program Files\Microsoft SQL Server\90\Tools\binn\;C:\Program Files\Microsoft SQL Server\90\DTS\Binn\;C:\Program Files\Microsoft SQL Server\90\Tools\Binn\VSShell\Common7\IDE\;C:\Program Files\Microsoft Visual Studio 8\Common7\IDE\PrivateAssemblies\;C:\opt\apache-ant-1.7.0\bin\;
      27-May-2009 5:50:31 PM org.apache.coyote.http11.Http11Protocol init
      INFO: Initializing Coyote HTTP/1.1 on http-8080
      27-May-2009 5:50:31 PM org.apache.catalina.startup.Catalina load
      INFO: Initialization processed in 511 ms
      27-May-2009 5:50:31 PM org.apache.catalina.core.StandardService start
      INFO: Starting service Catalina
      27-May-2009 5:50:31 PM org.apache.catalina.core.StandardEngine start
      INFO: Starting Servlet Engine: Apache Tomcat/6.0.18
      27-May-2009 5:50:32 PM org.jboss.seam.servlet.SeamListener contextInitialized
      INFO: Welcome to Seam 2.1.1.GA
      27-May-2009 5:50:33 PM org.apache.catalina.core.StandardContext listenerStart
      SEVERE: Exception sending context initialized event to listener instance of class org.jboss.seam.servlet.SeamListener
      java.lang.NoClassDefFoundError: javassist/bytecode/ClassFile
           at org.jboss.seam.deployment.AbstractScanner.<init>(AbstractScanner.java:140)
           at org.jboss.seam.deployment.URLScanner.<init>(URLScanner.java:35)
           at org.jboss.seam.deployment.DeploymentStrategy.initScanner(DeploymentStrategy.java:107)
           at org.jboss.seam.deployment.DeploymentStrategy.getScanner(DeploymentStrategy.java:59)
           at org.jboss.seam.deployment.StandardDeploymentStrategy.scan(StandardDeploymentStrategy.java:113)
           at org.jboss.seam.init.Initialization.create(Initialization.java:132)
           at org.jboss.seam.servlet.SeamListener.contextInitialized(SeamListener.java:35)
           at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3843)
           at org.apache.catalina.core.StandardContext.start(StandardContext.java:4342)
           at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
           at org.apache.catalina.core.StandardHost.start(StandardHost.java:719)
           at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
           at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
           at org.apache.catalina.core.StandardService.start(StandardService.java:516)
           at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
           at org.apache.catalina.startup.Catalina.start(Catalina.java:578)
           at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
           at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
           at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
           at java.lang.reflect.Method.invoke(Unknown Source)
           at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288)
           at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)
      27-May-2009 5:50:33 PM org.apache.catalina.core.StandardContext start
      SEVERE: Error listenerStart
      27-May-2009 5:50:33 PM org.apache.catalina.core.StandardContext start
      SEVERE: Context [/tester] startup failed due to previous errors
      27-May-2009 5:50:33 PM org.apache.catalina.core.StandardContext listenerStop
      SEVERE: Exception sending context destroyed event to listener instance of class org.jboss.seam.servlet.SeamListener
      java.lang.NoClassDefFoundError: javassist/util/proxy/MethodFilter
           at org.jboss.seam.contexts.Contexts.destroy(Contexts.java:243)
           at org.jboss.seam.contexts.Lifecycle.endApplication(Lifecycle.java:56)
           at org.jboss.seam.contexts.ServletLifecycle.endApplication(ServletLifecycle.java:135)
           at org.jboss.seam.servlet.SeamListener.contextDestroyed(SeamListener.java:40)
           at org.apache.catalina.core.StandardContext.listenerStop(StandardContext.java:3882)
           at org.apache.catalina.core.StandardContext.stop(StandardContext.java:4523)
           at org.apache.catalina.core.StandardContext.start(StandardContext.java:4387)
           at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
           at org.apache.catalina.core.StandardHost.start(StandardHost.java:719)
           at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
           at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
           at org.apache.catalina.core.StandardService.start(StandardService.java:516)
           at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
           at org.apache.catalina.startup.Catalina.start(Catalina.java:578)
           at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
           at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
           at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
           at java.lang.reflect.Method.invoke(Unknown Source)
           at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288)
           at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)
      27-May-2009 5:50:33 PM org.apache.catalina.startup.HostConfig deployDescriptor
      WARNING: A docBase C:\opt\apache-tomcat-6.0.18\webapps\jboss-seam-jpa inside the host appBase has been specified, and will be ignored
      27-May-2009 5:50:33 PM org.apache.catalina.core.StandardContext resourcesStart
      SEVERE: Error starting static Resources
      java.lang.IllegalArgumentException: Document base C:\opt\apache-tomcat-6.0.18\webapps\jboss-seam-jpa does not exist or is not a readable directory
           at org.apache.naming.resources.FileDirContext.setDocBase(FileDirContext.java:141)
           at org.apache.catalina.core.StandardContext.resourcesStart(StandardContext.java:3957)
           at org.apache.catalina.core.StandardContext.start(StandardContext.java:4126)
           at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:791)
           at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:771)
           at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:525)
           at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:627)
           at org.apache.catalina.startup.HostConfig.deployDescriptors(HostConfig.java:553)
           at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:488)
           at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1149)
           at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:311)
           at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:117)
           at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053)
           at org.apache.catalina.core.StandardHost.start(StandardHost.java:719)
           at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
           at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
           at org.apache.catalina.core.StandardService.start(StandardService.java:516)
           at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
           at org.apache.catalina.startup.Catalina.start(Catalina.java:578)
           at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
           at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
           at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
           at java.lang.reflect.Method.invoke(Unknown Source)
           at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288)
           at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)
      27-May-2009 5:50:33 PM org.apache.catalina.core.StandardContext start
      SEVERE: Error in resourceStart()
      27-May-2009 5:50:33 PM org.apache.catalina.core.StandardContext start
      SEVERE: Error getConfigured
      27-May-2009 5:50:33 PM org.apache.catalina.core.StandardContext start
      SEVERE: Context [/jboss-seam-jpa] startup failed due to previous errors
      27-May-2009 5:50:33 PM org.apache.catalina.core.StandardContext stop
      INFO: Container org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/jboss-seam-jpa] has not been started
      27-May-2009 5:50:33 PM org.apache.catalina.core.ApplicationContext log
      INFO: ContextListener: contextInitialized()
      27-May-2009 5:50:33 PM org.apache.catalina.core.ApplicationContext log
      INFO: SessionListener: contextInitialized()
      27-May-2009 5:50:33 PM org.apache.coyote.http11.Http11Protocol start
      INFO: Starting Coyote HTTP/1.1 on http-8080
      27-May-2009 5:50:33 PM org.apache.jk.common.ChannelSocket init
      INFO: JK: ajp13 listening on /0.0.0.0:8009
      27-May-2009 5:50:33 PM org.apache.jk.server.JkMain start
      INFO: Jk running ID=0 time=0/31  config=null
      27-May-2009 5:50:33 PM org.apache.catalina.startup.Catalina start
      INFO: Server startup in 1894 ms
      



      Does JBoss Tools create a Seam project that can be immediately deployed to Tomcat, or is additional configuration required?  If so, does anyone know of a good guide?  There are enough on the Internet that finding a minimal and reliable one (for the latest version of Seam and Tomcat) is a bit difficult.

        • 1. Re: Tutorial for new project in Tomcat 6?
          Arbi Sookazian Master

          consult Seam ref doc (first), books (second), wiki/forums (third); always in that order.


          ref doc:



          1.1.2. Running the examples on Tomcat



          The examples are also configured for use on Tomcat 6.0. You will need to follow the instructions
          in Section 29.6.1, “Installing Embedded JBoss” for installing JBoss Embedded on Tomcat 6.0.



          JBoss Embedded is only required to run the Seam demos that use EJB3 components on Tomcat.
          There are also examples of non-EJB3 applications that can be run on Tomcat without the use
          of JBoss Embedded.



          You'll need to set tomcat.home, in the shared build.properties file in the root folder of your
          Seam installation, to the location of your Tomcat installation. make sure you set the location of
          your Tomcat.



          You'll need to use a different Ant target when using Tomcat. Use ant tomcat.deploy in example
          subdirectory to build and deploy any example for Tomcat.



          On Tomcat, the examples deploy to URLs like /jboss-seam-example, so for the registration
          example the URL would be http://localhost:8080/jboss-seam-registration/. The same is true for examples that deploy as a WAR, as mentioned in the previous section.

          side note: one guy was in your position @ Napster and told me what do I need JBoss for?  Well, if you're a Spring/Tomcat/Hibernate shop, then yes, you apparently defy the almighty services of the heavy-weight EJB container.  Spring AOP is great no?  can't wait til the local interface is optional in 3.1!

          • 2. Re: Tutorial for new project in Tomcat 6?
            Gregory Nikle Apprentice

            Add javassist.jar file to your project/WEB-INF/lib

            • 3. Re: Tutorial for new project in Tomcat 6?
              Israel Fonseca Apprentice

              can't wait til the local interface is optional in 3.1!

              Me too Arbi.


              About the tomcat-example, just do what Arbi told.

              • 4. Re: Tutorial for new project in Tomcat 6?
                Moissane Hernández Newbie
                Hello Karl, I know you are talking about...I faced that hard situation and nobody was able to help me because the information for seam 2 and tomcat 6 configuration is around multiple internet forums, documentation and blogs. But I am ready to help you, however I warning you there are some things to do.

                Here are the steps:

                ***Creating the project***

                1. Create a new Seam Web Project
                Target Runtime: Apache Tomacat v6.0
                Target Server: Tomacat v6.0 Server at localhost
                Configurations: Dynamic Web Project with Seam 2.0 (technology preview)

                click Next button

                2. Check Java Persistence, others items by default

                click Next button

                3. Just click Next button

                4. Just click Next button

                5. Just click Next button

                6. We are in Seam Facet
                Add Seam Runtime
                Check WAR radiobutton
                Database Type: MySQL (in this example)
                Connection profile: select or new...
                Other items by default or
                in code generation you can customize the packages if you want changing the domain.

                click Finish button

                ***Setting the project to works with tomcat***

                1. Add to WebContent\WEB-INF\lib:
                cglib.jar; antlr.jar; antlr-runtime.jar; commons-collections.jar; commons-lang.jar; commons-logging.jar; dom4j.jar; hibernate-annotations.jar; hibernate-commons-annotations.jar; hibernate-entitymanager.jar; hibernate-validator.jar; hibernate.jar; javassist.jar; jboss-archive-browsing.jar; jboss-common-core.jar; jsf-api.jar; jsf-impl.jar; jstl.jar; jta.jar; persistence-api.jar; asm.jar.

                Copy to tomcat\lib the mysql-connector-java-5.0.6-bin.jar (I used this connector version of mysql).

                2. This is the persistence.xml file:

                <persistence-unit name="test" transaction-type="RESOURCE_LOCAL">
                      <provider>org.hibernate.ejb.HibernatePersistence</provider>
                      <jta-data-source>java:comp/env/jdbc/testDS</jta-data-source>
                      <properties>
                         <property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect"/>
                         <property name="hibernate.hbm2ddl.auto" value="update"/>
                         <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>

                The persistence-unit name must be the same that components.xml <persistence:entity-manager-factory     name="testEntityManagerFactory"
                     persistence-unit-name="test" />.
                In the property hibernate.dialect must be the value org.hibernate.dialect.MySQLDialect in the case of mysql.

                3. Create in WebContent\WEB-INF context.xml

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

                <Context path="/test" docBase="test" debug="5" reloadable="true"
                     crossContext="true">

                     <Resource auth="Container" driverClassName="com.mysql.jdbc.Driver"
                          maxActive="20" maxIdle="10" maxWait="100" name="jdbc/testDS"
                          type="javax.sql.DataSource" url="jdbc:mysql://localhost:3306/test_db"
                          username="root" password="admin" />
                               
                </Context>

                4. Add to web.xml this:

                <resource-ref>
                          <description>DB Connection</description>
                          <res-ref-name>jdbc/testDS</res-ref-name>
                          <res-type>javax.sql.DataSource</res-type>
                          <res-auth>Container</res-auth>
                     </resource-ref>

                and comment this

                <!-- Facelets development mode (disable in production) -->
                <!--
                     <context-param>
                          <param-name>facelets.DEVELOPMENT</param-name>
                          <param-value>true</param-value>
                     </context-param>
                -->

                5. In components.xml:

                Add tags in xlmns:
                            xmlns:transaction="http://jboss.com/products/seam/transaction"
                            xmlns:web="http://jboss.com/products/seam/web"
                and add:
                <transaction:entity-transaction entity-manager="#{entityManager}"/>
                <web:context-filter url-pattern="/nombre_proyecto"/>
                Remove from <core:init debug="true" jndi-pattern="@jndiPattern@" /> the property jndi-pattern.

                Delete file jboss-web from WebContent\WEB-INF because we are not using jboss.

                Thats all, If you do all this correct will work...it work for me OK.
                God bless you.