[jboss-user] [JBoss Seam] - Embedded EJB / DS EM Configuration

eiswind70 do-not-reply at jboss.com
Tue Dec 5 09:52:24 EST 2006


I try to set up an embedded EJB/Seam Configuration. But Seam doesnt inject an Entity Manager when I try:


  | @In
  |   private EntityManager em;
  | 

I get a NPE. I treid to use the EntityManagerFactory then to obtain an EM, but then I get

  | 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 com.hp.test.domain.TestBenutzer.testBenutzer(TestBenutzer.java:31)
  | 	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.junit.internal.runners.TestMethodRunner.executeMethodBody(TestMethodRunner.java:99)
  | 	at org.junit.internal.runners.TestMethodRunner.runUnprotected(TestMethodRunner.java:81)
  | 	at org.junit.internal.runners.BeforeAndAfterRunner.runProtected(BeforeAndAfterRunner.java:34)
  | 	at org.junit.internal.runners.TestMethodRunner.runMethod(TestMethodRunner.java:75)
  | 	at org.junit.internal.runners.TestMethodRunner.run(TestMethodRunner.java:45)
  | 	at org.junit.internal.runners.TestClassMethodsRunner.invokeTestMethod(TestClassMethodsRunner.java:71)
  | 	at org.junit.internal.runners.TestClassMethodsRunner.run(TestClassMethodsRunner.java:35)
  | 	at org.junit.internal.runners.TestClassRunner$1.runUnprotected(TestClassRunner.java:42)
  | 	at org.junit.internal.runners.BeforeAndAfterRunner.runProtected(BeforeAndAfterRunner.java:34)
  | 	at org.junit.internal.runners.TestClassRunner.run(TestClassRunner.java:52)
  | 	at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:38)
  | 	at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
  | 	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
  | 	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
  | 	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
  | 	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
  | 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)
  | 	... 24 more
  | Caused by: javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file:  java.naming.factory.initial
  | 	at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:645)
  | 	at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:247)
  | 	at javax.naming.InitialContext.getURLOrDefaultInitCtx(InitialContext.java:284)
  | 	at javax.naming.InitialContext.lookup(InitialContext.java:351)
  | 	at org.hibernate.connection.DatasourceConnectionProvider.configure(DatasourceConnectionProvider.java:52)
  | 	... 33 more
  | 
  | 

altough I have a DataSource declared in embedded-jboss-beans.xml


  |  <bean name="DefaultDSBootstrap"
  |     class="org.jboss.resource.adapter.jdbc.local.LocalTxDataSource">
  |     <property name="driverClass">
  |       <value>com.edb.Driver</value>
  |     </property>
  |     <property name="connectionURL">
  |       <value>jdbc:edb://127.0.0.1:5444/asd</value>
  |     </property>
  |     <property name="userName">
  |       <value>sa</value>
  |     </property>
  |     <property name="jndiName">
  |       <value>java:/AsdDS</value>
  |     </property>
  |     <property name="minSize">
  |       <value>0</value>
  |     </property>
  |     <property name="maxSize">
  |       <value>10</value>
  |     </property>
  |     <property name="blockingTimeout">
  |       <value>1000</value>
  |     </property>
  |     <property name="idleTimeout">
  |       <value>50000</value>
  |     </property>
  |     <property name="transactionManager">
  |       <inject bean="TransactionManager" />
  |     </property>
  |     <property name="cachedConnectionManager">
  |       <inject bean="CachedConnectionManager" />
  |     </property>
  |     <property name="initialContextProperties">
  |       <inject bean="InitialContextProperties" />
  |     </property>
  |   </bean>
  | 
  |   <bean name="DefaultDS" class="java.lang.Object">
  |     <constructor factoryMethod="getDatasource">
  |       <factory bean="DefaultDSBootstrap" />
  |     </constructor>
  |   </bean>
  | 

can anyone help me with this ? Thx in advance

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

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



More information about the jboss-user mailing list