-
Bug
-
Resolution: Done
-
Critical
-
5.2.0.Final
-
None
I have infinispan-cdi library in my appserver to be able to use JSR-107.
During startup of application server it loads the InfinispanExtension because the service provider is declared in META-INF/services.
During startup I get the exception
Caused by: java.util.ServiceConfigurationError: javax.enterprise.inject.spi.Extension: Provider org.infinispan.cdi.InfinispanExtension could not be instantiated: java.lang.IllegalAccessException: Class java.util.ServiceLoader$LazyIterator can not access a member of class org.infinispan.cdi.InfinispanExtension with modifiers "" at java.util.ServiceLoader.fail(ServiceLoader.java:207) at java.util.ServiceLoader.access$100(ServiceLoader.java:164) at java.util.ServiceLoader$LazyIterator.next(ServiceLoader.java:353) at java.util.ServiceLoader$1.next(ServiceLoader.java:421)
The reason is that the InfinispanExtension only provides a package scoped constructor.
For sure the documentation of java.util.ServiceLoader is not very clear here. It just says:
"The only requirement enforced by this facility is that provider classes must have a zero-argument constructor so that they can be instantiated during loading"
But the implementation fails if the constructor is not public. Hence, we need a public constructor for InfinispanExtension.