0

I am getting the following error when I am using Jboss 4.2.3 GA and configured my ms-sql.ds file. I created an Entity Bean EJB3 and I am trying to access that Entity bean from EJB 2.1 Session Bean. First of all, I wanted to check if it is possible. Because when I use EntityManager or EntityManagerFactory, my EntityManager is comming as null. Also instead if I use EntityManagerFactory, it gives an error saying:

javax.persistence.PersistenceException: No Persistence provider for EntityManager named EjbComponentPU

Below is my class

public class TestBean implements SessionBean {

//pass persistence unit to entityManager.
@PersistenceContext(unitName="EjbComponentPU")
 private EntityManager entitymanager;

My Project folder structure is:

src - has the all the packages. Inside that I have META-INF folder which has the persistence.xml file

Thanks for any help.

Tom11
  • 2,419
  • 8
  • 30
  • 56
anu8802
  • 11
  • 1
  • 5

1 Answers1

0

this is my persistence.xml file.

<?xml version="1.0" encoding="UTF-8"?>
<persistence version="1.0" 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">
   <persistence-unit name="EjbComponentPU" transaction-type="JTA">
      <provider>org.hibernate.ejb.HibernatePersistence</provider>
      <jta-data-source>java:/testDS</jta-data-source>
       <exclude-unlisted-classes>false</exclude-unlisted-classes>
   </persistence-unit>
anu8802
  • 11
  • 1
  • 5
  • This seems to be really short. Where are the dialect, db driver, security properties are set? – mikereem Sep 08 '16 at 06:09
  • Hi,I figured out the solution in my case, in case it may help someone. I had to put the persistence.xml file under Resources/META-INF directory and that worked as ant file put all resources in the classpath. – anu8802 Sep 08 '16 at 12:52
  • Hi mikereem,db properties are set in ms-ds.xml file – anu8802 Sep 08 '16 at 12:55