Comments (12)
@ValorVl I've finally found the time to set up an example project to test this. When leaving out the requires
declaration for the blackbird module, the application starts fine. When adding the requires
declaration for the blackbird module, I can reproduce your exceptions.
As I stated earlier, blackbird must have the ability to read the modules where it wants to perform the optimizations to have correct access privileges when calling privateLookupIn
. Since blackbird not only optimizes your classes but additionally dropwizard's classes, a reads
declaration has to be present for the io.dropwizard.core
module (e.g. for the Configuration
class, but other dropwizard modules may also lack the reads
access). Therefore the following reads
declarations have to be present (ALL-UNNAMED
should be added, if you have unnamed modules in your application):
--add-reads
com.fasterxml.jackson.module.blackbird=backend.service
--add-reads
com.fasterxml.jackson.module.blackbird=io.dropwizard.core
--add-reads
com.fasterxml.jackson.module.blackbird=ALL-UNNAMED
Then blackbird can continue to define the new classes for the optimizations. The new anonymous classes generated by blackbird reside in the modules, where the classes to be optimized are declared. This means new classes will be created in your module backend.service
when blackbird performs optimizations there. These classes seem to access blackbird APIs and therefore the blackbird APIs have to be exported to the modules where optimized classes are generated. In my test project this are only io.dropwizard.core
and unnamed modules, so the following declarations have to be present:
--add-exports
com.fasterxml.jackson.module.blackbird/com.fasterxml.jackson.module.blackbird.ser=io.dropwizard.core
--add-exports
com.fasterxml.jackson.module.blackbird/com.fasterxml.jackson.module.blackbird.ser=ALL-UNNAMED
--add-exports
com.fasterxml.jackson.module.blackbird/com.fasterxml.jackson.module.blackbird.deser=ALL-UNNAMED
--add-exports
com.fasterxml.jackson.module.blackbird/com.fasterxml.jackson.module.blackbird.deser=io.dropwizard.core
After adding all these command line options, I don't get any exception and the application starts again.
That being said: Dropwizard currently only introduces Automatic-Module-Name
s and doesn't provide full support for the JPMS. The automatic modules are just a transition step and we probably won't introduce support for the JPMS anytime soon. So you might encounter further problems when using the JPMS right now.
from dropwizard.
Hi @ValorVl. The JavaDoc of privateLookupIn
gives a hint. The opens
declaration in your module-info
is present. But the exception message explains the reads
declaration in the blackbird module is missing. To add the missing declaration, you can use the --add-reads
command line argument.
from dropwizard.
Hello @zUniQueX . Thank you for the clarification. I tried your solution and yes, the first problem was solved, but another problem occurred.
Added --add-reads com.fasterxml.jackson.module.blackbird=backend.service
This looks like a bug in the library
java.lang.InternalError: java.lang.IllegalAccessError: superinterface check failed: class com.****.config.$$JacksonBlackbirdAccess$$Lambda/0x000000040138ba60 (in module backend.service) cannot access class com.fasterxml.jackson.module.blackbird.ser.ToBooleanFunction (in module com.fasterxml.jackson.module.blackbird) because module com.fasterxml.jackson.module.blackbird does not export com.fasterxml.jackson.module.blackbird.ser to module backend.service
at java.base/java.lang.invoke.InnerClassLambdaMetafactory.generateInnerClass(InnerClassLambdaMetafactory.java:364)
at java.base/java.lang.invoke.InnerClassLambdaMetafactory.spinInnerClass(InnerClassLambdaMetafactory.java:286)
at java.base/java.lang.invoke.InnerClassLambdaMetafactory.buildCallSite(InnerClassLambdaMetafactory.java:221)
at java.base/java.lang.invoke.LambdaMetafactory.metafactory(LambdaMetafactory.java:341)
at [email protected]/com.fasterxml.jackson.module.blackbird.ser.BBSerializerModifier.createProperty(BBSerializerModifier.java:133)
at [email protected]/com.fasterxml.jackson.module.blackbird.ser.BBSerializerModifier.lambda$findProperties$0(BBSerializerModifier.java:67)
at [email protected]/com.fasterxml.jackson.module.blackbird.util.Unchecked.lambda$runnable$0(Unchecked.java:31)
at [email protected]/com.fasterxml.jackson.module.blackbird.ser.BBSerializerModifier.findProperties(BBSerializerModifier.java:68)
at [email protected]/com.fasterxml.jackson.module.blackbird.ser.BBSerializerModifier.changeProperties(BBSerializerModifier.java:52)
at [email protected]/com.fasterxml.jackson.databind.ser.BeanSerializerFactory.constructBeanOrAddOnSerializer(BeanSerializerFactory.java:415)
at [email protected]/com.fasterxml.jackson.databind.ser.BeanSerializerFactory.findBeanOrAddOnSerializer(BeanSerializerFactory.java:295)
at [email protected]/com.fasterxml.jackson.databind.ser.BeanSerializerFactory._createSerializer2(BeanSerializerFactory.java:240)
at [email protected]/com.fasterxml.jackson.databind.ser.BeanSerializerFactory.createSerializer(BeanSerializerFactory.java:174)
at [email protected]/com.fasterxml.jackson.databind.SerializerProvider._createUntypedSerializer(SerializerProvider.java:1503)
at [email protected]/com.fasterxml.jackson.databind.SerializerProvider._createAndCacheUntypedSerializer(SerializerProvider.java:1471)
at [email protected]/com.fasterxml.jackson.databind.SerializerProvider.findValueSerializer(SerializerProvider.java:597)
at [email protected]/com.fasterxml.jackson.databind.ser.DefaultSerializerProvider.acceptJsonFormatVisitor(DefaultSerializerProvider.java:565)
at [email protected]/com.fasterxml.jackson.databind.ObjectMapper.acceptJsonFormatVisitor(ObjectMapper.java:4670)
at [email protected]/com.fasterxml.jackson.databind.ObjectMapper.acceptJsonFormatVisitor(ObjectMapper.java:4649)
at [email protected]/io.dropwizard.configuration.ConfigurationMetadata.<init>(ConfigurationMetadata.java:76)
at [email protected]/io.dropwizard.configuration.BaseConfigurationFactory.<init>(BaseConfigurationFactory.java:80)
at [email protected]/io.dropwizard.configuration.YamlConfigurationFactory.<init>(YamlConfigurationFactory.java:28)
at [email protected]/io.dropwizard.configuration.DefaultConfigurationFactoryFactory.create(DefaultConfigurationFactoryFactory.java:22)
at [email protected]/io.dropwizard.core.cli.ConfiguredCommand.parseConfiguration(ConfiguredCommand.java:137)
at [email protected]/io.dropwizard.core.cli.ConfiguredCommand.run(ConfiguredCommand.java:85)
at [email protected]/io.dropwizard.core.cli.Cli.run(Cli.java:78)
at [email protected]/io.dropwizard.core.Application.run(Application.java:94)
at backend.service/com.*****.application.BackendApplication.main(BackendApplication.java:79)
Caused by: java.lang.IllegalAccessError: superinterface check failed: class com.****.config.$$JacksonBlackbirdAccess$$Lambda/0x000000040138ba60 (in module backend.service) cannot access class com.fasterxml.jackson.module.blackbird.ser.ToBooleanFunction (in module com.fasterxml.jackson.module.blackbird) because module com.fasterxml.jackson.module.blackbird does not export com.fasterxml.jackson.module.blackbird.ser to module backend.service
at java.base/java.lang.ClassLoader.defineClass0(Native Method)
at java.base/java.lang.System$2.defineClass(System.java:2390)
at java.base/java.lang.invoke.MethodHandles$Lookup$ClassDefiner.defineClass(MethodHandles.java:2505)
at java.base/java.lang.invoke.InnerClassLambdaMetafactory.generateInnerClass(InnerClassLambdaMetafactory.java:361)
... 27 more
from dropwizard.
Hi @ValorVl. The exception suggests that an exports declaration is missing. The linked article explaining the --add-reads
option additionally explains the --add-exports
option. An export also contains the user package. Therefore this isn't provided by the library authors.
from dropwizard.
Hi @zUniQueX. Yes, I added --add-exports, but it didn't help. The entry point for the exception is located in the io.dropwizard.core.Configuration#getLoggingFactory
Added
--add-reads
com.fasterxml.jackson.module.blackbird=backend.service
--add-exports
com.fasterxml.jackson.module.blackbird/com.fasterxml.jackson.module.blackbird.ser=backend.service
--add-opens
java.base/java.lang.invoke=ALL-UNNAMED
--add-opens
java.base/java.lang=ALL-UNNAMED
Exception thrown after all added options:
java.lang.IllegalAccessException: access to public member failed: io.dropwizard.core.Configuration.getLoggingFactory[Ljava.lang.Object;@3b353651/invokeVirtual, from class com.***.config.BackendConfiguration (module backend.service), previous lookup com.fasterxml.jackson.module.blackbird.BlackbirdModule$$Lambda/0x000000a00112a8f0 (module com.fasterxml.jackson.module.blackbird)
at java.base/java.lang.invoke.MemberName.makeAccessException(MemberName.java:894)
at java.base/java.lang.invoke.MethodHandles$Lookup.checkAccess(MethodHandles.java:3987)
at java.base/java.lang.invoke.MethodHandles$Lookup.checkMethod(MethodHandles.java:3923)
at java.base/java.lang.invoke.MethodHandles$Lookup.getDirectMethodCommon(MethodHandles.java:4072)
at java.base/java.lang.invoke.MethodHandles$Lookup.getDirectMethodNoSecurityManager(MethodHandles.java:4065)
at java.base/java.lang.invoke.MethodHandles$Lookup.unreflect(MethodHandles.java:3451)
at [email protected]/com.fasterxml.jackson.module.blackbird.ser.BBSerializerModifier.createProperty(BBSerializerModifier.java:103)
at [email protected]/com.fasterxml.jackson.module.blackbird.ser.BBSerializerModifier.lambda$findProperties$0(BBSerializerModifier.java:67)
at [email protected]/com.fasterxml.jackson.module.blackbird.util.Unchecked.lambda$runnable$0(Unchecked.java:31)
at [email protected]/com.fasterxml.jackson.module.blackbird.ser.BBSerializerModifier.findProperties(BBSerializerModifier.java:68)
at [email protected]/com.fasterxml.jackson.module.blackbird.ser.BBSerializerModifier.changeProperties(BBSerializerModifier.java:52)
at [email protected]/com.fasterxml.jackson.databind.ser.BeanSerializerFactory.constructBeanOrAddOnSerializer(BeanSerializerFactory.java:415)
at [email protected]/com.fasterxml.jackson.databind.ser.BeanSerializerFactory.findBeanOrAddOnSerializer(BeanSerializerFactory.java:295)
at [email protected]/com.fasterxml.jackson.databind.ser.BeanSerializerFactory._createSerializer2(BeanSerializerFactory.java:240)
at [email protected]/com.fasterxml.jackson.databind.ser.BeanSerializerFactory.createSerializer(BeanSerializerFactory.java:174)
at [email protected]/com.fasterxml.jackson.databind.SerializerProvider._createUntypedSerializer(SerializerProvider.java:1503)
at [email protected]/com.fasterxml.jackson.databind.SerializerProvider._createAndCacheUntypedSerializer(SerializerProvider.java:1471)
at [email protected]/com.fasterxml.jackson.databind.SerializerProvider.findValueSerializer(SerializerProvider.java:597)
at [email protected]/com.fasterxml.jackson.databind.ser.DefaultSerializerProvider.acceptJsonFormatVisitor(DefaultSerializerProvider.java:565)
at [email protected]/com.fasterxml.jackson.databind.ObjectMapper.acceptJsonFormatVisitor(ObjectMapper.java:4670)
at [email protected]/com.fasterxml.jackson.databind.ObjectMapper.acceptJsonFormatVisitor(ObjectMapper.java:4649)
at [email protected]/io.dropwizard.configuration.ConfigurationMetadata.<init>(ConfigurationMetadata.java:76)
at [email protected]/io.dropwizard.configuration.BaseConfigurationFactory.<init>(BaseConfigurationFactory.java:80)
at [email protected]/io.dropwizard.configuration.YamlConfigurationFactory.<init>(YamlConfigurationFactory.java:28)
at [email protected]/io.dropwizard.configuration.DefaultConfigurationFactoryFactory.create(DefaultConfigurationFactoryFactory.java:22)
at [email protected]/io.dropwizard.core.cli.ConfiguredCommand.parseConfiguration(ConfiguredCommand.java:137)
at [email protected]/io.dropwizard.core.cli.ConfiguredCommand.run(ConfiguredCommand.java:85)
at [email protected]/io.dropwizard.core.cli.Cli.run(Cli.java:78)
at [email protected]/io.dropwizard.core.Application.run(Application.java:94)
at backend.service/com.***.application.BackendApplication.main(BackendApplication.java:79)
from dropwizard.
Hi @ValorVl. Dropwizard itself isn't fully compatible with the JPMS yet. We have just introduced Automatic-Module-Name
s.
from dropwizard.
Hi @zUniQueX. Do I understand correctly that there is currently no solution for this problem?
It would be nice to be able to disable third-party library modules, even at the cost of performance. This way, blocking during migration could be avoided.
from dropwizard.
@ValorVl There isn't a native solution. As I said, we don't provide full JPMS information through module-info
files for the framework classes. If you want to use Dropwizard with modules, you would have to patch our modules to obtain those information. This could be done with command line arguments but would take some effort to accomplish.
from dropwizard.
@zUniQueX What command line arguments are we talking about? Do you mean ***=ALL-UNNAMED?
from dropwizard.
@ValorVl The modules are named, but don't properly declare exports, reads etc. If you want to use reflection on dropwizard classes, you'd have to add the proper reads
declarations.
from dropwizard.
@zUniQueX Sorry, I don't understand, I don't use reflection in my code and I don't make changes to the framework code. The problem occurs during project compilation and is related to the library jackson/blackbird which is used by the framework. Those. I have no control over this. I also cannot disable the jackson/blackbird module since it is also initialized inside the framework. I donβt see any solution other than rebuilding the Dropwizard (
from dropwizard.
@zUniQueX thank you for your work. yes, it works.
from dropwizard.
Related Issues (20)
- Incorrect javadocs for io.dropwizard.logging.common.AppenderFactory
- Dropwizard 4.0.3 not logging request logs HOT 2
- AWS Serverless Example HOT 1
- Dropwizard 4.0.2 + Hibernate + ContainerResponseFilter with NameBinding HOT 3
- Jersey client 2.21 doesnt support Transfer-encoding: chunked, is there any workaround?
- Breaking change in a version between 4.0.1 and 4.0.4 HOT 3
- DropwizardJettyServerAdapter in DropWizard3 causing exception when there are multiple HttpHeaders HOT 9
- Update Logback to fix CVE-2023-6378? HOT 4
- NPE in tests when a factory is used to inject a value to a resource method parameter HOT 2
- Managed virtual thread pool HOT 2
- Deserialization failures due to Afterburner HOT 1
- Server starts and stops immediately when both enableVirtualThreads and enableAdminVirtualThreads are set to true HOT 5
- delay between tests that use DropwizardExtensionsSupport HOT 2
- Logging request and response body with RequestLogFactory HOT 2
- Dependency Injection issue in AuthFilter HOT 4
- Add cache support for stale-while-revalidate HOT 1
- Redirect log output for commands other than "server" HOT 2
- Enhancement: Make Cli ArgumentParsers locale configurable HOT 6
- Enhancement: Expose `message` property in Dropwizard health functionality
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from dropwizard.