I have a basic database JPA setup with the following structure in project A:
└── src
├── main
│ ├── java
│ │ └── com
│ │ └── my
│ │ └── apps
│ │ └── org
│ │ └── helidonapp
│ │ ├── Application.java
│ │ ├── application
│ │ │ ├── Employee
│ │ │ │ ├── EmployeeController.java
│ │ │ │ └── EmployeeRepository.java
│ │ │ ├── MyDataSource.java
│ │ ├── domain
│ │ │ └── model
│ │ │ └── Employee.java
│ └── resources
│ ├── META-INF
│ │ ├── beans.xml
│ │ ├── microprofile-config-local.properties
│ │ ├── microprofile-config.properties
│ │ └── persistence.xml
│ └── log4j2.xml
Which, when I compile and run project A, it connects to the database and I can make REST calls to the API without any issues.
However, I want to shift the database configuration to an external maven library (let's call this project B).
Project B now has the following structure:
database-utils
├── pom.xml
└── src
├── main
├── java
│ └── com
│ └── my
│ └── apps
│ └── ic
│ ├── Entity
| │ ├── GenericController.java
| │ └── GenericRepository.java
| ├── domain
| │ └── model
| │ └── AbstractEntity.java
│ ├──
│ └── persistence
│ └── jpa
│ └── MyDataSource.java
└── resources
└── META-INF
├── persistence.xml
And my child project (Project A) now has this structure:
src
├── main
│ ├── java
│ │ └── com
│ │ └── my
│ │ └── apps
│ │ └── org
│ │ └── helidon
│ │ ├── Application.java
│ │ ├── application
│ │ │ └── Employee
│ │ │ ├── EmployeeController.java
│ │ │ └── EmployeeRepository.java
├── domain
│ └── model
│ └── Employee.java
│ └── resources
│ ├── META-INF
│ │ ├── beans.xml
│ │ ├── microprofile-config-local.properties
│ │ └── microprofile-config.properties
(Note: EmployeeController and EmployeeRepository both extend their Generic equivalents from project B)
However, when I compile and run newly configured Project A I get the following error:
Exception in thread "main" jakarta.persistence.PersistenceException: Exception [EclipseLink-28018] (Eclipse Persistence Services - 3.0.3.v202208191135): org.eclipse.persistence.exceptions.EntityManagerSetupException
Exception Description: Predeployment of PersistenceUnit [myPu] failed.
Internal Exception: org.jboss.weld.exceptions.UnsatisfiedResolutionException: WELD-001334: Unsatisfied dependencies for type DataSource with qualifiers @Default @Named
at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.createPredeployFailedPersistenceException(EntityManagerSetupImpl.java:2153)
at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.predeploy(EntityManagerSetupImpl.java:2129)
at org.eclipse.persistence.jpa.PersistenceProvider.createContainerEntityManagerFactoryImpl(PersistenceProvider.java:350)
I am unsure why the above error is happening, I looked up possible causes but could not find anything regarding having a db setup on an external library.
My theory is the persistence.xml cannot find the DataSource class, but I checked to see that my project B's module .jar file is included under target/libs in project A. I also looked inside the .jar file and did see the DataSource, persistence.xml, and other controller/repository class files are available. I double checked that the @Named annotation value in my datasource class matches the tag in persistence.xml