module resource loading - opens {package} when {package} only holds resources
Rob Bygrave
robin.bygrave at gmail.com
Mon Sep 20 09:58:47 UTC 2021
*> "dbmigration" resources have not been copied into target/classes?*
target/classes/dbmigration exists *BUT* ... now I noticed that dbmigration
only contained other sub-directories (which then contain the resources). So
putting an empty junk.txt file into dbmigration fixes the problem.
So if the resource path only contains subdirectories then we get the
InvalidModuleDescriptorException,
to open resource paths they need to contain at least one file "at the top
level". Hmmm, I'll have to ponder that - it seems pretty subtle.
target/classes/dbmigration
├── postgres *(directory)*
│ └── 1.0_initial.sql
│ └── idx_postgres.migrations
└── mysql *(directory)*
│ └── 1.0_initial.sql
│ └── idx_mysql.migrations
└── junk.txt
*<!-- ADDING THIS FIXES IT*
Cheers, Rob
On Mon, 20 Sept 2021 at 21:22, Alan Bateman <Alan.Bateman at oracle.com> wrote:
> On 20/09/2021 09:55, Rob Bygrave wrote:
> > Hi,
> > I have a case where I believe I have a module where I would like to use:
> >
> > opens {package};
> >
> > ... *where {package} only contains resources*, there are no .class files
> in
> > {package}. Currently when {package} only contains resources, we get an
> > InvalidModuleDescriptorException error:
> >
> > Error occurred during initialization of boot layer
> > java.lang.module.FindException: Error reading module:
> > /home/rob/github/avaje/test-modules/target/classes
> > Caused by: java.lang.module.InvalidModuleDescriptorException: Package
> > dbmigration not found in module
> >
> > module test.modules {
> > ...
> > opens dbmigration;
> > }
> You can open a package that only contains resources. The directory
> structure above hints that this is a Maven project, it is possible that
> the "dbmigration" resources have not been copied into target/classes?
>
> -Alan
>
More information about the jigsaw-dev
mailing list