Details
Assignee
UnassignedUnassignedReporter
Bartlomiej NiemiecBartlomiej NiemiecWorked in
Components
Affects versions
Priority
Major
Details
Details
Assignee
Unassigned
UnassignedReporter
Bartlomiej Niemiec
Bartlomiej NiemiecWorked in
Components
Affects versions
Priority
Created October 11, 2024 at 1:08 PM
Updated March 24, 2025 at 6:52 AM
I have following entities:
public class Income implements Serializable { private int id; private BigDecimal balance; //rest of the code @Entity @Table(schema = "public", name = "t_expense") public class Expense implements Serializable { @Id private int id; private BigDecimal balance; //rest of the code
With orm.xml:
<?xml version="1.0" encoding="UTF-8"?> <entity-mappings xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="https://jakarta.ee/xml/ns/persistence/orm" xsi:schemaLocation="https://jakarta.ee/xml/ns/persistence/orm https://jakarta.ee/xml/ns/persistence/persistence_3_0https://jakarta.ee/xml/ns/persistence/orm/orm_3_1.xsd" version="3.1"> <entity class="org.hibernate.bugs.Income"> <table schema="public" name="t_income"/> <attributes> <id name="id"/> <basic name="balance"/> </attributes> </entity> </entity-mappings>
There are two problems in version 7.X with static model generation:
If i configure modelgen dependency in
annotationProcessorPath
ofmaven-compiler-plugin
then orm.xml is not loaded by generator probably due to classloading issuesIf i configure modelgen as regular dependency(less preferred way) then i will hit this error:
jakarta.xml.bind.JAXBException: Implementation of Jakarta XML Binding-API has not been found on module path or classpath. - with linked exception: [java.lang.ClassNotFoundException: org.glassfish.jaxb.runtime.v2.ContextFactory]
If I add jaxb impl. dependency(as plugin dependency, adding as regular dependency doesn’t work):
<dependency> <groupId>org.glassfish.jaxb</groupId> <artifactId>jaxb-runtime</artifactId> <version>4.0.5</version> </dependency>
Then i get:
jakarta.xml.bind.JAXBException: Error while searching for service [jakarta.xml.bind.JAXBContextFactory] - with linked exception: [java.util.ServiceConfigurationError: jakarta.xml.bind.JAXBContextFactory: org.glassfish.jaxb.runtime.v2.JAXBContextFactory not a subtype]
I think in this case jaxb api and impl are picked from different classloaders(adding api dep. to plugin dosen’t fix that).
These problems also occurs when i configure modelgen with
maven-processor-plugin
instead ofmaven-compiler-plugin
Test case is in attachement (it’s testcase2.zip)