3 Replies Latest reply on Sep 18, 2007 12:00 PM by valbosoft

    testing in pojo environment with eclipse

    valbosoft

      Hello,

      I have a working seam application in eclipse, and I'm now trying to set a test.
      No ejb is used. The application runs on tomcat from within eclipse.

      When I run the test, Seam seems to start up ok, but I get the following error:

      12:16:06,621 INFO [Environment] Hibernate 3.2.1
      12:16:06,621 INFO [Environment] hibernate.properties not found
      12:16:06,637 INFO [Environment] Bytecode provider name : cglib
      12:16:06,668 INFO [Environment] using JDK 1.4 java.sql.Timestamp handling
      12:16:18,715 INFO [AnnotationBinder] Binding entity from annotated class: com.inmobiliaria.entity.Inmueble
      12:16:18,824 INFO [EntityBinder] Bind entity com.inmobiliaria.entity.Inmueble on table Inmueble
      
      ...
      12:16:19,496 INFO [NamingHelper] JNDI InitialContext properties:{}
      12:16:19,574 ERROR [NamingHelper] Could not obtain initial context
      javax.naming.NamingException: Local server is not initialized
       at org.jnp.interfaces.LocalOnlyContextFactory.getInitialContext(LocalOnlyContextFactory.java:30)
       at javax.naming.spi.NamingManager.getInitialContext(Unknown Source)
       at javax.naming.InitialContext.getDefaultInitCtx(Unknown Source)
       at javax.naming.InitialContext.init(Unknown Source)
       at javax.naming.InitialContext.<init>(Unknown Source)
       at org.hibernate.util.NamingHelper.getInitialContext(NamingHelper.java:28)
       at org.hibernate.connection.DatasourceConnectionProvider.configure(DatasourceConnectionProvider.java:52)
       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:2006)
       at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1289)
       at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:713)
       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 com.inmobiliaria.test.PersonaTest.getEntityManager(PersonaTest.java:76)
       at com.inmobiliaria.test.PersonaTest.testRegisterAction(PersonaTest.java:19)
       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.testng.internal.MethodHelper.invokeMethod(MethodHelper.java:604)
       at org.testng.internal.Invoker.invokeMethod(Invoker.java:470)
       at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:564)
       at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:830)
       at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:125)
       at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:109)
       at org.testng.TestRunner.runWorkers(TestRunner.java:678)
       at org.testng.TestRunner.privateRun(TestRunner.java:624)
       at org.testng.TestRunner.run(TestRunner.java:495)
       at org.testng.SuiteRunner.runTest(SuiteRunner.java:300)
       at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:295)
       at org.testng.SuiteRunner.privateRun(SuiteRunner.java:275)
       at org.testng.SuiteRunner.run(SuiteRunner.java:190)
       at org.testng.TestNG.createAndRunSuiteRunners(TestNG.java:792)
       at org.testng.TestNG.runSuitesLocally(TestNG.java:765)
       at org.testng.TestNG.run(TestNG.java:699)
       at org.testng.remote.RemoteTestNG.run(RemoteTestNG.java:73)
       at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:122)
      12:16:19,590 FATAL [DatasourceConnectionProvider] Could not find datasource: java:/DefaultDS


      I guess the test environment cannot find the persistence.xml
      Can anybody give a pointer on where I should place it? Or what else could be the cause?
      I've tried several options: place it in src/WEB-INF, created a resources source directory with a WEB-INF directory, but no luck.

      Regards, Bo

        • 1. Re: testing in pojo environment with eclipse
          pmuir

          Which version of Seam?

          • 2. Re: testing in pojo environment with eclipse
            valbosoft

            I'm using version 1.2.1 GA

            • 3. Re: testing in pojo environment with eclipse
              valbosoft

              Hi,

              actually I think persistence.xml IS being read, and that it can't find jboss-beans.xml (I have JPA configured, copied from the booking example)

              BTW, my project structure is the following:

              project
               src
               META-INF
               persistence.xml
               jboss-beans.xml
               jboss-beans.xml (just in case)
               jndi.properties
               log4j.xml
               seam.properties
               test
               WebContent
               WEB-INF
              

              here's 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="bookingDatabase" transaction-type="JTA">
               <provider>org.hibernate.ejb.HibernatePersistence</provider>
               <jta-data-source>java:/DefaultDS</jta-data-source>
               <properties>
               <property name="hibernate.show_sql" value="true"/>
               <property name="hibernate.dialect" value="org.hibernate.dialect.PostgreSQLDialect"/>
               <property name="hibernate.cache.provider_class" value="org.hibernate.cache.HashtableCacheProvider"/>
               <property name="hibernate.transaction.manager_lookup_class" value="org.hibernate.transaction.JBossTransactionManagerLookup"/>
               <!-- alternative
               <property name="jboss.entity.manager.factory.jndi.name"
               value="java:/jpaBookingEntityManagerFactory"/>
               -->
               </properties>
               </persistence-unit>
              </persistence>
              

              and here jboss-beans.xml:
              <?xml version="1.0" encoding="UTF-8"?>
              
              <deployment xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
               xsi:schemaLocation="urn:jboss:bean-deployer bean-deployer_1_0.xsd"
               xmlns="urn:jboss:bean-deployer">
              
               <bean name="Naming" class="org.jnp.server.SingletonNamingServer"/>
              
               <bean name="TransactionManagerFactory"
               class="org.jboss.seam.microcontainer.TransactionManagerFactory"/>
               <bean name="TransactionManager" class="java.lang.Object">
               <constructor factoryMethod="getTransactionManager">
               <factory bean="TransactionManagerFactory"/>
               </constructor>
               </bean>
              
               <bean name="bookingDatasourceFactory"
               class="org.jboss.seam.microcontainer.DataSourceFactory">
               <property name="driverClass">org.postgresql.Driver</property>
               <property name="connectionUrl">jdbc:postgresql://localhost/inmobiliarias?charSet=LATIN1</property>
               <property name="userName">myuser</property>
               <property name="password">mypassword</property>
               <property name="jndiName">java:/DefaultDS</property>
               <property name="minSize">0</property>
               <property name="maxSize">10</property>
               <property name="blockingTimeout">1000</property>
               <property name="idleTimeout">100000</property>
               <property name="transactionManager">
               <inject bean="TransactionManager"/>
               </property>
               </bean>
               <bean name="bookingDatasource" class="java.lang.Object">
               <constructor factoryMethod="getDataSource">
               <factory bean="bookingDatasourceFactory"/>
               </constructor>
               </bean>
              
              </deployment>
              


              Anybody can see some error?

              Regards