You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@netbeans.apache.org by Emma Atkinson <em...@gmail.com> on 2018/10/02 17:05:17 UTC

I have tried build a very simple Java application demonstrating a problem I
am having with using the latest Log4j2 V2.11.1 as a module (log4j.api) and
building it using the ant scripts.  It compiles, builds and runs when I use
the classpath, but cannot compile the module-info.java file when I use the
modulepath. I have uploaded the code and Netbeans files at the following
link:

https://github.com/cosmiczoo/Log4j2TestCase

Log4j2 V2.11.1 is a Multi-release JAR (MR-JAR).  The module-info.class file
is in log4j-api-2.11.1.jar under the folder META-INF/versions/9, which
seems correct.

The Netbeans editor can see the module log4j.api because it appears in the
drop-down menu of completion suggestions and does not have wiggly red line
under it.  My simple test program has a module-info.java file that requires
log4j.api and nothing else.  This bit works as I would expect.

I *Clean* the project.  It completes successfully.
I then use a RMB option to *Compile File* the module-info.java file.
This generates an error pointing to the line *requires log4j.api* in my
module-info.java.

<path-to>/Log4j2TestCase/src/module-info.java:7: error: module not found:
log4j.api
    requires log4j.api;
1 error
ZipFileIndex clearCache failed
<path-to>/Log4j2TestCase/nbproject/build-impl.xml:1131: The following error
occurred while executing this line:
<path-to>/Log4j2TestCase/nbproject/build-impl.xml:358: Compile failed; see
the compiler error output for details.
    at org.apache.tools.ant.taskdefs.Javac.compile(Javac.java:1425)
    at org.apache.tools.ant.taskdefs.Javac.execute(Javac.java:1133)
    at
org.netbeans.modules.java.source.ant.JavacTask.execute(JavacTask.java:120)
    at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:292)

and so on.  Let me know if you want more.

I notice too that I have notification that an unexpected exception
(java.langAssertionError) has been generated but I recklon this is a
side-effect / consequence of the ant script not finding the module.

I have tried building this program under JDK-9, JDK-10 and JDK-11.  My
Netbeans runs on JDK-10.  I am learning how to migrate to modules by trial,
error and reading.  I may have made an error, but if I have, I don't know
where.

Thanks
Emma