Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ServiceConfigurationError with "not a subtype" for external library in dev mode #12136

Closed
havwig opened this issue Sep 16, 2020 · 2 comments · Fixed by #12156
Closed

ServiceConfigurationError with "not a subtype" for external library in dev mode #12136

havwig opened this issue Sep 16, 2020 · 2 comments · Fixed by #12156
Labels
area/devmode kind/bug Something isn't working
Milestone

Comments

@havwig
Copy link

havwig commented Sep 16, 2020

Describe the bug
I get several ServiceConfigurationError exceptions with "not a subtype" message when initializing the GeoTools library suite, but only in dev mode. I've verified that the classes in the error messages are both included in the project, but also that they are in different jars (e.g. interface "CRSFactory" in gt-opengis, and "ReferencingObjectFactory" that implements CRSFactory in gt-referencing).

Expected behavior
No errors even in dev mode.

Actual behavior
Several error messages like this when GeoTools is first used:
"java.util.ServiceConfigurationError: org.opengis.referencing.crs.CRSFactory: org.geotools.referencing.factory.ReferencingObjectFactory not a subtype"

To Reproduce
Steps to reproduce the behavior:

  1. Start attached project
  2. Access http://localhost:8080/test
  3. Check console for error messages

Configuration
No application.properties in use

Screenshots
(If applicable, add screenshots to help explain your problem.)

Environment (please complete the following information):

  • Output of uname -a: Linux 5.7.15-100.fc31.x86_64 Switch to the Maven distributed copy of the SubstrateVM annotations #1 SMP Tue Aug 11 17:18:01 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
  • Output of java -version: openjdk 11.0.8 2020-07-14 / OpenJDK Runtime Environment 18.9 (build 11.0.8+10) / OpenJDK 64-Bit Server VM 18.9 (build 11.0.8+10, mixed mode, sharing)
  • Quarkus version: 1.7.3.Final
  • Build tool: Apache Maven 3.6.3 (cecedd343002696d0abb50b32b541b8a6ba2883f)

Additional context
I've created the smallest possible test case here, so there's no difference in behaviour between dev and prod mode, except from the error messages. In my application I get bugs in dev mode because some of the services from the libraries won't load.

I've looked at https://quarkus.io/guides/class-loading-reference without finding a solution.
I tried to use with quarkus-bootstrap-maven-plugin (and include the complete dependency graph for "gt-referencing"), but that didn't have any effect.

Stack trace
2020-09-16 14:11:53,917 WARNING [org.geo.uti.factory] (executor-thread-1) 8: java.util.ServiceConfigurationError: org.opengis.referencing.crs.CRSFactory: org.geotools.referencing.factory.ReferencingObjectFactory not a subtype at java.base/java.util.ServiceLoader.fail(ServiceLoader.java:588) at java.base/java.util.ServiceLoader$LazyClassPathLookupIterator.hasNextService(ServiceLoader.java:1236) at java.base/java.util.ServiceLoader$LazyClassPathLookupIterator.hasNext(ServiceLoader.java:1264) at java.base/java.util.ServiceLoader$2.hasNext(ServiceLoader.java:1299) at java.base/java.util.ServiceLoader$3.hasNext(ServiceLoader.java:1384) at org.geotools.util.factory.FactoryRegistry.register(FactoryRegistry.java:950) at org.geotools.util.factory.FactoryRegistry.scanForPlugins(FactoryRegistry.java:859) at org.geotools.util.factory.FactoryRegistry.scanForPluginsIfNeeded(FactoryRegistry.java:889) at org.geotools.util.factory.FactoryRegistry.getUnfilteredFactories(FactoryRegistry.java:289) at org.geotools.util.factory.FactoryRegistry.getFactoryImplementation(FactoryRegistry.java:497) at org.geotools.util.factory.FactoryRegistry.getFactory(FactoryRegistry.java:420) at org.geotools.util.factory.FactoryCreator.getFactory(FactoryCreator.java:138) at org.geotools.referencing.ReferencingFactoryFinder.getFactory(ReferencingFactoryFinder.java:200) at org.geotools.referencing.ReferencingFactoryFinder.getCRSFactory(ReferencingFactoryFinder.java:291) at org.geotools.referencing.factory.ReferencingFactoryContainer.getCRSFactory(ReferencingFactoryContainer.java:249) at org.geotools.referencing.factory.ReferencingFactoryContainer.initialize(ReferencingFactoryContainer.java:175) at org.geotools.referencing.factory.ReferencingFactoryContainer.getImplementationHints(ReferencingFactoryContainer.java:195) at org.geotools.util.factory.FactoryRegistry.usesAcceptableHints(FactoryRegistry.java:620) at org.geotools.util.factory.FactoryRegistry.isAcceptable(FactoryRegistry.java:575) at org.geotools.util.factory.FactoryRegistry.lambda$getFactoryImplementation$2(FactoryRegistry.java:504) at java.base/java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:176) at java.base/java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:177) at java.base/java.util.Spliterators$IteratorSpliterator.tryAdvance(Spliterators.java:1812) at java.base/java.util.stream.ReferencePipeline.forEachWithCancel(ReferencePipeline.java:127) at java.base/java.util.stream.AbstractPipeline.copyIntoWithCancel(AbstractPipeline.java:502) at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:488) at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474) at java.base/java.util.stream.FindOps$FindOp.evaluateSequential(FindOps.java:150) at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) at java.base/java.util.stream.ReferencePipeline.findFirst(ReferencePipeline.java:543) at org.geotools.util.factory.FactoryRegistry.getFactoryImplementation(FactoryRegistry.java:505) at org.geotools.util.factory.FactoryRegistry.getFactory(FactoryRegistry.java:420) at org.geotools.util.factory.FactoryCreator.getFactory(FactoryCreator.java:138) at org.geotools.referencing.factory.ReferencingFactoryContainer.instance(ReferencingFactoryContainer.java:162) at org.geotools.referencing.factory.epsg.FactoryUsingWKT.<init>(FactoryUsingWKT.java:142) at org.geotools.referencing.factory.epsg.FactoryUsingWKT.<init>(FactoryUsingWKT.java:136) at org.geotools.referencing.factory.epsg.FactoryUsingWKT.<init>(FactoryUsingWKT.java:126) at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:490) at java.base/java.util.ServiceLoader$ProviderImpl.newInstance(ServiceLoader.java:779) at java.base/java.util.ServiceLoader$ProviderImpl.get(ServiceLoader.java:721) at java.base/java.util.ServiceLoader$3.next(ServiceLoader.java:1394) at org.geotools.util.factory.FactoryRegistry.register(FactoryRegistry.java:953) at org.geotools.util.factory.FactoryRegistry.scanForPlugins(FactoryRegistry.java:859) at org.geotools.util.factory.FactoryRegistry.scanForPluginsIfNeeded(FactoryRegistry.java:889) at org.geotools.util.factory.FactoryRegistry.getFactories(FactoryRegistry.java:251) at org.geotools.referencing.ReferencingFactoryFinder.getFactories(ReferencingFactoryFinder.java:183) at org.geotools.referencing.ReferencingFactoryFinder.getCRSAuthorityFactories(ReferencingFactoryFinder.java:453) at org.geotools.referencing.DefaultAuthorityFactory.getSupportedCodes(DefaultAuthorityFactory.java:124) at org.geotools.referencing.CRS.getSupportedCodes(CRS.java:379) at org.acme.ExampleResource.test(ExampleResource.java:18)

@havwig havwig added the kind/bug Something isn't working label Sep 16, 2020
@havwig
Copy link
Author

havwig commented Sep 16, 2020

sample project.zip

@stuartwdouglas
Copy link
Member

The problematic code is here: https://github.com/geotools/geotools/blob/b9713ae8623959234700166b7e53c5a706e2a8a4/modules/library/metadata/src/main/java/org/geotools/util/factory/FactoryRegistry.java#L770

This is trying to grab all the ClassLoaders it can, and not just using the TCCL. When you have an isolated ClassLoader this can result in loading classes that see a different version of the service.

stuartwdouglas added a commit to stuartwdouglas/quarkus that referenced this issue Sep 17, 2020
The rest of the depenencies are resolved in the bootstrap resolver,
having them on the ClassPath only causes problems.

A similar fix could be applied to Gradle, however I am not sure
how to filter the dependencies to only include those required
for bootstrap.

Fixes quarkusio#12136
stuartwdouglas added a commit to stuartwdouglas/quarkus that referenced this issue Oct 19, 2020
The rest of the depenencies are resolved in the bootstrap resolver,
having them on the ClassPath only causes problems.

A similar fix could be applied to Gradle, however I am not sure
how to filter the dependencies to only include those required
for bootstrap.

Fixes quarkusio#12136
stuartwdouglas added a commit to stuartwdouglas/quarkus that referenced this issue Oct 19, 2020
The rest of the depenencies are resolved in the bootstrap resolver,
having them on the ClassPath only causes problems.

A similar fix could be applied to Gradle, however I am not sure
how to filter the dependencies to only include those required
for bootstrap.

Fixes quarkusio#12136
stuartwdouglas added a commit to stuartwdouglas/quarkus that referenced this issue Oct 22, 2020
The rest of the depenencies are resolved in the bootstrap resolver,
having them on the ClassPath only causes problems.

A similar fix could be applied to Gradle, however I am not sure
how to filter the dependencies to only include those required
for bootstrap.

Fixes quarkusio#12136
@gsmet gsmet modified the milestones: 1.10 - master, 1.9.1.Final Oct 27, 2020
gsmet pushed a commit to gsmet/quarkus that referenced this issue Oct 27, 2020
The rest of the depenencies are resolved in the bootstrap resolver,
having them on the ClassPath only causes problems.

A similar fix could be applied to Gradle, however I am not sure
how to filter the dependencies to only include those required
for bootstrap.

Fixes quarkusio#12136
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/devmode kind/bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants