2 Replies Latest reply on Mar 8, 2008 1:58 AM by Francisco Jose Peredo Noguez

    Example of Seam in Java SE, without JBoss Embedded

    Francisco Jose Peredo Noguez Master

      Hi!


      Where can I find an Example of Seam in Java SE, without JBoss Embedded, I have been trying to do it myself, but after adding lots of missing jars one by one without any guidance I end up with the following error:


      SEVERE: Exception sending context initialized event to listener instance of class org.jboss.seam.servlet.SeamListener
      javax.persistence.PersistenceException: org.hibernate.HibernateException: Could not find datasource
           at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:720)
           at org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:121)
           at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:51)
           at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:33)
           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:2090)
           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.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: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:597)
           at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288)
           at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)
      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.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:713)
           ... 34 more
      Caused by: javax.naming.NameNotFoundException: Name seamonlytomcatDatasource is not bound in this Context
           at org.apache.naming.NamingContext.lookup(NamingContext.java:770)
           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)
           ... 40 more
      
      



      I dont know why it can not find seamonlytomcatDatasource, my context.xml file has:


       <Context docBase="seam.only.tomcat" path="/seam.only.tomcat"
           reloadable="true"
           source="org.eclipse.jst.jee.server:seam.only.tomcat">
           <Resource name="seamonlytomcatDatasource" auth="Container"
                type="javax.sql.DataSource" maxActive="100" maxIdle="30"
                maxWait="10000" username="sa" password=""
                driverClassName="org.hsqldb.jdbcDriver" url="jdbc:hsqldb:mem:test" />
      </Context>
      



      And my 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="seam.only.tomcat">
            <provider>org.hibernate.ejb.HibernatePersistence</provider>
            <non-jta-data-source>seamonlytomcatDatasource</non-jta-data-source>      
            <properties>
               <property name="hibernate.dialect" value="org.hibernate.dialect.HSQLDialect"/>
               <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>
          
      </persistence>
      



      Any hints?


      (BTW if you want to know why I want to make this work, it is because I want to integrate seam with an existing project that already runs in plain tomcat, and embedding jboss is a politically blocked option)


      Thanks
      Regards,