Advertisement
Guest User

Untitled

a guest
Apr 24th, 2017
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.17 KB | None | 0 0
  1. @Entity
  2. public class ConfigEntity {
  3.  
  4. @Id
  5. private Long id;
  6. @Version
  7. private Long version;
  8.  
  9. [further fields, getters and setters omitted]
  10.  
  11. }
  12.  
  13. public class ConfigBEDao {
  14.  
  15. @PersistenceContext(unitName = "configurationPU")
  16. EntityManager entityManager;
  17.  
  18. public boolean isEntityManagerNull() {
  19. return entityManager == null;
  20. }
  21.  
  22. }
  23.  
  24. <?xml version="1.0" encoding="UTF-8"?>
  25. <persistence xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  26. xmlns="http://xmlns.jcp.org/xml/ns/persistence"
  27. xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd"
  28. version="2.1">
  29.  
  30. <persistence-unit name="configurationPU" transaction-type="RESOURCE_LOCAL">
  31. <description/>
  32. <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
  33. <jta-data-source>jdbc/db</jta-data-source>
  34. <properties>
  35. <property name="eclipselink.target-database" value="${database.dialect}"/>
  36. <property name="eclipselink.logging.level" value="FINE"/>
  37. <property name="eclipselink.logging.parameters" value="true"/>
  38. <property name="eclipselink.cache.shared.default" value="false"/>
  39. </properties>
  40. </persistence-unit>
  41. </persistence>
  42.  
  43. ConfigBEDao dao = new ConfigBEDao();
  44. dao.isEntityManagerNull();
  45.  
  46. java.lang.RuntimeException: Could not resolve a persistence unit corresponding to the persistence-context-ref-name [ConfigBEDao/entityManager] in the scope of the module called [main_ear-1.0-SNAPSHOT#main_ejb-1.0-SNAPSHOT.jar]. Please verify your application.
  47. at com.sun.enterprise.deployment.BundleDescriptor.findReferencedPUViaEMRef(BundleDescriptor.java:733)
  48. at org.glassfish.ejb.deployment.descriptor.EjbBundleDescriptorImpl.findReferencedPUs(EjbBundleDescriptorImpl.java:889)
  49. at org.glassfish.persistence.jpa.JPADeployer.createEMFs(JPADeployer.java:186)
  50. at org.glassfish.persistence.jpa.JPADeployer.prepare(JPADeployer.java:168)
  51.  
  52. <?xml version="1.0" encoding="UTF-8"?>
  53. <persistence xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  54. xmlns="http://xmlns.jcp.org/xml/ns/persistence"
  55. xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd"
  56. version="2.1">
  57.  
  58. <persistence-unit name="configurationPU" transaction-type="RESOURCE_LOCAL">
  59. <description/>
  60. <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
  61. <properties>
  62. <property name="javax.persistence.jdbc.url" value="jdbc:postgresql://localhost:5432/db"/>
  63. <property name="javax.persistence.jdbc.user" value="db"/>
  64. <property name="javax.persistence.jdbc.password" value="secret"/>
  65. <property name="javax.persistence.jdbc.driver" value="org.postgresql.Driver"/>
  66. </properties>
  67. </persistence-unit>
  68. </persistence>
  69.  
  70. javax.persistence.PersistenceException: No Persistence provider for EntityManager named configurationPU
  71. at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:85)
  72. at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:54)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement