Skip to content

Conversation

@flx5
Copy link

@flx5 flx5 commented Jun 9, 2024

Hello,
recently I've experimented with GraalVM and native images.

However the Jaxb implementation resulted in an exception at runtime:

org.graalvm.nativeimage.MissingReflectionRegistrationError: The program tried to reflectively invoke method public org.glassfish.jaxb.runtime.v2.runtime.property.SingleElementNodeProperty(org.glassfish.jaxb.runtime.v2.runtime.JAXBContextImpl,org.glassfish.jaxb.runtime.v2.model.runtime.RuntimeElementPropertyInfo) without it being registered for runtime reflection. Add it to the reflection metadata to solve this problem. See https://www.graalvm.org/latest/reference-manual/native-image/metadata/#reflection for help.
at org.graalvm.nativeimage.builder/com.oracle.svm.core.reflect.MissingReflectionRegistrationUtils.forQueriedOnlyExecutable(MissingReflectionRegistrationUtils.java:97) ~[na:na]
at [email protected]/java.lang.reflect.Constructor.acquireConstructorAccessor(Constructor.java:74) ~[com.example.producingwebservice.ProducingWebServiceApplication:na]
at [email protected]/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:496) ~[com.example.producingwebservice.ProducingWebServiceApplication:na]
at [email protected]/java.lang.reflect.Constructor.newInstance(Constructor.java:480) ~[com.example.producingwebservice.ProducingWebServiceApplication:na]
at org.glassfish.jaxb.runtime.v2.runtime.property.PropertyFactory.create(PropertyFactory.java:94) ~[na:na]
at org.glassfish.jaxb.runtime.v2.runtime.ClassBeanInfoImpl.(ClassBeanInfoImpl.java:148) ~[na:na]
at org.glassfish.jaxb.runtime.v2.runtime.JAXBContextImpl.getOrCreate(JAXBContextImpl.java:464) ~[com.example.producingwebservice.ProducingWebServiceApplication:4.0.4 - 75b0b97]
at org.glassfish.jaxb.runtime.v2.runtime.JAXBContextImpl.(JAXBContextImpl.java:283) ~[com.example.producingwebservice.ProducingWebServiceApplication:4.0.4 - 75b0b97]
at org.glassfish.jaxb.runtime.v2.runtime.JAXBContextImpl$JAXBContextBuilder.build(JAXBContextImpl.java:1115) ~[na:na]
at org.glassfish.jaxb.runtime.v2.ContextFactory.createContext(ContextFactory.java:144) ~[com.example.producingwebservice.ProducingWebServiceApplication:4.0.4 - 75b0b97]
at org.glassfish.jaxb.runtime.v2.JAXBContextFactory.createContext(JAXBContextFactory.java:44) ~[com.example.producingwebservice.ProducingWebServiceApplication:4.0.4 - 75b0b97]
at jakarta.xml.bind.ContextFinder.find(ContextFinder.java:373) ~[na:na]
at jakarta.xml.bind.JAXBContext.newInstance(JAXBContext.java:605) ~[com.example.producingwebservice.ProducingWebServiceApplication:4.0.1]
at jakarta.xml.bind.JAXBContext.newInstance(JAXBContext.java:546) ~[com.example.producingwebservice.ProducingWebServiceApplication:4.0.1]
at org.springframework.ws.server.endpoint.adapter.method.jaxb.AbstractJaxb2PayloadMethodProcessor.getJaxbContext(AbstractJaxb2PayloadMethodProcessor.java:224) ~[com.example.producingwebservice.ProducingWebServiceApplication:na]

Three ideas to resolve this issue:

  1. Add reflection hints
  2. Replace reflection with functional programming (BiFunction instead of Constructor)
  3. Move property creation into RuntimePropertyInfo

In this PR I've implemented the third option. However I also have the second option available (See https://github.com/flx5/jaxb-ri/tree/feature/functional).

@flx5 flx5 force-pushed the feature/refactor-property-factory branch from 168bf0d to bca8832 Compare June 9, 2024 16:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant