Hello!
I’m trying to build a Spring Boot 3.4.4 application using CXF 4.1.1 with JAX-WS
endpoints on GraalVM 24 (native-image) under Windows 11.
The native executable is successfully created, but execution fails when the
first JAX-WS endpoint is initialized, throwing the following exception:
Caused by: java.lang.NullPointerException
at
org.apache.cxf.common.util.PackageUtils.getPackageName(PackageUtils.java:47)
at org.apache.cxf.common.jaxb.JAXBUtils.scanPackages(JAXBUtils.java:865)
...
The SpringBus is extended as follows:
bus.setExtension(new WrapperHelperClassLoader(bus),
WrapperHelperCreator.class);
bus.setExtension(new ExtensionClassLoader(bus),
ExtensionClassCreator.class);
bus.setExtension(new ExceptionClassLoader(bus),
ExceptionClassCreator.class);
bus.setExtension(new WrapperClassLoader(bus), WrapperClassCreator.class);
bus.setExtension(new FactoryClassLoader(bus), FactoryClassCreator.class);
bus.setExtension(new GeneratedNamespaceClassLoader(bus),
NamespaceClassCreator.class);
The endpoint is created like this:
EndpointImpl endpoint = new EndpointImpl(bus, usermanagement);
endpoint.publish("/usermanagement");
And the usermanagement class is annotated as:
@WebService(
endpointInterface = "de.x.y.IUsermanagement",
targetNamespace = "http://www.xyz.de/usermanagement"
)
wouldn’t expect a NullPointerException at JAXBUtils.scanPackages() or
ReflectionServiceFactoryBean, and the same application runs fine on the JVM.
I looked at the official CXF example jaxws_graalvm hoping for guidance. I
managed to build it with GraalVM 24 by extending the native-image.properties,
but execution fails with this:
Exception in thread "main" org.apache.cxf.bus.extension.ExtensionException:
Could not load extension class
org.apache.cxf.jaxws.spi.WrapperClassNamingConvention$DefaultWrapperClassNamingConvention.
at
org.apache.cxf.bus.extension.Extension.tryClass(Extension.java:184)
at
org.apache.cxf.bus.extension.Extension.getClassObject(Extension.java:200)
at
org.apache.cxf.bus.extension.ExtensionManagerImpl.activateAllByType(ExtensionManagerImpl.java:139)
at
org.apache.cxf.bus.extension.ExtensionManagerBus.<init>(ExtensionManagerBus.java:145)
at
org.apache.cxf.bus.extension.ExtensionManagerBus.<init>(ExtensionManagerBus.java:157)
at demo.jaxws.server.Server.<init>(Server.java:33)
at demo.jaxws.server.Server.main(Server.java:43)
at
[email protected]/java.lang.invoke.LambdaForm$DMH/sa346b79c.invokeStaticInit(LambdaForm$DMH)
Caused by: java.lang.ClassNotFoundException:
org.apache.cxf.jaxws.spi.WrapperClassNamingConvention$DefaultWrapperClassNamingConvention
at
[email protected]/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:59)
at
[email protected]/java.lang.ClassLoader.loadClass(ClassLoader.java:115)
at
org.apache.cxf.bus.extension.Extension.tryClass(Extension.java:167)
... 7 more
I’ll likely submit this issue as a bug report against the example.
But my main question is:
Do you have any suggestions on how to solve or debug the NullPointerException
in scanPackages() when building JAX-WS endpoints with CXF on GraalVM native
image?
Thanks in advance – the application behaves perfectly fine on the JVM.
Greetings from Munich,
Torsten