5 Replies Latest reply on Jul 29, 2008 8:40 AM by Eugeniy Nikolaev

    Standalone Tomcat problems

    Dustin Norlander Apprentice

      I am trying to move my app from jboss as to tomcat.  I have no ejb's and as far as I can tell it should work.  I am stuck trying to configure the datasources.  I get the following stack trace on start up:





      SEVERE: Exception sending context initialized event to listener instance of class org.jboss.seam.servlet.SeamListener
      org.jboss.seam.InstantiationException: Could not instantiate Seam component: trendrrDatabase
           at org.jboss.seam.Component.newInstance(Component.java:1986)
           at org.jboss.seam.contexts.Contexts.startup(Contexts.java:304)
           at org.jboss.seam.contexts.Contexts.startup(Contexts.java:278)
           at org.jboss.seam.contexts.ServletLifecycle.endInitialization(ServletLifecycle.java:95)
           at org.jboss.seam.init.Initialization.init(Initialization.java:596)
           at org.jboss.seam.servlet.SeamListener.contextInitialized(SeamListener.java:34)
           at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3843)
           at org.apache.catalina.core.StandardContext.start(StandardContext.java:4350)
           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.deployWAR(HostConfig.java:829)
           at org.apache.catalina.startup.HostConfig.deployWARs(HostConfig.java:718)
           at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:490)
           at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1147)
           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(NativeMethodAccessorImpl.java:39)
           at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
           at java.lang.reflect.Method.invoke(Method.java:597)
           at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288)
           at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)
      Caused by: javax.persistence.PersistenceException: org.hibernate.HibernateException: Could not find datasource
           at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:737)
           at org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:121)
           at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:83)
           at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:60)
           at org.jboss.seam.persistence.EntityManagerFactory.createEntityManagerFactory(EntityManagerFactory.java:81)
           at org.jboss.seam.persistence.EntityManagerFactory.startup(EntityManagerFactory.java:50)
           at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
           at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
           at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
           at java.lang.reflect.Method.invoke(Method.java:597)
           at org.jboss.seam.util.Reflections.invoke(Reflections.java:21)
           at org.jboss.seam.util.Reflections.invokeAndWrap(Reflections.java:125)
           at org.jboss.seam.Component.callComponentMethod(Component.java:2100)
           at org.jboss.seam.Component.callCreateMethod(Component.java:2015)
           at org.jboss.seam.Component.newInstance(Component.java:1976)
           ... 29 more
      Caused by: org.hibernate.HibernateException: Could not find datasource
           at org.hibernate.connection.DatasourceConnectionProvider.configure(DatasourceConnectionProvider.java:56)
           at org.hibernate.connection.ConnectionProviderFactory.newConnectionProvider(ConnectionProviderFactory.java:124)
           at org.hibernate.ejb.InjectionSettingsFactory.createConnectionProvider(InjectionSettingsFactory.java:29)
           at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:62)
           at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:2009)
           at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1292)
           at org.hibernate.cfg.AnnotationConfiguration.buildSessionFactory(AnnotationConfiguration.java:915)
           at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:730)
           ... 43 more
      Caused by: javax.naming.NameNotFoundException: Name jdbc is not bound in this Context
           at org.apache.naming.NamingContext.lookup(NamingContext.java:770)
           at org.apache.naming.NamingContext.lookup(NamingContext.java:140)
           at org.apache.naming.NamingContext.lookup(NamingContext.java:781)
           at org.apache.naming.NamingContext.lookup(NamingContext.java:140)
           at org.apache.naming.NamingContext.lookup(NamingContext.java:781)
           at org.apache.naming.NamingContext.lookup(NamingContext.java:153)
           at org.apache.naming.SelectorContext.lookup(SelectorContext.java:137)
           at javax.naming.InitialContext.lookup(InitialContext.java:392)
           at org.hibernate.connection.DatasourceConnectionProvider.configure(DatasourceConnectionProvider.java:52)
           ... 50 more
      




      my context.xml:



      <?xml version='1.0' encoding='utf-8'?>
      <Context path="/trendrr" docBase="trendrr" crossContext="true" reloadable="true">
      
      <Resource 
           name="jdbc/trendrrDB" 
           auth="Container" 
           type="javax.sql.DataSource"
           maxActive="100" maxIdle="30" maxWait="10000"
           removeAbandoned="true" 
           removeAbandonedTimeout="60" 
           logAbandoned="true"
           username="*****" 
           password="*****" 
           driverClassName="com.mysql.jdbc.ReplicationDriver"
           autoReconnect="true" 
           failOverReadOnly="false" 
           roundRobinLoadBalance="true"
           url="jdbc:mysql://***.**.**.**:3306,localhost:3306/trendrr"/>
      
      <Resource 
           name="jdbc/torrentDB" 
           auth="Container" 
           type="javax.sql.DataSource"
           maxActive="100" maxIdle="30" maxWait="10000"
           removeAbandoned="true" 
           removeAbandonedTimeout="60" 
           logAbandoned="true"
           username="****" 
           password="****" 
           driverClassName="com.mysql.jdbc.ReplicationDriver"
           autoReconnect="true" 
           failOverReadOnly="false" 
           roundRobinLoadBalance="true"
           url="jdbc:mysql://***.**.**.**:3306,***.**.**.**:3306/torrent_crawler"/>
           
      </Context> 




      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="trendrrDatabase" transaction-type="RESOURCE_LOCAL">
            <provider>org.hibernate.ejb.HibernatePersistence</provider>
            <non-jta-data-source>java:comp/env/jdbc/trendrrDB</non-jta-data-source>
            <properties>
            
               <property name="hibernate.show_sql" value="true"/>
               <property name="hibernate.format_sql" value="true" />
               <property name="hibernate.dialect" value="org.hibernate.dialect.MySQL5Dialect" />
               
               <property name="hibernate.cache.provider_class" value="org.hibernate.cache.HashtableCacheProvider"/>
             
            </properties>
         </persistence-unit>
      
         <persistence-unit name="torrentDatabase" transaction-type="RESOURCE_LOCAL">
            <provider>org.hibernate.ejb.HibernatePersistence</provider>
            <non-jta-data-source>java:comp/env/jdbc/torrentDB</non-jta-data-source>
            <properties>
               
               <property name="hibernate.show_sql" value="true"/>
               <property name="hibernate.format_sql" value="true" />
               <property name="hibernate.dialect" value="org.hibernate.dialect.MySQL5Dialect" />
               
               <property name="hibernate.cache.provider_class" value="org.hibernate.cache.HashtableCacheProvider"/>
       
            </properties>
         </persistence-unit>
      
      </persistence>




      and components.xml


         <core:init debug="true" />
           
         <core:manager concurrent-request-timeout="500" 
                       conversation-timeout="120000" 
                       conversation-id-parameter="cid" />
          
         <persistence:managed-persistence-context name="entityManager"
                                    auto-create="true"
                     entity-manager-factory="#{trendrrDatabase}"/>
       
         <persistence:managed-persistence-context name="torrentEntityManager"
                                    auto-create="true"
                     entity-manager-factory="#{torrentDatabase}"/>
         
         <persistence:entity-manager-factory name="trendrrDatabase"/>
         <persistence:entity-manager-factory name="torrentDatabase"/>
         
         <transaction:entity-transaction entity-manager="#{entityManager}"/>
      





      Can anybody offer any help?


      -Dustin

        • 1. Re: Standalone Tomcat problems
          Nicklas Karlsson Master

          Haven't used plain tomcat in a while but can't you copy -ds.xml files to the deploy folder if there is any difference in the lookup context? Where does the log indicate the datasource is bound?

          • 2. Re: Standalone Tomcat problems
            Eugeniy Nikolaev Newbie

            This description (13.2) is possible will help all of you to understand, then prompt also to me, at me precisely same problem...

            • 3. Re: Standalone Tomcat problems
              Dustin Norlander Apprentice

              Huh, I thought that the ds file was only valid for embedded-jboss installs? 


              here is the relevant portion of the startup log:


               INFO main org.hibernate.util.NamingHelper - JNDI InitialContext properties:{}
               INFO main org.hibernate.connection.DatasourceConnectionProvider - Using datasource: java:comp/env/jdbc/trendrrDB
               INFO main org.hibernate.cfg.SettingsFactory - RDBMS: MySQL, version: 5.0.41-log
               INFO main org.hibernate.cfg.SettingsFactory - JDBC driver: MySQL-AB JDBC Driver, version: mysql-connector-java-5.1.6 ( Revision: ${svn.Revision} )
               INFO main org.hibernate.dialect.Dialect - Using dialect: org.hibernate.dialect.MySQL5Dialect
               INFO main org.hibernate.transaction.TransactionFactoryFactory - Transaction strategy: org.hibernate.transaction.JDBCTransactionFactory
               INFO main org.hibernate.transaction.TransactionManagerLookupFactory - No TransactionManagerLookup configured (in JTA environment, use of read-write or transactional second-level cache is not recommended)
               INFO main org.hibernate.cfg.SettingsFactory - Automatic flush during beforeCompletion(): disabled
               INFO main org.hibernate.cfg.SettingsFactory - Automatic session close at end of transaction: disabled
               INFO main org.hibernate.cfg.SettingsFactory - JDBC batch size: 15
               INFO main org.hibernate.cfg.SettingsFactory - JDBC batch updates for versioned data: disabled
               INFO main org.hibernate.cfg.SettingsFactory - Scrollable result sets: enabled
               INFO main org.hibernate.cfg.SettingsFactory - JDBC3 getGeneratedKeys(): enabled
               INFO main org.hibernate.cfg.SettingsFactory - Connection release mode: auto
               INFO main org.hibernate.cfg.SettingsFactory - Maximum outer join fetch depth: 2
               INFO main org.hibernate.cfg.SettingsFactory - Default batch fetch size: 1
               INFO main org.hibernate.cfg.SettingsFactory - Generate SQL with comments: disabled
               INFO main org.hibernate.cfg.SettingsFactory - Order SQL updates by primary key: disabled
               INFO main org.hibernate.cfg.SettingsFactory - Order SQL inserts for batching: disabled
               INFO main org.hibernate.cfg.SettingsFactory - Query translator: org.hibernate.hql.ast.ASTQueryTranslatorFactory
               INFO main org.hibernate.hql.ast.ASTQueryTranslatorFactory - Using ASTQueryTranslatorFactory
               INFO main org.hibernate.cfg.SettingsFactory - Query language substitutions: {}
               INFO main org.hibernate.cfg.SettingsFactory - JPA-QL strict compliance: enabled
               INFO main org.hibernate.cfg.SettingsFactory - Second-level cache: enabled
               INFO main org.hibernate.cfg.SettingsFactory - Query cache: disabled
               INFO main org.hibernate.cfg.SettingsFactory - Cache provider: org.hibernate.cache.HashtableCacheProvider
               INFO main org.hibernate.cfg.SettingsFactory - Optimize cache for minimal puts: disabled
               INFO main org.hibernate.cfg.SettingsFactory - Structured second-level cache entries: disabled
               INFO main org.hibernate.cfg.SettingsFactory - Echoing all SQL to stdout
               INFO main org.hibernate.cfg.SettingsFactory - Statistics: disabled
               INFO main org.hibernate.cfg.SettingsFactory - Deleted entity synthetic identifier rollback: disabled
               INFO main org.hibernate.cfg.SettingsFactory - Default entity-mode: pojo
               INFO main org.hibernate.cfg.SettingsFactory - Named query checking : enabled
               INFO main org.hibernate.impl.SessionFactoryImpl - building session factory
              


              • 4. Re: Standalone Tomcat problems
                Dustin Norlander Apprentice

                Ok, I got it working..  I was deploying as a directory called trendrr.war (like I used to add a directory called trendrr.ear to jboss) -- apparently this confused tomcat which was trying to load two webapps (trendrr, and trendrr.war).  Correcting that fixed the problem.


                Thanks for the help

                • 5. Re: Standalone Tomcat problems
                  Eugeniy Nikolaev Newbie

                  Whether something from these two things is required for work Seam on Tomcat?


                  1) JBoss Microcontainer


                  2) JBoss Web


                  It is concrete at you - something from this is established?