You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 3 Next »

GraalVM is becoming an increasingly popular target to deploy Apache CXF services. The most challenging deployments are the ones which bundle Apache CXF services and applications as native images. There are some limitations with that and there are certain improvements incorporated into Apache CXF recently to provide the way to overcome those.

JAX-WS Support

In certain scenarios Apache CXF does aggressive code generation and dynamic class loading at runtime. This is violate one of the GraalVM's ahead-of-time compilation limitations which "... states that all classes and all bytecodes that are reachable at run time must be known at build time". Since 3.4.2 / 3.5.x there is a way to capture all dynamically generated classes, include them into the native image at build time and then use class loading (instead of class generation) at runtime. It eliminates the need for dynamic class generation and loading. The capability is provided by GeneratedClassClassLoaderCapture extension (shown below).

public interface GeneratedClassClassLoaderCapture {
    void capture(String className, byte[] bytes);
}

The stored generated classes should be injected at build time, whereas the following extensions replace dynamic class generation with class loading of the captured (generated) classes:

Here is the programmatic way to configure these extensions:

 final Bus bus = ...; /* Bus instance */
 bus.setExtension(new WrapperHelperClassLoader(bus), WrapperHelperCreator.class);
 bus.setExtension(new ExtensionClassLoader(bus), ExtensionClassCreator.class);
 bus.setExtension(new ExceptionClassLoader(bus), ExceptionClassCreator.class);
 bus.setExtension(new GeneratedWrapperClassLoader(bus), WrapperClassCreator.class);
 bus.setExtension(new FactoryClassLoader(bus), FactoryClassCreator.class);
 bus.setExtension(new GeneratedNamespaceClassLoader(bus), NamespaceClassCreator.class);
  • No labels