Java: module not found: org.slf4j (and yet definitely in project)

Answered

See attached screenshot.  

What is wrong:

Maven can package and test the build.  IDEA cannot. 

What should happen:

both build, both test, IDEA debug the application.

Notes:

I am running IntelliJ IDEA 2021.3.2 (Ultimate Edition), Build #IU-213.6777.52, built on January 27, 2022.

project source is https://github.com/MarginallyClever/nodeGraphCore/

My pom.xml includes logback-classic and slf4j. logback.xml appears to be valid.  When I run the maven build a nominal log file is generated.

I copied my slf4j settings from another project on this machine that is building and running OK.

2
16 comments

When building, running, or debugging, the Build Output says

C:\Users\aggra\Documents\GitHub\NodeGraphCore\src\main\java\module-info.java:11:17
java: module not found: org.slf4j
C:\Users\aggra\Documents\GitHub\NodeGraphCore\src\main\java\module-info.java:12:21
java: module not found: logback.core

With no further explanation.  Vague error is vague! :)

0

Either delete module-info.java or properly define the modules in this file.

-3

Which part is not properly defined?  requires org.slf4j; was added by IntelliJ.

module com.marginallyClever.nodeGraphCore {
requires java.desktop;
requires org.json;
requires org.slf4j;
requires logback.core;

uses com.marginallyClever.nodeGraphCore.NodeRegistry;
provides com.marginallyClever.nodeGraphCore.NodeRegistry with
com.marginallyClever.nodeGraphCore.BuiltInRegistry,
com.marginallyClever.nodeGraphSwing.SwingRegistry;

uses com.marginallyClever.nodeGraphCore.DAORegistry;
provides com.marginallyClever.nodeGraphCore.DAORegistry with
com.marginallyClever.nodeGraphCore.BuiltInRegistry,
com.marginallyClever.nodeGraphSwing.SwingRegistry;

exports com.marginallyClever.nodeGraphCore;
exports com.marginallyClever.nodeGraphCore.json;

exports com.marginallyClever.nodeGraphSwing;
exports com.marginallyClever.nodeGraphSwing.actions;
}

 

0

According to https://www.slf4j.org/faq.html#jmpsModuleNames, slf4j supports Java modules since 2.x version, you have 1.7.35 in your pom.xml.

Why do you think the issue is with IntelliJ IDEA?

0

I have also tried with 2.0.0-alpha1 through 2.0.0-alpha6, same result.

0

And, as stated in OP, I copied the same SLF4J settings from another project that has module-info.java and everything *just works* there.

The other project is https://github.com/MarginallyClever/Makelangelo-software/

0

I've tried your project from the GitHub link and it builds without errors in IntelliJ IDEA 2021.3.2.

Clearing build system data…
Executing pre-compile tasks…
Loading Ant configuration...
Running Ant tasks...
Cleaning output directories…
Running 'before' tasks
Checking sources
Copying resources... [NodeGraphCore]
Searching for compilable files... [NodeGraphCore]
Parsing java… [NodeGraphCore]
Writing classes… [NodeGraphCore]
Updating dependency information… [NodeGraphCore]
Adding @NotNull assertions… [NodeGraphCore]
Adding pattern assertions… [NodeGraphCore]
Adding the Threading Model assertions… [NodeGraphCore]
Searching for compilable files... [tests of NodeGraphCore]
Parsing java… [tests of NodeGraphCore]
Writing classes… [tests of NodeGraphCore]
Updating dependency information… [tests of NodeGraphCore]
Adding @NotNull assertions… [tests of NodeGraphCore]
Adding pattern assertions… [tests of NodeGraphCore]
Adding the Threading Model assertions… [tests of NodeGraphCore]
Running 'after' tasks
javac 15.0.2 was used to compile java sources
Finished, saving caches…
Executing post-compile tasks…
Loading Ant configuration...
Running Ant tasks...
Synchronizing output directories…
3/16/2022 12:27 - Build completed successfully in 4 sec, 34 ms
0

Great!  That's something.

I removed all my configurations and tried again.  Same error.

I tried "repair IDE" and ran all the steps.  I tried "rebuild project".  I tried "Maven > clean".  I tried "Maven > Reload project".  I tried rebooting.

My guess is a temporary file created by IDEA that doesn't exist on your machine in broken state that it is on mine.  Any ideas?

0
Executing pre-compile tasks…
Loading Ant configuration...
Running Ant tasks...
Running 'before' tasks
Checking sources
Parsing java… [NodeGraphCore]
Checking dependencies… [NodeGraphCore]
Dependency analysis found 7 affected files
Errors occurred while compiling module 'NodeGraphCore'
javac 15.0.2 was used to compile java sources
Finished, saving caches…
Compilation failed: errors: 2; warnings: 0
Executing post-compile tasks…
Loading Ant configuration...
Running Ant tasks...
Synchronizing output directories…
2022-03-16 12:31 p.m. - Build completed with 2 errors and 0 warnings in 1 sec, 853 ms

 

0

Try to delete .idea directory and re-import the project from pom.xml: https://www.jetbrains.com/help/idea/maven-support.html#maven_import_project_start .

1

Well first off, thank you.  That worked. 

It shouldn't have been necessary.  What went wrong?  should I post a zip of my broken .idea folder?

0

Okay... it worked for the first build.  As soon as I edited code everything became angry red.  The IDE claims imports of files in the same package - that I have open in the IDE - are missing.  wtf...

0

That worked more than once.  Thank you!

Any idea what went wrong on my end?  I'd hate to repeat my mistake.

0

We don't know. You can report it at https://youtrack.jetbrains.com/newIssue?project=IDEA with the broken .idea directrory attached and the logs using Help | Collect Logs and Diagnostic Data.

0

Now that I've deleted and overwritten the broken stuff that's... very challenging. :(

0

Please sign in to leave a comment.