7 Replies Latest reply on Jun 7, 2008 6:02 AM by rnerurka

    SeamListener cannot find datasource! (Seam 2.0 on Tomcat 6) Why??

    billevans

      This is driving me nuts but I sense that I almost have the last piece in the puzzle ... can anyone help me?


      Summary:
      I have built a complex Seam application and it runs great on JBoss AS 4.2. Now I need to have it run on Tomcat 6.


      I followed the instructions as they are laid out in the wiki:
      1. I installed JBoss Embedded to Tomcat
      2. I added the listeners to server.xml and context.xml
      3. I set-up my my persistence, hibernate and components files


      -------------------- components.xml ------------------



         <persistence:hibernate-session-factory name="hibernateSessionFactory"/>
         <persistence:managed-hibernate-session name="gadb" auto-create="true" session-factory-jndi-name="java:/gadb"/>
         <transaction:hibernate-transaction session="#{gadb}"/>
         <factory name="session" scope="STATELESS" auto-create="true" value="#{entityManager.delegate}"/>



        


      -------------------- persistence.xml ------------------


      <persistence-unit name="gadb" transaction-type="JTA">
            <provider>org.hibernate.ejb.HibernatePersistence</provider>
            <jta-data-source>java:/gaDatasource</jta-data-source>
            <properties>
               <property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect"/> 
                <property name="hibernate.show_sql" value="true"/>
               <property name="hibernate.format_sql" value="true"/>
               
            </properties>
         </persistence-unit>




      ------------------- hibernate.cfg.xml -----------------


      <session-factory name="java:/gadb">
                      <property name="show_sql">true</property>               
                      <property name="dialect">org.hibernate.dialect.MySQLDialect</property> 
                      <property name="connection.datasource">java:/gaDatasource</property>
                      <property name="cache.provider_class">org.hibernate.cache.HashtableCacheProvider</property>
                      <property name="transaction.flush_before_completion">true</property>
                      <property name="connection.release_mode">after_statement</property>
                      <property name="transaction.manager_lookup_class">org.hibernate.transaction.JBossTransactionManagerLookup</property>
                      <property name="transaction.factory_class">org.hibernate.transaction.JTATransactionFactory</property>
      



      ----------------- Code to access the Session ----------------------------       


      @In Session gadb;






      My application fires up and everything parses successfully, but when the SeamListener goes after the datasource it simply cannot find it:


      SEVERE: Exception sending context initialized event to listener instance of class org.jboss.seam.servlet.SeamListener
      org.hibernate.HibernateException: Could not find datasource: java:/gaDatasource
              at org.hibernate.connection.DatasourceConnectionProvider.configure(DatasourceConnectionProvider.java:59)
              at org.hibernate.connection.ConnectionProviderFactory.newConnectionProvider(ConnectionProviderFactory.java:124)
              at org.hibernate.connection.ConnectionProviderFactory.newConnectionProvider(ConnectionProviderFactory.java:56)
      




      I'd REALLY appreciate help on this as I have being on this for 3 days already!!


        • 1. Re: SeamListener cannot find datasource! (Seam 2.0 on Tomcat 6) Why??
          kariem

          I don't think, this is a seam-related problem. Did you configure the data source in tomcat? You had to configure it in JBoss too, right?


          I'm not sure whether you can just deploy something similar to a JBoss xxx-ds.xml file on Tomcat, but you can look for the configuration of Tomcat's resource factory in the tomcat documentation on JDBC data sources in JNDI.


          • 2. Re: SeamListener cannot find datasource! (Seam 2.0 on Tomcat 6) Why??
            billevans

            I was my understanding that since Tomcat's JNDI is read-only, it is not usable and once JBoss Embedded is installed, that is the JNDI provider. Therefore, providing a context for Tomcat is unnecessary.


            I forgot to provide info on where I define my JDBC. I put it in a file called hibernate-ds.xml:



            <datasources>   
               <local-tx-datasource>
                  <jndi-name>gaDatasource</jndi-name>      
                  <connection-url>jdbc:mysql://vijay:3306/xxx</connection-url>      
                  <driver-class>com.mysql.jdbc.Driver</driver-class>
                  <user-name>xx</user-name>
                  <password>xx</password>
               </local-tx-datasource>    
            </datasources>



            Also, here are the versions of the software:



            Tomcat 6.0.14
            embedded-jboss-beta3.zip
            Seam 2.0.1.CR1




            Here are some relevant excerpts from my log. First the JBoss Embedded stuff. NOTE: This shows that  the ConnectionFactoryBindingService successfully bound gaDatasource to JNDI (java:gaDatasource), and then started a persistence unit with name gadb.



            WARN  [org.jboss.mx.loading.UnifiedLoaderRepository3] Tried to add non-URLClassLoader.  Ignored
            WARN  [org.jboss.aop.deployment.AspectManagerService] Could not find base-aspects.xml file in the resources of org.apache.catalina.loader.StandardClassLoader@b6ece5
            INFO  [org.jboss.aop.deployers.AspectDeployer] Deploying xml into org.jboss.aop.AspectManager@77baf4 for org.apache.catalina.loader.StandardClassLoader@b6ece5
            INFO  [org.jboss.resource.deployers.RARDeployment] Required license terms exist, view vfsfile:/C:/apache-tomcat-6.0.14/lib/deploy/jboss-local-jdbc.rar/META-INF/ra.xml
            INFO  [org.jboss.resource.connectionmanager.ConnectionFactoryBindingService] Bound ConnectionManager 'jboss.jca:service=DataSourceBinding,name=DefaultDS' to JNDI name 'java:DefaultDS'
            INFO  [org.jboss.resource.deployers.RARDeployment] Required license terms exist, view vfsfile:/C:/apache-tomcat-6.0.14/lib/deploy/jboss-xa-jdbc.rar/META-INF/ra.xml
            INFO  [org.jboss.resource.deployers.RARDeployment] Required license terms exist, view vfsfile:/C:/apache-tomcat-6.0.14/lib/deploy/jms-ra.rar/META-INF/ra.xml
            WARN  [org.jboss.jms.server.security.SecurityMetadataStore] WARNING! POTENTIAL SECURITY RISK. It has been detected that the MessageSucker component which sucks messages from one node to another has not had its password changed fro
            m the installation default. Please see the JBoss Messaging user guide for instructions on how to do this.
            INFO  [org.jboss.jms.server.ServerPeer] JBoss Messaging 1.4.0.SP1 server [0] started
            INFO  [org.jboss.jms.server.connectionfactory.ConnectionFactory] Connector bisocket://bevans:4457 has leasing enabled, lease period 10000 milliseconds
            INFO  [org.jboss.jms.server.connectionfactory.ConnectionFactory] org.jboss.jms.server.connectionfactory.ConnectionFactory@1d22ddb started
            WARN  [org.jboss.jms.server.connectionfactory.ConnectionFactoryJNDIMapper] supportsFailover attribute is true on connection factory: jboss.messaging.connectionfactory:service=ClusteredConnectionFactory but post office is non clust
            ered. So connection factory will *not* support failover
            WARN  [org.jboss.jms.server.connectionfactory.ConnectionFactoryJNDIMapper] supportsLoadBalancing attribute is true on connection factory: jboss.messaging.connectionfactory:service=ClusteredConnectionFactory but post office is non
            clustered. So connection factory will *not* support load balancing
            INFO  [org.jboss.jms.server.connectionfactory.ConnectionFactory] Connector bisocket://bevans:4457 has leasing enabled, lease period 10000 milliseconds
            INFO  [org.jboss.jms.server.connectionfactory.ConnectionFactory] org.jboss.jms.server.connectionfactory.ConnectionFactory@9aa764 started
            INFO  [org.jboss.jms.server.destination.QueueService] Queue[/queue/DLQ] started, fullSize=200000, pageSize=2000, downCacheSize=2000
            INFO  [org.jboss.jms.server.destination.QueueService] Queue[/queue/ExpiryQueue] started, fullSize=200000, pageSize=2000, downCacheSize=2000
            INFO  [org.jboss.jms.server.connectionfactory.ConnectionFactory] Connector bisocket://bevans:4457 has leasing enabled, lease period 10000 milliseconds
            INFO  [org.jboss.jms.server.connectionfactory.ConnectionFactory] org.jboss.jms.server.connectionfactory.ConnectionFactory@30cd64 started
            INFO  [org.jboss.resource.connectionmanager.ConnectionFactoryBindingService] Bound ConnectionManager 'jboss.jca:service=ConnectionFactoryBinding,name=JmsXA' to JNDI name 'java:JmsXA'
            Mar 12, 2008 7:26:20 AM org.apache.catalina.core.StandardService start
            INFO: Starting service Catalina
            Mar 12, 2008 7:26:20 AM org.apache.catalina.core.StandardEngine start
            INFO: Starting Servlet Engine: Apache Tomcat/6.0.14
            Mar 12, 2008 7:26:20 AM org.apache.catalina.startup.HostConfig deployWAR
            INFO: Deploying web application archive newRiskApp.war
            Mar 12, 2008 7:26:20 AM org.apache.catalina.loader.WebappLoader start
            INFO: Dual registration of jndi stream handler: factory already defined
            INFO  [org.jboss.ejb3.deployers.PersistenceUnitParsingDeployer] Found persistence units [org.jboss.ejb3.metadata.jpa.spec.PersistenceUnitMetaData@30cefd{name=gadb}]
            WARN  [org.jboss.xb.builder.runtime.CollectionPropertyHandler] ClassInfo.getDeclaredConstructor(null) didn't work for org.jboss.metadata.ejb.spec.InterceptorClassesMetaData, found the default ctor in ClassInfo.getDeclaredConstruct
            ors()
            INFO  [org.jboss.ejb3.deployers.AppClientScanningDeployer] mainClass = class com.lowagie.tools.ToolboxAvailable
            INFO  [org.jboss.ejb3.deployers.AppClientScanningDeployer] mainClass = class org.jboss.cache.Version
            INFO  [org.jboss.ejb3.deployers.AppClientScanningDeployer] mainClass = class org.jboss.kernel.plugins.bootstrap.standalone.StandaloneBootstrap
            INFO  [org.jboss.ejb3.deployers.AppClientScanningDeployer] mainClass = class org.jgroups.Version
            INFO  [org.jboss.ejb3.MCKernelAbstraction] installing bean: jboss.j2ee:jar=jboss-seam.jar,name=TimerServiceDispatcher,service=EJB3 with dependencies:
            INFO  [org.jboss.ejb3.MCKernelAbstraction]   and supplies:
            INFO  [org.jboss.ejb3.MCKernelAbstraction]      Class:org.jboss.seam.async.LocalTimerServiceDispatcher
            INFO  [org.jboss.ejb3.EJBContainer] STARTED EJB: org.jboss.seam.async.TimerServiceDispatcher ejbName: TimerServiceDispatcher
            WARN  [org.jboss.ejb3.timerservice.jboss.JBossTimerServiceFactory] TIMER SERVICE IS NOT INSTALLED
            INFO  [org.jboss.ejb3.MCKernelAbstraction] installing bean: jboss.j2ee:jar=jboss-seam.jar,name=EjbSynchronizations,service=EJB3 with dependencies:
            INFO  [org.jboss.ejb3.MCKernelAbstraction]   and supplies:
            INFO  [org.jboss.ejb3.MCKernelAbstraction]      Class:org.jboss.seam.transaction.LocalEjbSynchronizations
            INFO  [org.jboss.ejb3.EJBContainer] STARTED EJB: org.jboss.seam.transaction.EjbSynchronizations ejbName: EjbSynchronizations
            INFO  [org.jboss.ejb3.MCKernelAbstraction] installing bean: persistence.units:unitName=gadb with dependencies:
            INFO  [org.jboss.ejb3.MCKernelAbstraction]   and supplies:
            INFO  [org.jboss.resource.connectionmanager.ConnectionFactoryBindingService] Bound ConnectionManager 'jboss.jca:service=DataSourceBinding,name=gaDatasource' to JNDI name 'java:gaDatasource'
            INFO  [org.jboss.ejb3.entity.PersistenceUnitDeployment] Starting persistence unit persistence.units:unitName=gadb
            INFO  [org.hibernate.cfg.annotations.Version] Hibernate Annotations 3.3.1.Beta1
            INFO  [org.hibernate.cfg.Environment] Hibernate 3.2.4.sp1
            INFO  [org.hibernate.cfg.Environment] hibernate.properties not found
            INFO  [org.hibernate.cfg.Environment] Bytecode provider name : javassist
            INFO  [org.hibernate.cfg.Environment] using JDK 1.4 java.sql.Timestamp handling
            INFO  [org.hibernate.ejb.Version] Hibernate EntityManager 3.3.2.Beta1
            INFO  [org.hibernate.ejb.Ejb3Configuration] Processing PersistenceUnitInfo [
                    name: gadb
                    ...]
            WARN  [org.hibernate.ejb.Ejb3Configuration] Persistence provider caller does not implement the EJB3 spec correctly. PersistenceUnitInfo.getNewTempClassLoader() is null.



            After this, the hibernate.cfg.xml file is read and here is where it should pick up the JNDI configured JDBC, but it fails:



            WARN  [org.hibernate.connection.UserSuppliedConnectionProvider] No connection properties specified - the user must supply JDBC connections



            It is then later that the SeamListener tries to get a handle that failure is fatal.

            • 3. Re: SeamListener cannot find datasource! (Seam 2.0 on Tomcat 6) Why??
              billevans

              By the way, don't think I didn't try using a Tomcat context.xml file.


              First I tried using that and the hibernate-ds.xml file. When I did this I got a conflict:



              ERROR [org.jboss.kernel.plugins.dependency.AbstractKernelController] Error installing to Start: name=jboss.jca:name=comp/env/jdbc/gaDatasource,service=DataSourceBinding state=Create mode=Manual requiredState=Installed
              org.jboss.deployment.DeploymentException: Could not bind ConnectionFactory into jndi: java:comp/env/jdbc/gaDatasource
                      at org.jboss.resource.connectionmanager.ConnectionFactoryBindingService.bindConnectionFactory(ConnectionFactoryBindingService.java:164)
              ...
              Caused by: javax.naming.NameAlreadyBoundException; remaining name 'comp'
                      at org.jnp.server.NamingServer.createSubcontext(NamingServer.java:465)
                      at org.jnp.interfaces.NamingContext.createSubcontext(NamingContext.java:1059)
              



              Then, I tried with JUST the context.xml (no hibernate-ds file) and got the following:



              java.lang.RuntimeException: org.jboss.deployers.client.spi.IncompleteDeploymentException: Summary of incomplete deployments (SEE PREVIOUS ERRORS FOR DETAILS):
              
              *** CONTEXTS MISSING DEPENDENCIES: Name -> Dependency{Required State:Actual State}
              
              persistence.units:unitName=gadb
               -> <UNKNOWN>{Described:** UNRESOLVED Demands 'jboss.jca:name=comp/env/jdbc/gaDatasource,service=DataSourceBinding **}
              
              
              *** CONTEXTS IN ERROR: Name -> Error
              
              <UNKNOWN> -> ** UNRESOLVED Demands 'jboss.jca:name=comp/env/jdbc/gaDatasource,service=DataSourceBinding **





              • 4. Re: SeamListener cannot find datasource! (Seam 2.0 on Tomcat 6) Why??
                billevans

                Ok, I think the hibernate warning:



                WARN  [org.hibernate.connection.UserSuppliedConnectionProvider] No connection properties specified - the user must supply JDBC connections




                ... is a red fish, because when I change the value of 'connection.datasource' to something completely invalid, I get:



                FATAL [org.hibernate.connection.DatasourceConnectionProvider] Could not find datasource: gaDatasource
                javax.naming.NameNotFoundException: gaDatasource not bound



                So, the problem must lie in how Seam is interacting with Hibernate.


                Here's the full exception I get:



                SEVERE: Exception sending context initialized event to listener instance of class org.jboss.seam.servlet.SeamListener
                org.hibernate.HibernateException: Could not find datasource: java:gaDatasource
                     at org.hibernate.connection.DatasourceConnectionProvider.configure(DatasourceConnectionProvider.java:59)
                     at org.hibernate.connection.ConnectionProviderFactory.newConnectionProvider(ConnectionProviderFactory.java:124)
                     at org.hibernate.connection.ConnectionProviderFactory.newConnectionProvider(ConnectionProviderFactory.java:56)
                     at org.hibernate.cfg.SettingsFactory.createConnectionProvider(SettingsFactory.java:414)
                     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:918)
                     at org.jboss.seam.persistence.HibernateSessionFactory.createSessionFactory(HibernateSessionFactory.java:165)
                     at org.jboss.seam.persistence.HibernateSessionFactory.startup(HibernateSessionFactory.java:79)
                     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:585)
                     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:2082)
                     at org.jboss.seam.Component.callCreateMethod(Component.java:2005)
                     at org.jboss.seam.Component.newInstance(Component.java:1976)
                     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:583)
                     at org.jboss.seam.servlet.SeamListener.contextInitialized(SeamListener.java:34)
                     at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3830)
                     at org.apache.catalina.core.StandardContext.start(StandardContext.java:4337)
                     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:825)
                     at org.apache.catalina.startup.HostConfig.deployWARs(HostConfig.java:714)
                     at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:490)
                     at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1138)
                     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:566)
                     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:585)
                     at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288)
                     at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)




                Come on SEAM experts, throw me a bone! I'm dying here!

                • 5. Re: SeamListener cannot find datasource! (Seam 2.0 on Tomcat 6) Why??
                  joff

                  I'd just like to throw in a me too here - regarding the missing dependencies problem.


                  I can't seem to find anywhere any documentation as to how to get a Seam project set up with a datasource in Tomcat.. certainly not for a project created with seam-gen.


                  (I am using the embedded-jboss-beta3 btw)


                  • 6. Re: SeamListener cannot find datasource! (Seam 2.0 on Tomcat 6) Why??
                    pmuir

                    Copy the -ds.xml into the deploy folder.


                    All the Seam examples do this when you deploy to tomcat.

                    • 7. Re: SeamListener cannot find datasource! (Seam 2.0 on Tomcat 6) Why??
                      rnerurka

                      I am getting a similar error. However I haven't installed the EJ3 embedded component but I have seen a JPA example in the examples directory of Seam distribution that has I was able to successfully deploy on Tomcat 6 without the embedded EB3. No errors!.


                      Only when I try to deploy a Seam application build using the Seam Web Project plug-in for Eclipse and that too without installing the embedded EJB3 component that I get the datasource not found error.


                      I haven't tried packaging the Seam Web Project eclipse plug-in application using ant into a war file and seeing the result. I will be trying that soon.


                      Your help in this matter will help us select our technology stack at UCLA for our Financial department. Seam is the frontrunner in this evaluation process but it has to run on Tomcat 6 without embedded JBoss!


                      Regards
                      Raj