1

I'm trying to make my project modular on Eclipse, but I'm running into an issue. I have added the module-info.java file through right-clicking on the project > Configure > Create module-info.java. However, when I run, I get the error

Error occurred during initialization of boot layer
java.lang.module.FindException: Module serenitea-pot-manager not found

I believe this might be caused by having renamed the project to sereniteaPotManager at some point. Initially, the project name was serenitea-pot-manager, which is the name of the module being asked for. I did the renaming through right-clicking on the project > Refactor > Rename..., which should have updated all instances.

I have been searching for a while, but still haven't found a way to fix this. Is there anything else that I need to update on Eclipse for it to change to the correct module name?

Note: The module name included in module-info.java is indeed sereniteaPotManager.

Jak
  • 178
  • 10
  • 1
    Does deleting the launch configuration (in _Run > Run Configurations..._) help? – howlger Sep 19 '21 at 10:56
  • @howlger I tried deleting the configuration and set it up again, but the problem keeps occurring... – Jak Sep 19 '21 at 13:36

5 Answers5

3

I had the same problem. I will summarize my experience then my solution.

I did a rename of the module, and Eclipse kept wanting to use the old module name. Cleans, restarts, etc., did not help. A search of the project properties, the run configuration, and all files in the workspace, did not turn up an instance of the original module name. Editing the module name so that it matched the original one did work. It is as if Eclipse tucks away the initial module name in some hidden place and keeps wanting to use it.

I was able to solve the problem by deleting all Run configurations that existed and then creating a new project and new Run configuration.

I am using JavaFX, and a somewhat peculiar side-effect of this is that the normally-required run configuration argument (below) was not needed in this new run configuration. I wonder if Eclipse is tucking that away in some hidden place, also?

--module-path="C:\Program Files\Java\javafx-sdk-17.0.1\lib" --add-modules=javafx.controls
Lii
  • 11,553
  • 8
  • 64
  • 88
SteveVZZZ
  • 71
  • 4
  • I had a similar problem and found this article: https://stackoverflow.com/questions/36652746/where-are-run-configurations-stored . The .launch run configuration file I used for my project contained an XML element with a key attribute for the MODULE_NAME. Interestingly, if I updated it using say an external editor and saved it from that editor, I couldn't find a way to get Eclipse to "read" and use the updated run configuration until I actually restarted Eclipse. I don't know if there's a way to accomplish that run configuration refresh without a restart, but restarting worked fine. – gcbound Jul 07 '22 at 03:22
1

https://stackoverflow.com/users/17416717/stevevzzz[Steves] solution worked for me while I got stuck with the same problem.

... but I did not create a new project. I only was able to solve the problem by deleting all Run Configurations that existed and then I created a new Run Configuration.

Wilbury
  • 71
  • 5
1

I had the same issue. To solve it I did:

  1. Save the run configuration in a file (this is done in the Common tab in the run configuration, figure 1)
  2. Open the created *.launch file (which is a XML file)
  3. Find the stringAttribute element with the key equals to "org.eclipse.jdt.launching.MODULE_NAME" (figure 2)
  4. Fix it's value with the correct module name
sdimarco
  • 11
  • 1
0

In Java, serenitea-pot-manager is an invalid module name since a module name must not contain hypens (-).

Therefore, In module-info.java, Eclipse shows Syntax error on token "-". So make sure, before running your application, no compile errors are shown in the Problems view.

Rename your module to serenitea_pot_manager, delete the existing launch configuration (in Run > Run Configurations...) and try again:

module serenitea_pot_manager {
    // ...
}
howlger
  • 31,050
  • 11
  • 59
  • 99
  • I'm aware that `-` invalid module names. Although I haven't included my `module-info.java`, I've named the module as `sereniteaPotManager` from the beginning. Eclipse shows no compile errors nor warnings. Still, even after deleting the existing launch configuration, it still asks for a module named `serenitea-pot-manager`, which I can only link to the original project name. – Jak Sep 20 '21 at 14:25
  • Renaming of the project does not affect the module name. Please add your `module-info.java` to your question. Please show what you have in _Run > Run Configurations..._ and what you have deleted before running it again. I can reproduce your issue and the given answer works for me in the current Eclipse 2020-09 (4.21). – howlger Sep 20 '21 at 17:52
  • 1
    Thank you for your help. In the meantime, I have managed create an executable without the modular approach, and since this is a small hooby project, I think I'll just leave it at that since I don't have much more time to dedicate to it. In the end, maybe I messed up something in the run configurations, so your solution could probably work. – Jak Sep 21 '21 at 17:27
0

I noticed the same behaviour. After changing the module name of my project, I got the error

Error occurred during initialization of boot layer
java.lang.module.FindException: Module ... not found

It looks like eclipse holds on to the original module name that is used when first running the application using the Run Configuration. To work around this issue, I deleted and recreated the run configuration. Then it works again.

ezzou
  • 2,348
  • 1
  • 15
  • 16
Dennis
  • 1
  • 2