java - TomEE + OpenJPA: Error creating EntityManager using container managed DataSource -
I'm trying to configure an example JPA application in Eclipse, and put it on Tommy + on the Data Source Container Managed I am seeing the following error while trying to create EntityManager:
The persistency provider is trying to use the property in the persistence.xml file to resolve the data source. The name of the Java database connectivity (JDBC) driver or the data source class should be specified in openjpa.ConnectionDriverName or javax.preistence.jdbc.driver property. The following properties are available in the configuration: "org.apache.openjpa.jdbc.conf.JDBCConfigurationImpl@414793b4".
What's wrong with this configuration?
is the code below.
tomee.xml
& lt; Tomee & gt; & Lt; Resource ID = "jdbc / MyAppDS" type = "data source" & gt; JdbcDriver com.microsoft.sqlserver.jdbc.SQLServerDriver JdbcUrl jdbc: sqlserver: // localhost: 1433 / db_dev Username Password Password JtaManaged true DefaultAutoCommit false & lt; / Resources & gt; & Lt; / Tomee & gt;
Persistence Xml
& lt; Persistence xmlns = "http://java.sun.com/xml/ns/firmity" xmlns: xsi = "http://www.w3.org/2001/XMLSchema-instance" version = "2.0" & gt; & Lt; Firmness unit name = "simple" transaction-type = "jta" & gt; & Lt; Provider & gt; Org.apache.openjpa.persistence.PersistenceProviderImpl & lt; / Provider & gt; & Lt; JTA-Data-Source & gt; JDBC / MyAppDS & lt; / JTA-Data-Source & gt; & Lt; Classes & gt; Social.Media & lt; / Square & gt; & Lt; / Persistence unit & gt; & Lt; / Persistence>
Media. Java
Package Social; Import javax.preistence.Column; Import javax.preistence.Entity; Import javax.preistence.Id; Import javax.preistence.Table; @Entity @Table (name = "media") Public class media {@Id @Column (name = "id") Private string ID; Private string description; Private string title; Public string getId () {return ID; } Public Zero Set ID (string id) {this.id = id; } Public string getDescription () {return details; } Public Zero Setdition (string description) {this.description = description; } Public string getTitle () {return title; } Public Zero Sattitles (String title) {this.title = title; }}
Administrator. Java
Package Social; Import javax.inject.Inject; Import javax.preistence.EntityManager; Import javax.preistence.EntityManagerFactory; Import javax.preistence.Persistence; Import javax.ws.rs.GET; Import javax.ws.rs.Path; Import javax.ws.rs.produces; Import javax.ws.rs.core.MediaType; @ Path ("/ Hello") public class controller {@ Inject private media media; @GET @ Products (MediaType.txt_dublan) say public string ({{EntityManagerFactory emf = Persistence.createEntityManagerFactory ("Simple"); EntityManager em = emf.createEntityManager (); // Report exceptions on this line. . Return media.getDescription (); If you are using the JTA-managed unit manager factory, I think that instead of manually building EntityManagerFactory you should make the application server do it for you, such as in the administrator: @ Path ("/ hello") public class controller {@ Pereisence Contact (entity name = "simple") private entity manager; @GET @Produces (MediaType.TEXT_PLAIN) Public String is called hello () {// Get Media From Media - Replace With Your Own Code Media Media = em.find (Media.class, "1"); Return media.getDescription (); }}
Comments
Post a Comment