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.

Please sign in to leave a comment.
When building, running, or debugging, the Build Output says
With no further explanation. Vague error is vague! :)
Either delete module-info.java or properly define the modules in this file.
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;
}
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?
I have also tried with 2.0.0-alpha1 through 2.0.0-alpha6, same result.
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/
I've tried your project from the GitHub link and it builds without errors in IntelliJ IDEA 2021.3.2.
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?
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 .
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?
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...
Close the IDE and delete the System directory: https://www.jetbrains.com/help/idea/directories-used-by-the-ide-to-store-settings-caches-plugins-and-logs.html#system-directory.
That worked more than once. Thank you!
Any idea what went wrong on my end? I'd hate to repeat my mistake.
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.
Now that I've deleted and overwritten the broken stuff that's... very challenging. :(