This is an automated email from the ASF dual-hosted git repository. pcristof pushed a commit to branch OPENJPA-2940 in repository https://gitbox.apache.org/repos/asf/openjpa.git
commit 38e0b0c186b0b0c46046a174de089788cda1375b Author: Paulo Cristovão de Araújo Silva Filho <pcris...@gmail.com> AuthorDate: Thu Jul 3 13:39:36 2025 -0300 [OPENJPA-2940] [WIP] Replacing javax.xml.bind dependecy for jakarta one * Tested and passed XML support using postgresql-17 as target db --- openjpa-jdbc/pom.xml | 4 +- .../openjpa/jdbc/meta/strats/XMLValueHandler.java | 8 +-- openjpa-jest/pom.xml | 1 + openjpa-persistence-jdbc/pom.xml | 4 +- .../jdbc/AnnotationPersistenceMappingParser.java | 74 +++++++++++----------- .../persistence/jdbc/mapping/Authority.java | 4 +- .../xmlmapping/xmlbindings/myaddress/Address.java | 10 +-- .../xmlbindings/myaddress/CANAddress.java | 10 +-- .../xmlbindings/myaddress/GBRAddress.java | 10 +-- .../xmlbindings/myaddress/ObjectFactory.java | 6 +- .../xmlbindings/myaddress/ShortAddress.java | 8 +-- .../xmlbindings/myaddress/USAAddress.java | 10 +-- .../AnnotationPersistenceXMLMetaDataParser.java | 18 ++---- openjpa/pom.xml | 4 +- pom.xml | 8 +-- 15 files changed, 86 insertions(+), 93 deletions(-) diff --git a/openjpa-jdbc/pom.xml b/openjpa-jdbc/pom.xml index 4c05efeaf..5460665cd 100644 --- a/openjpa-jdbc/pom.xml +++ b/openjpa-jdbc/pom.xml @@ -42,8 +42,8 @@ <version>${project.version}</version> </dependency> <dependency> - <groupId>javax.xml.bind</groupId> - <artifactId>jaxb-api</artifactId> + <groupId>jakarta.xml.bind</groupId> + <artifactId>jakarta.xml.bind-api</artifactId> <scope>compile</scope> <optional>true</optional> </dependency> diff --git a/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/XMLValueHandler.java b/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/XMLValueHandler.java index 6a75a1c52..49f0115e7 100644 --- a/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/XMLValueHandler.java +++ b/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/XMLValueHandler.java @@ -22,10 +22,10 @@ import java.io.StringReader; import java.io.StringWriter; import java.io.Writer; -import javax.xml.bind.JAXBContext; -import javax.xml.bind.JAXBException; -import javax.xml.bind.Marshaller; -import javax.xml.bind.Unmarshaller; +import jakarta.xml.bind.JAXBContext; +import jakarta.xml.bind.JAXBException; +import jakarta.xml.bind.Marshaller; +import jakarta.xml.bind.Unmarshaller; import javax.xml.transform.stream.StreamSource; import org.apache.openjpa.jdbc.identifier.DBIdentifier; diff --git a/openjpa-jest/pom.xml b/openjpa-jest/pom.xml index 884ab83c3..753def1c9 100644 --- a/openjpa-jest/pom.xml +++ b/openjpa-jest/pom.xml @@ -84,6 +84,7 @@ <executions> <execution> <phase>process-test-classes</phase> + <?m2e ignore?> <configuration> <target> <ant antfile="src/main/ant/enhancer.xml" target="enhance" inheritRefs="true"> diff --git a/openjpa-persistence-jdbc/pom.xml b/openjpa-persistence-jdbc/pom.xml index d47613f1f..a2da20acd 100644 --- a/openjpa-persistence-jdbc/pom.xml +++ b/openjpa-persistence-jdbc/pom.xml @@ -90,8 +90,8 @@ </dependency> <!-- Required for org.apache.openjpa.persistence.xmlmapping tests --> <dependency> - <groupId>javax.xml.bind</groupId> - <artifactId>jaxb-api</artifactId> + <groupId>jakarta.xml.bind</groupId> + <artifactId>jakarta.xml.bind-api</artifactId> <scope>test</scope> </dependency> <dependency> diff --git a/openjpa-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/AnnotationPersistenceMappingParser.java b/openjpa-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/AnnotationPersistenceMappingParser.java index 950741c9c..c43002947 100644 --- a/openjpa-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/AnnotationPersistenceMappingParser.java +++ b/openjpa-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/AnnotationPersistenceMappingParser.java @@ -107,39 +107,6 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -import jakarta.persistence.AssociationOverride; -import jakarta.persistence.AssociationOverrides; -import jakarta.persistence.AttributeOverride; -import jakarta.persistence.AttributeOverrides; -import jakarta.persistence.CollectionTable; -import jakarta.persistence.ColumnResult; -import jakarta.persistence.ConstructorResult; -import jakarta.persistence.DiscriminatorColumn; -import jakarta.persistence.DiscriminatorValue; -import jakarta.persistence.EntityResult; -import jakarta.persistence.EnumType; -import jakarta.persistence.Enumerated; -import jakarta.persistence.FieldResult; -import jakarta.persistence.Inheritance; -import jakarta.persistence.JoinColumn; -import jakarta.persistence.JoinColumns; -import jakarta.persistence.JoinTable; -import jakarta.persistence.MapKeyColumn; -import jakarta.persistence.MapKeyEnumerated; -import jakarta.persistence.MapKeyJoinColumn; -import jakarta.persistence.MapKeyJoinColumns; -import jakarta.persistence.MapKeyTemporal; -import jakarta.persistence.PrimaryKeyJoinColumn; -import jakarta.persistence.PrimaryKeyJoinColumns; -import jakarta.persistence.SecondaryTable; -import jakarta.persistence.SecondaryTables; -import jakarta.persistence.SqlResultSetMapping; -import jakarta.persistence.SqlResultSetMappings; -import jakarta.persistence.Table; -import jakarta.persistence.TableGenerator; -import jakarta.persistence.Temporal; -import jakarta.persistence.UniqueConstraint; - import org.apache.openjpa.jdbc.conf.JDBCConfiguration; import org.apache.openjpa.jdbc.identifier.DBIdentifier; import org.apache.openjpa.jdbc.identifier.DBIdentifier.DBIdentifierType; @@ -179,6 +146,39 @@ import org.apache.openjpa.util.MetaDataException; import org.apache.openjpa.util.UnsupportedException; import org.apache.openjpa.util.UserException; +import jakarta.persistence.AssociationOverride; +import jakarta.persistence.AssociationOverrides; +import jakarta.persistence.AttributeOverride; +import jakarta.persistence.AttributeOverrides; +import jakarta.persistence.CollectionTable; +import jakarta.persistence.ColumnResult; +import jakarta.persistence.ConstructorResult; +import jakarta.persistence.DiscriminatorColumn; +import jakarta.persistence.DiscriminatorValue; +import jakarta.persistence.EntityResult; +import jakarta.persistence.EnumType; +import jakarta.persistence.Enumerated; +import jakarta.persistence.FieldResult; +import jakarta.persistence.Inheritance; +import jakarta.persistence.JoinColumn; +import jakarta.persistence.JoinColumns; +import jakarta.persistence.JoinTable; +import jakarta.persistence.MapKeyColumn; +import jakarta.persistence.MapKeyEnumerated; +import jakarta.persistence.MapKeyJoinColumn; +import jakarta.persistence.MapKeyJoinColumns; +import jakarta.persistence.MapKeyTemporal; +import jakarta.persistence.PrimaryKeyJoinColumn; +import jakarta.persistence.PrimaryKeyJoinColumns; +import jakarta.persistence.SecondaryTable; +import jakarta.persistence.SecondaryTables; +import jakarta.persistence.SqlResultSetMapping; +import jakarta.persistence.SqlResultSetMappings; +import jakarta.persistence.Table; +import jakarta.persistence.TableGenerator; +import jakarta.persistence.Temporal; +import jakarta.persistence.UniqueConstraint; + /** * Persistence annotation mapping parser. * @@ -1346,8 +1346,7 @@ public class AnnotationPersistenceMappingParser (((Nonpolymorphic) anno).value())); break; case ORDER_COLUMN: - parseJavaxOrderColumn(fm, - (jakarta.persistence.OrderColumn)anno); + parseJakartaOrderColumn(fm, (jakarta.persistence.OrderColumn)anno); break; case ORDER_COL: parseOrderColumn(fm, (OrderColumn) anno); @@ -1681,7 +1680,7 @@ public class AnnotationPersistenceMappingParser // have a hard-wired dependency on JAXB here Class<?> xmlRootElementClass = null; try { - xmlRootElementClass = Class.forName("javax.xml.bind.annotation.XmlRootElement"); + xmlRootElementClass = Class.forName("jakarta.xml.bind.annotation.XmlRootElement"); } catch (Exception e) { } @@ -2093,8 +2092,7 @@ public class AnnotationPersistenceMappingParser /** * Parse @jakarta.persistence.OrderColumn */ - private void parseJavaxOrderColumn(FieldMapping fm, - jakarta.persistence.OrderColumn order) { + private void parseJakartaOrderColumn(FieldMapping fm, jakarta.persistence.OrderColumn order) { Column col = new Column(); if (!StringUtil.isEmpty(order.name())) diff --git a/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/mapping/Authority.java b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/mapping/Authority.java index df21ad084..f40ec8d45 100644 --- a/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/mapping/Authority.java +++ b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/mapping/Authority.java @@ -28,8 +28,8 @@ import jakarta.persistence.Id; import jakarta.persistence.NamedQueries; import jakarta.persistence.NamedQuery; import jakarta.persistence.Table; -import javax.xml.bind.annotation.XmlEnum; -import javax.xml.bind.annotation.XmlType; +import jakarta.xml.bind.annotation.XmlEnum; +import jakarta.xml.bind.annotation.XmlType; import org.apache.openjpa.persistence.Persistent; import org.apache.openjpa.persistence.jdbc.Strategy; diff --git a/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/xmlmapping/xmlbindings/myaddress/Address.java b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/xmlmapping/xmlbindings/myaddress/Address.java index 58b0ed620..46d2162c3 100644 --- a/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/xmlmapping/xmlbindings/myaddress/Address.java +++ b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/xmlmapping/xmlbindings/myaddress/Address.java @@ -13,11 +13,11 @@ package org.apache.openjpa.persistence.xmlmapping.xmlbindings.myaddress; import java.util.ArrayList; import java.util.List; -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlRootElement; -import javax.xml.bind.annotation.XmlType; +import jakarta.xml.bind.annotation.XmlAccessType; +import jakarta.xml.bind.annotation.XmlAccessorType; +import jakarta.xml.bind.annotation.XmlElement; +import jakarta.xml.bind.annotation.XmlRootElement; +import jakarta.xml.bind.annotation.XmlType; /** * <p>Java class for Address complex type. diff --git a/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/xmlmapping/xmlbindings/myaddress/CANAddress.java b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/xmlmapping/xmlbindings/myaddress/CANAddress.java index 2b6060fe5..10d9e1da7 100644 --- a/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/xmlmapping/xmlbindings/myaddress/CANAddress.java +++ b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/xmlmapping/xmlbindings/myaddress/CANAddress.java @@ -10,11 +10,11 @@ package org.apache.openjpa.persistence.xmlmapping.xmlbindings.myaddress; -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlRootElement; -import javax.xml.bind.annotation.XmlType; +import jakarta.xml.bind.annotation.XmlAccessType; +import jakarta.xml.bind.annotation.XmlAccessorType; +import jakarta.xml.bind.annotation.XmlElement; +import jakarta.xml.bind.annotation.XmlRootElement; +import jakarta.xml.bind.annotation.XmlType; /** diff --git a/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/xmlmapping/xmlbindings/myaddress/GBRAddress.java b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/xmlmapping/xmlbindings/myaddress/GBRAddress.java index 99cbc3567..fe1e54457 100644 --- a/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/xmlmapping/xmlbindings/myaddress/GBRAddress.java +++ b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/xmlmapping/xmlbindings/myaddress/GBRAddress.java @@ -10,11 +10,11 @@ package org.apache.openjpa.persistence.xmlmapping.xmlbindings.myaddress; -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlRootElement; -import javax.xml.bind.annotation.XmlType; +import jakarta.xml.bind.annotation.XmlAccessType; +import jakarta.xml.bind.annotation.XmlAccessorType; +import jakarta.xml.bind.annotation.XmlElement; +import jakarta.xml.bind.annotation.XmlRootElement; +import jakarta.xml.bind.annotation.XmlType; /** diff --git a/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/xmlmapping/xmlbindings/myaddress/ObjectFactory.java b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/xmlmapping/xmlbindings/myaddress/ObjectFactory.java index b22aec8c9..64bb0beb1 100644 --- a/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/xmlmapping/xmlbindings/myaddress/ObjectFactory.java +++ b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/xmlmapping/xmlbindings/myaddress/ObjectFactory.java @@ -10,9 +10,9 @@ package org.apache.openjpa.persistence.xmlmapping.xmlbindings.myaddress; -import javax.xml.bind.JAXBElement; -import javax.xml.bind.annotation.XmlElementDecl; -import javax.xml.bind.annotation.XmlRegistry; +import jakarta.xml.bind.JAXBElement; +import jakarta.xml.bind.annotation.XmlElementDecl; +import jakarta.xml.bind.annotation.XmlRegistry; import javax.xml.namespace.QName; diff --git a/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/xmlmapping/xmlbindings/myaddress/ShortAddress.java b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/xmlmapping/xmlbindings/myaddress/ShortAddress.java index e2f547356..622730693 100644 --- a/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/xmlmapping/xmlbindings/myaddress/ShortAddress.java +++ b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/xmlmapping/xmlbindings/myaddress/ShortAddress.java @@ -10,10 +10,10 @@ package org.apache.openjpa.persistence.xmlmapping.xmlbindings.myaddress; -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; -import javax.xml.bind.annotation.XmlRootElement; -import javax.xml.bind.annotation.XmlType; +import jakarta.xml.bind.annotation.XmlAccessType; +import jakarta.xml.bind.annotation.XmlAccessorType; +import jakarta.xml.bind.annotation.XmlRootElement; +import jakarta.xml.bind.annotation.XmlType; /** diff --git a/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/xmlmapping/xmlbindings/myaddress/USAAddress.java b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/xmlmapping/xmlbindings/myaddress/USAAddress.java index 51266e7ce..f4e3389f8 100644 --- a/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/xmlmapping/xmlbindings/myaddress/USAAddress.java +++ b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/xmlmapping/xmlbindings/myaddress/USAAddress.java @@ -10,11 +10,11 @@ package org.apache.openjpa.persistence.xmlmapping.xmlbindings.myaddress; -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlRootElement; -import javax.xml.bind.annotation.XmlType; +import jakarta.xml.bind.annotation.XmlAccessType; +import jakarta.xml.bind.annotation.XmlAccessorType; +import jakarta.xml.bind.annotation.XmlElement; +import jakarta.xml.bind.annotation.XmlRootElement; +import jakarta.xml.bind.annotation.XmlType; /** diff --git a/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/AnnotationPersistenceXMLMetaDataParser.java b/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/AnnotationPersistenceXMLMetaDataParser.java index e52b903bb..0f09d18ac 100644 --- a/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/AnnotationPersistenceXMLMetaDataParser.java +++ b/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/AnnotationPersistenceXMLMetaDataParser.java @@ -72,24 +72,18 @@ public class AnnotationPersistenceXMLMetaDataParser { _conf = conf; _log = conf.getLog(OpenJPAConfiguration.LOG_METADATA); try { - xmlTypeClass = Class.forName( - "javax.xml.bind.annotation.XmlType"); + xmlTypeClass = Class.forName("jakarta.xml.bind.annotation.XmlType"); xmlTypeName = xmlTypeClass.getMethod("name", null); xmlTypeNamespace = xmlTypeClass.getMethod("namespace", null); - xmlRootElementClass = Class.forName( - "javax.xml.bind.annotation.XmlRootElement"); + xmlRootElementClass = Class.forName("jakarta.xml.bind.annotation.XmlRootElement"); xmlRootName = xmlRootElementClass.getMethod("name", null); xmlRootNamespace = xmlRootElementClass.getMethod("namespace", null); - xmlAccessorTypeClass = Class.forName( - "javax.xml.bind.annotation.XmlAccessorType"); + xmlAccessorTypeClass = Class.forName("jakarta.xml.bind.annotation.XmlAccessorType"); xmlAccessorValue = xmlAccessorTypeClass.getMethod("value", null); - xmlAttributeClass = Class.forName( - "javax.xml.bind.annotation.XmlAttribute"); + xmlAttributeClass = Class.forName("jakarta.xml.bind.annotation.XmlAttribute"); xmlAttributeName = xmlAttributeClass.getMethod("name", null); - xmlAttributeNamespace = xmlAttributeClass.getMethod("namespace" - , null); - xmlElementClass = Class.forName( - "javax.xml.bind.annotation.XmlElement"); + xmlAttributeNamespace = xmlAttributeClass.getMethod("namespace", null); + xmlElementClass = Class.forName("jakarta.xml.bind.annotation.XmlElement"); xmlElementName = xmlElementClass.getMethod("name", null); xmlElementNamespace = xmlElementClass.getMethod("namespace", null); } catch (Exception e) { diff --git a/openjpa/pom.xml b/openjpa/pom.xml index 680cb2dfe..1550679e3 100644 --- a/openjpa/pom.xml +++ b/openjpa/pom.xml @@ -184,8 +184,8 @@ </dependency> <!-- Need to manually add back optional openjpa-jdbc depends --> <dependency> - <groupId>javax.xml.bind</groupId> - <artifactId>jaxb-api</artifactId> + <groupId>jakarta.xml.bind</groupId> + <artifactId>jakarta.xml.bind-api</artifactId> <scope>compile</scope> <optional>true</optional> <exclusions> diff --git a/pom.xml b/pom.xml index b2a5ff422..6f4768428 100644 --- a/pom.xml +++ b/pom.xml @@ -1826,14 +1826,14 @@ <version>${dbcp2.version}</version> </dependency> <dependency> - <groupId>javax.xml.bind</groupId> - <artifactId>jaxb-api</artifactId> - <version>2.2.1</version> + <groupId>jakarta.xml.bind</groupId> + <artifactId>jakarta.xml.bind-api</artifactId> + <version>4.0.2</version> </dependency> <dependency> <groupId>com.sun.xml.bind</groupId> <artifactId>jaxb-impl</artifactId> - <version>2.2.1</version> + <version>4.0.5</version> </dependency> <dependency> <groupId>org.hsqldb</groupId>