entity manager not working on RC4
r_q_d Feb 2, 2006 1:59 AMHi, There,
I have a ejb jar file works fine with RC3, but it failed with the RC4.
My persistence.xml is like this:
<?xml version="1.0" encoding="UTF-8"?> <persistence> <persistence-unit name="mydb"> <jta-data-source>java:/OracleDS</jta-data-source> <properties> <property name="hibernate.hbm2ddl.auto" value="update"/> </properties> </persistence-unit> </persistence>
My datasource file is like this:
<?xml version="1.0" encoding="UTF-8"?> <datasources> <local-tx-datasource> <jndi-name>OracleDS</jndi-name> <connection-url>jdbc:oracle:thin:@rqd1:1521:oracle</connection-url> <driver-class>oracle.jdbc.driver.OracleDriver</driver-class> <user-name>development</user-name> <password>quande</password> <exception-sorter-class-name>org.jboss.resource.adapter.jdbc.vendor.OracleExceptionSorter</exception-sorter-class-name> <metadata> <type-mapping>Oracle8</type-mapping> </metadata> </local-tx-datasource> </datasources>
In my stateless session bean, I have the code like this:
@PersistenceContext(unitName="mydb") private EntityManager manager;
I get error like this:
01:32:00,875 INFO [JmxKernelAbstraction] installing MBean:jboss.j2ee:service=EJB3,jar=ejb-lf.ejb3,name=SessionFacadeImpl with dependencies: 01:32:00,875 INFO [JmxKernelAbstraction] persistence.units:jar=ejb-lf.ejb3.jar,unitName=mydb 01:32:00,875 INFO [EJB3Deployer] Deployed: file:/C:/JavaApp/jboss-4.0.3SP1/serv er/all/deploy/ejb-lf.ejb3 01:32:00,906 INFO [TomcatDeployer] deploy, ctxPath=/jmx-console, warUrl=.../dep loy/jmx-console.war/ 01:32:01,125 ERROR [URLDeploymentScanner] Incomplete Deployment listing: --- MBeans waiting for other MBeans --- ObjectName: persistence.units:jar=ejb-lf.ejb3.jar,unitName=mydb State: FAILED Reason: java.lang.reflect.InvocationTargetException I Depend On: jboss.jca:service=DataSourceBinding,name=OracleDS Depends On Me: jboss.j2ee:service=EJB3,jar=ejb-lf.ejb3,name=SessionFacadeImpl ObjectName: jboss.j2ee:service=EJB3,jar=ejb-lf.ejb3,name=SessionFacadeImpl State: NOTYETINSTALLED I Depend On: persistence.units:jar=ejb-lf.ejb3.jar,unitName=mydb --- MBEANS THAT ARE THE ROOT CAUSE OF THE PROBLEM --- ObjectName: persistence.units:jar=ejb-lf.ejb3.jar,unitName=mydb State: FAILED Reason: java.lang.reflect.InvocationTargetException I Depend On: jboss.jca:service=DataSourceBinding,name=OracleDS Depends On Me: jboss.j2ee:service=EJB3,jar=ejb-lf.ejb3,name=SessionFacadeImpl
If I change this code like this
@PersistenceContext //without the unitName private EntityManager manager;
Still get the same error.
I am wandering what is the usage of the name in the <persistence-unit name="mydb">
Also the page at docs\tutorial\entity\entity.html has words like this:
you will probably need to define a hibernate.properties file in the META-INF directory of the JAR. hibernate.properties is needed if you need to hook in a datasource other than JBoss's DefaultDS, or change the caching of Hibernate.
Is it possible that somebody provide a working example for oracle or other datasource?
Any help is greatly appreciated.