Sunday 15 February 2015

EJB Maven module using JPA -


I have the simple Maven EJB module jpa use. This is my persistance.xml file

  & Lt; Persistence xmlns = "http://java.sun.com/xml/ns/specifence" version = "2.0" & gt; & Lt; Strength-unit name = "persistence" & gt; & Lt; Provider & gt; Org.hibernate.ejb.HibernatePersistence & lt; / Provider & gt; & Lt; Mapping file & gt; GroupTypes.xml & lt; / Mapping file & gt; & Lt; Properties & gt; & Lt; Property Name = "hibernate.connection.url" value = "jdbc: oracle: thin: @ 127.0.0.1: 1521: E" /> & Lt; Property Name = "hibernate.connection.driver_class" value = "oracle.jdbc.driver.OracleDriver" /> & Lt; Property Name = "hibernate.connection.username" value = "username" /> & Lt; Property Name = "hibernate.connection.password" Value = "Password" /> & Lt; / Properties & gt; & Lt; / Persistence unit & gt; & Lt; / Persistence>   

I am using EJB Stateless Bean and I am trying to get all the features from the Group Types table. This is my Bean implementation:

  Public class testben {Private group type group type; Private EntityManagerFattery UnitManagerPacker; Private Entity Manager Unit Manager; @WebMethod (OperationName = "Bus Checking") Public Boolean Basalting (@WebParam (name = "param") string value) {try {entityManagerFactory = persistence.createEntityManagerFactory ("persistance"); EntityManager = entityManagerFactory.createEntityManager (); Query query = entityManager.createQuery ("choose name from group type"); & Lt; AmmEdGroupTypes & gt; Results = query.getResultList (); Back true; } Hold (exception e) {e.printStackTrace (); return false; }}}   

When I try to call this method, I get evicted: javax.preistence.PersistenceException: No persistency provider for persistance called EntityManager. My persistance.xml file is placed in folder resources / META-INF / persistance.xml, and this solution works if I am not using bean. Does anyone have any idea why this is happening when I am using Bean?

I am using Intelligence 12.1.1, Oracle 11G, Glassfish 3.1 Server and Java 1.6.

I have solved this problem in the following way: 1. Hibernate add-on installed on the glassfish ( Using the glassfish update tool) 2. Added JDB connection pool with properties: classname, username, password, database name and url 3. jdbc resource added on glassfish jdbc / _am connection pool _ Binding with AMPPil 4. Replace persistence.xml file 5. Replace Pam.xml file 6. Glass The following Library was copied to the Shish domain / Domain1 / Lib folder: -antlr-2.7.7 -commons-collections-3.2.1, -dom4j-1.6.1, -ejb3- Implant -1.0.2.GA, - Hornete 3-Maven-Plugin-3.0, -BeberTennet-Communion-Annotation-4.0.0.final, -HorntecCor-4.2.2.final, -Bernet-Nitineman-4.2.2.Final -Jawist-3.15 0-GA , -Jeta -1.1, -Log 49-1.2.17, -Carel -JDBC-11.1.0.6.0 -production +,
- Slf4j-api-1.6.1 -slf4j-log4j12-1.7.5

A: These libraries were copied to the Glassfish / Leib Flooder.

This is my new persistance.xml file: and this is my pom.xml file:

No comments:

Post a Comment