Search code examples
eclipsehibernatemavenjakarta-eeentitymanager

Why glassfish5 does not deploy my war correctly?


I'm using Eclipse Version: Oxygen.3 Release (4.7.3), Glassfish 5, java version 1.8.0_161, Hibernate 5.2.16 (as JPA implementation) and maven.

I'm coping with the following situation:

test1

  1. I right click on a project in eclipse -> update project -> select all -> ok
  2. from servers view: right click on glassfish -> debug
  3. from servers view: right click on glassfish -> add and remove -> add "clusterer" module (see below my maven structure)
  4. go to http://localhost:8080/clusterer/webapi/myresource, my ws works fine!

test2

  1. click right on parent project -> run as -> maven clean
  2. click right on parent project -> run as -> maven install
  3. copy war from parent project -> paste it in path_folder/clusterer.war
  4. stop domain of the previous test (let's say domain1)
  5. start a new domain (let's say domain2)
  6. asadmin --force deploy path_folder/clusterer.war
  7. go to http://localhost:8080/clusterer/webapi/myresource
  8. I get the following error: Unable to retrieve EntityManagerFactory for unitName DBClusterer

My maven project structure is as follows:

p1  (parent pom with modules)
|   |  |
|   |  Clusterer (war)
|   |
|   ClusterService (ejb)
|
DBClusterer (jar)

hibernate.cfg.xml and persistence.xml (which contains persistence unit "DBClusterer" cited before) are located in DBClusterer module. hibernate.cfg.xml is located in src/main/resources (which is marked as source directory in java build path). persistence.xml is located in src/main/java/META-INF (where src/main/java is marked as source directory in java build path).


Solution

  • I have just solved the problem. Maven wants persistence.xml to be put in main/java/resources/META-INF