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

java.lang.module.FindException: Automatic-Module-Name: org.xmlunit.xmlunit-core: Invalid module name: 'xmlunit-core' is not a Java identifier #136

Closed
tzieleniewski opened this Issue Aug 20, 2018 · 4 comments

Comments

Projects
None yet
2 participants
@tzieleniewski
Copy link

tzieleniewski commented Aug 20, 2018

I was investingating project with jdeps tool and encountered automatic module name problem related to xmlunit dependecy.

Environment
java version "10.0.1" 2018-04-17
Java(TM) SE Runtime Environment 18.3 (build 10.0.1+10)
Java HotSpot(TM) 64-Bit Server VM 18.3 (build 10.0.1+10, mixed mode)

Jdeps stack trace

> jdeps --module-path target/dependency target/app.jar
Exception in thread "main" java.lang.module.FindException: Unable to derive module descriptor for target\dependency\xmlunit-core-2.6.0.jar
        at java.base/jdk.internal.module.ModulePath.readJar(ModulePath.java:648)
        at java.base/jdk.internal.module.ModulePath.readModule(ModulePath.java:331)
        at java.base/jdk.internal.module.ModulePath.scanDirectory(ModulePath.java:284)
        at java.base/jdk.internal.module.ModulePath.scan(ModulePath.java:232)
        at java.base/jdk.internal.module.ModulePath.scanNextEntry(ModulePath.java:190)
        at java.base/jdk.internal.module.ModulePath.findAll(ModulePath.java:166)
        at jdk.jdeps/com.sun.tools.jdeps.JdepsConfiguration$Builder.build(JdepsConfiguration.java:558)
        at jdk.jdeps/com.sun.tools.jdeps.JdepsTask.buildConfig(JdepsTask.java:589)
        at jdk.jdeps/com.sun.tools.jdeps.JdepsTask.run(JdepsTask.java:543)
        at jdk.jdeps/com.sun.tools.jdeps.JdepsTask.run(JdepsTask.java:519)
        at jdk.jdeps/com.sun.tools.jdeps.Main.main(Main.java:49)
Caused by: java.lang.module.FindException: Automatic-Module-Name: org.xmlunit.xmlunit-core: Invalid module name: 'xmlunit-core' is not a Java identifier
        at java.base/jdk.internal.module.ModulePath.deriveModuleDescriptor(ModulePath.java:505)
        at java.base/jdk.internal.module.ModulePath.readJar(ModulePath.java:644)
        ... 10 more
@bodewig

This comment has been minimized.

Copy link
Member

bodewig commented Aug 20, 2018

Actually, this affects all our "modules".

The value of the manifest entry is defined inside the parent POM and we need to use some other kind of property than project.artifactId to build the name. Replacing the - with a _ (likely manually) would do the trick.

@tzieleniewski

This comment has been minimized.

Copy link
Author

tzieleniewski commented Aug 22, 2018

@bodewig recently I came across a very cool article about the modules naming.
Perhaps you might find it helpful Java SE 9 - JPMS module naming by Stephen Colebourne

@bodewig

This comment has been minimized.

Copy link
Member

bodewig commented Aug 22, 2018

Thanks, I have read that in the past but simply overlooked the fact that all our artifact names contain dashes.

The issue is pretty trivial to fix, I'm deliberately keeping it open for a while as it provides chance for somebody new to get their feet wet.

Re-reading Stephen's post xmlunit-core should probably use org.xmlunit, the legacy module org.custommonkey.xmlunit, and all the other modules can use the name of their base package. A not quite so trivial case is the "sumo" jar provided by the legacy module, it is probably best to not provide any Automatic-Module-Name at all here.

@bodewig bodewig self-assigned this Aug 27, 2018

@bodewig bodewig closed this in 4e77f25 Aug 27, 2018

@bodewig

This comment has been minimized.

Copy link
Member

bodewig commented Aug 27, 2018

2.6.2 has just been released

@bodewig bodewig removed their assignment Aug 28, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.