[Bug]: XmlIO Exception in thread "main" java.lang.NoClassDefFoundError: javax/xml/bind/ValidationEventHandler
- Dominant language
- Java
- Stars
- 8.7k
- Forks
- 4.7k
- Avg merge
- 1d 20h
- Merged PRs (30d)
- 196
Description
### What happened?
I'm trying to use the XmlIO SDK to parse XML and receiving the following error
Exception in thread "main" java.lang.NoClassDefFoundError: javax/xml/bind/ValidationEventHandler
I'm using Java 17 as it says I can use Java 17 here on the quickstart page
https://beam.apache.org/get-started/quickstart-java/
> Download and install the [Java Development Kit (JDK)](https://www.oracle.com/technetwork/java/javase/downloads/index.html) version 8, 11, or 17. Verify that the [JAVA_HOME](https://docs.oracle.com/javase/8/docs/technotes/guides/troubleshoot/envvars001.html) environment variable is set and points to your JDK installation.
I've added the Jakarta dependencies in order to use jaxb
```
jakarta.xml.bind
jakarta.xml.bind-api
4.0.0
com.sun.xml.bind
jaxb-impl
4.0.0
runtime
```
I believe the error is because the XmlIO SDK has not been updated to include the Jakarta dependancies since they have been removed from the JDK
Here is an example of my pipeline
```
public class OrdersToBigQuery {
public interface OrdersToBigQueryOptions extends PipelineOptions {
@Description("File input path")
@Default.String("order.xml")
String getInputPath();
void setInputPath(String value);
}
public static void main(String[] args) {
PipelineOptionsFactory.register(OrdersToBigQueryOptions.class);
OrdersToBigQueryOptions options =
PipelineOptionsFactory.fromArgs(args).as(OrdersToBigQueryOptions.class);
Pipeline p = Pipeline.create(options);
p.apply("Read XML", XmlIO.read()
.from(options.getInputPath())
.withRootElement("orders")
.withRecordElement("order")
.withRecordClass(ComplexTypeOrder.class)
);
}
}
```
### Issue Priority
Priority: 2
### Issue Component
Component: io-java-xml
### Issue Priority
Priority: 2
### Issue Component
Component: io-java-xml
Contributor guide
Assessment
This issue has not been assessed yet.