[jboss-user] [JBoss Seam] - Seam Unit Testing Problem: javax.naming.NamingException: Loc

i77ac_10 do-not-reply at jboss.com
Wed Apr 11 02:38:58 EDT 2007


Hi,

I'm following this example (http://docs.jboss.com/seam/1.2.1.GA/reference/en/html/testing.html#d0e15875) for writing a unit test for seam.  However, I'm getting a NamingException when I try to create the EntityManagerFactory.  Anyone know whats up with this?

Here is the code for creating the EntityManagerFactory

  emf = Persistence.createEntityManagerFactory("myPersistenceUnitName");


Here is the exception stack trace:
  javax.persistence.PersistenceException: org.hibernate.HibernateException: Could not find datasource
  | 	at org.hibernate.ejb.Ejb3Configuration.createEntityManagerFactory(Ejb3Configuration.java:217)
  | 	at org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:114)
  | 	at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:37)
  | 	at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:27)
  | 	at test.model.TestNGTest.init(TestNGTest.java:61)
  | 	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.testng.internal.MethodHelper.invokeMethod(MethodHelper.java:529)
  | 	at org.testng.internal.Invoker.invokeConfigurationMethod(Invoker.java:311)
  | 	at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:149)
  | 	at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:77)
  | 	at org.testng.TestRunner.privateRun(TestRunner.java:614)
  | 	at org.testng.TestRunner.run(TestRunner.java:505)
  | 	at org.testng.SuiteRunner.privateRun(SuiteRunner.java:221)
  | 	at org.testng.SuiteRunner.run(SuiteRunner.java:147)
  | 	at org.testng.TestNG.createAndRunSuiteRunners(TestNG.java:576)
  | 	at org.testng.TestNG.runSuitesLocally(TestNG.java:539)
  | 	at org.testng.TestNG.run(TestNG.java:316)
  | 	at org.testng.TestNG.privateMain(TestNG.java:666)
  | 	at org.testng.TestNG.main(TestNG.java:608)
  | 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:61)
  | 	at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:1928)
  | 	at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1211)
  | 	at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:631)
  | 	at org.hibernate.ejb.Ejb3Configuration.createEntityManagerFactory(Ejb3Configuration.java:760)
  | 	at org.hibernate.ejb.Ejb3Configuration.createFactory(Ejb3Configuration.java:151)
  | 	at org.hibernate.ejb.Ejb3Configuration.createEntityManagerFactory(Ejb3Configuration.java:205)
  | 	... 21 more
  | Caused by: javax.naming.NamingException: Local server is not initialized
  | 	at org.jnp.interfaces.LocalOnlyContextFactory.getInitialContext(LocalOnlyContextFactory.java:45)
  | 	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)
  | 	... 30 more



View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4036220#4036220

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4036220



More information about the jboss-user mailing list