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
- I right click on a project in eclipse -> update project -> select all -> ok
- from servers view: right click on glassfish -> debug
- from servers view: right click on glassfish -> add and remove -> add "clusterer" module (see below my maven structure)
- go to http://localhost:8080/clusterer/webapi/myresource, my ws works fine!
test2
- click right on parent project -> run as -> maven clean
- click right on parent project -> run as -> maven install
- copy war from parent project -> paste it in path_folder/clusterer.war
- stop domain of the previous test (let's say domain1)
- start a new domain (let's say domain2)
- asadmin --force deploy path_folder/clusterer.war
- go to http://localhost:8080/clusterer/webapi/myresource
- 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).