eclipse-ee4j / jaxb-ri

Jaxb RI
https://eclipse-ee4j.github.io/jaxb-ri/
BSD 3-Clause "New" or "Revised" License
202 stars 110 forks source link

Cause exception is lost for IllegalAnnotationsException #1803

Open PavelTurk opened 2 months ago

PavelTurk commented 2 months ago

This is what I have in log file:

org.glassfish.jaxb.runtime.v2.runtime.IllegalAnnotationsException: 1 counts of IllegalAnnotationExceptions
    at org.glassfish.jaxb.runtime@4.0.2/org.glassfish.jaxb.runtime.v2.runtime.IllegalAnnotationsException$Builder.check(IllegalAnnotationsException.java:83) ~[jaxb-runtime-4.0.2.jar:?]
    at org.glassfish.jaxb.runtime@4.0.2/org.glassfish.jaxb.runtime.v2.runtime.JAXBContextImpl.getTypeInfoSet(JAXBContextImpl.java:421) ~[jaxb-runtime-4.0.2.jar:?]
    at org.glassfish.jaxb.runtime@4.0.2/org.glassfish.jaxb.runtime.v2.runtime.JAXBContextImpl.<init>(JAXBContextImpl.java:255) ~[jaxb-runtime-4.0.2.jar:?]
    at org.glassfish.jaxb.runtime@4.0.2/org.glassfish.jaxb.runtime.v2.runtime.JAXBContextImpl$JAXBContextBuilder.build(JAXBContextImpl.java:1115) ~[jaxb-runtime-4.0.2.jar:?]
    at org.glassfish.jaxb.runtime@4.0.2/org.glassfish.jaxb.runtime.v2.ContextFactory.createContext(ContextFactory.java:144) ~[jaxb-runtime-4.0.2.jar:?]
    at org.glassfish.jaxb.runtime@4.0.2/org.glassfish.jaxb.runtime.v2.JAXBContextFactory.createContext(JAXBContextFactory.java:44) ~[jaxb-runtime-4.0.2.jar:?]
    at jakarta.xml.bind@4.0.0/jakarta.xml.bind.ContextFinder.find(ContextFinder.java:368) ~[jakarta.xml.bind-api-4.0.0.jar:?]
    at jakarta.xml.bind@4.0.0/jakarta.xml.bind.JAXBContext.newInstance(JAXBContext.java:605) ~[jakarta.xml.bind-api-4.0.0.jar:?]
    at jakarta.xml.bind@4.0.0/jakarta.xml.bind.JAXBContext.newInstance(JAXBContext.java:546) ~[jakarta.xml.bind-api-4.0.0.jar:?]

However, it gives me nothing. So, I have to add breakpoint to line 81 of IllegalAnnotationsException and check list field, to understand what is going on: Screenshot from 2024-06-14 12-02-48

PavelTurk commented 2 months ago

I find out how to get causes in log with slf4j but it was very unexpected. I think this behaviour should be changed:

       try {
            JAXBContext context = JAXBContext.newInstance(settingsClass);
            Unmarshaller unmarshaller = context.createUnmarshaller();
            ....
        } catch (JAXBException e) {
            logger.error("Error reading settings from {}: {}", path, e.toString(), e); //NOTE e.toString()
        }