1

I am using jaxb2-maven-plugin to generate Java classes from an XSD file. I have a bindings file with adapters for XML date elements that point to a fully qualified java class (e.g: com.example.project.DateAdapter).

When I run mvn clean install I see that the generated java classes in ./generated-sources/jaxb/ contain the correct import (full package name) for my adapters and the date fields are annotated with @XmlJavaTypeAdapter, but when the classes are actually compiled to ./target/classes/ the import of the adapter does not have the fully qualified name and it appears as import DateAdapter.java instead of import com.example.project.DateAdapter. I noticed this after decompiling the .class file.

The issue I'm having is that when my application tries to run it fails because the @XmlJavaTypeAdapter(DateAdapter.class) annotation cannot resolve the class, which makes sense because the import did not reference the fully qualifier name of the class.

I suspect that what is happening is that when Maven is compiling the generated java files classes it has no visibility on the .java files located under ./src/. Could this be the issue?

Not sure if this helps but I'm using VSCode and build-helper-maven-plugin to add the generated sources to the classpath.

Berigoner
  • 93
  • 1
  • 7
  • Do you have complete steps to reproduce? Please show it or report it to the official developers on [GitHub](https://github.com/redhat-developer/vscode-java/issues/new). – JialeDu Aug 28 '23 at 06:15

0 Answers0