4 Replies Latest reply on Aug 13, 2008 10:24 PM by samdoyle

    TestNG problem with Eclipse

    samdoyle

      Hello,


      I have followed the instructions specified for the Eclipse TestNG plugin in the readme file within a seam-gen project however, I am getting this exception constantly when trying to run me testcases.


      FATAL [org.hibernate.connection.DatasourceConnectionProvider] Could not find datasource: java:/event-management-toolDatasource
      java.lang.RuntimeException: PROVIDER_URL not provided in jndi.properties.  Automatic discovery not implemented yet.
           at org.jboss.naming.JBossRemotingContextFactory.getInitialContext(JBossRemotingContextFactory.java:158)
           at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:667)
           at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:247)
           at javax.naming.InitialContext.init(InitialContext.java:223)
           at javax.naming.InitialContext.<init>(InitialContext.java:175)
           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:2009)
           at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1292)
           at org.hibernate.cfg.AnnotationConfiguration.buildSessionFactory(AnnotationConfiguration.java:918)
           at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:656)
           at org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:121)
           at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:52)
           at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:34)



      I have tried various configuration options including specifying the parameters directly instead of using JNDI within the persistence.xml. When I do this however it gives me an exception complaining about No Persistence provider for the persistent unit.


      Thanks for your time.

        • 1. Re: TestNG problem with Eclipse
          thejavafreak

          What Seam version are you using?
          Is embedded JBoss located in your classpath?

          • 2. Re: TestNG problem with Eclipse
            jnusaira

            are you only getting this when running in eclipse? or are you getting it when running via a command line of ant test



            Also what does your unit test look like?


            I used to get that error when i tried to lookup the EntityManagerFactory in my setups and tear downs.

            • 3. Re: TestNG problem with Eclipse
              samdoyle

              This problem only happens from Eclipse, ant test does work fine. I have followed the instructions for setting up the environment for Eclipse so yes the jboss-embedded-all.jar is in my path.


              We are using Seam 2.0.0.GA

              • 4. Re: TestNG problem with Eclipse
                samdoyle

                Alright so I resolved this but it is really odd.


                It manifested itself when I attempted to lookup the EntityManager in my test method since it the container didn't appear to be initialized. When I removed my @BeforeClass method and moved everything into the test the container was initialized and everything worked fine.