I'm encountering an issue with the hapi-fhir-jpa-starter with Hibernate entity management, and I'm hoping someone might be able to help.
Caused by: java.lang.IllegalArgumentException: Not a managed type: class wales.nhs.ctmuhb.hapiserver.entities.AuditEventRow
This error occurs during the init phase when Hibernate is setting up the JPA repositories.
Here's my AuditEventRow entity:
package wales.nhs.ctmuhb.hapiserver.entities;
import jakarta.persistence.Entity;
import
jakarta.persistence.Id;
import jakarta.persistence.Table;
import jakarta.persistence.Column;
import java.util.UUID;
@Entity
@Table(name = "AU_EVENTS")
public class AuditEventRow {
@Id
@Column(name = "request_id", nullable = false, unique = true)
private UUID requestId;
// Default constructor
public AuditEventRow() {}
// Getters and Setters
public UUID getRequestId() {
return requestId;
}
public void setRequestId(UUID requestId) {
this.requestId = requestId;
}
}
Repository Interface:
package wales.nhs.ctmuhb.hapiserver.repositories;
import org.springframework.data.jpa.repository.JpaRepository;
import wales.nhs.ctmuhb.hapiserver.entities.AuditEventRow;
import java.util.UUID;
public interface IAuditEventRowRepository extends JpaRepository<AuditEventRow, UUID> {
}
Application Configuration:
In my Application.java:
@ServletComponentScan(basePackageClasses = {RestfulServer.class, SmartServlet.class})
@SpringBootApplication(
scanBasePackages = {
"ca.uhn.fhir.jpa.starter",
"wales.nhs.ctmuhb.hapiserver"
},
exclude = {
ElasticsearchRestClientAutoConfiguration.class,
ThymeleafAutoConfiguration.class
}
)
@EntityScan(basePackages = "wales.nhs.ctmuhb.hapiserver.entities")
@EnableJpaRepositories("wales.nhs.ctmuhb.hapiserver.repositories")
@Import({
StarterCrR4Config.class,
StarterCrDstu3Config.class,
StarterCdsHooksConfig.class,
SubscriptionSubmitterConfig.class,
SubscriptionProcessorConfig.class,
SubscriptionChannelConfig.class,
WebsocketDispatcherConfig.class,
MdmConfig.class,
JpaBatch2Config.class,
Batch2JobsConfig.class
})
public class Application extends SpringBootServletInitializer {
Steps Taken to Debug:
Checked Package Scanning:
- Confirmed that @EntityScan and @EnableJpaRepositories point to the correct packages.
Cleaned and Rebuilt the Project:
- Ran mvn clean install to clean the build and rebuild all artifacts.
Verified Managed Entities:
Observations:
- It seems that AuditEventRow is not being picked up during the entity scanning phase, despite the configurations.
- The error persists even after ensuring that annotations and dependencies are compatible with Spring Boot 3.x.
Has anyone experienced a similar issue or have insights on how to resolve this?
Any suggestions on steps I might have missed or alternative approaches to debug this problem?
Thank you in advance for your help!
Best wishes,
Keiron O'Shea