问题
I am having EAR project which contains 1 EJB 3.0 Project and 2 WAR Project. I have defined persistence.xml in my EJB project.
However when the application starts it starts persistence unit service 3 times. As per log on startup I can see
Starting Persistence Unit Service 'xyz-ear.ear/xyz-ejb-1_0_0-SNAPSHOT.jar#xyzUnit'
Starting Persistence Unit Service 'xyz-ear.ear/xyz-war-1_0_0-SNAPSHOT.war#xyzUnit'
Starting Persistence Unit Service 'xyz-ear.ear/xyz-service-war-1_0_0-SNAPSHOT.war#xyzUnit'
Beacuse of this my database schema validation is happening 3 times.
@Startup
@Singleton
@PostConstruct
is getting called 3 times.
Has anyone faced this issue before? Please let me know if you need any other info.
PS: I have declared the EJB as ejb and not as ejb-client in pom.xml of both war module.
Can that cause this issue ?
来源:https://stackoverflow.com/questions/36759110/persistence-unit-service-starting-multille-times