Eclipse asking for module named after the old project name - java

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.

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?

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 {
// ...
}

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.

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.

Related

How to use a netbeans "friend" module in own modules?

I'm trying to write a small module for netbeans.
Now, everything compiles, but when I try to run the module the follwing error occurs:
The module mtzoutgoings is not a friend of C:\Program Files (x86)\NetBeans 8.0.2\java\modules\org-netbeans-modules-java-j2seproject.jar
I've read that in the jar's MANIFEST.MF there is a section "OpenIDE-Module-Friends" in which all classes are referenced that are allowed to use the jar.
Hm. So, is there any way that I can use it for my module as well, without beeing a "friend" of the jar ?
thanks for any hint!
Thorsten
I'm developing a module for NetBeans. When I tried to run my module, I received the following error message:
The module my_module_name is not a friend of
/home/antonio/netbeans-8.2/php/modules/org-netbeans-modules-php-api-phpmodule.jar
What I did to get rid of that error message: I expanded Libraries, right-clicked PHP Module API and clicked Edit. In the dialog box, I checked Implementation Version and clicked OK.
Reference: https://markmail.org/message/qulevpr647bpvshg

must declare a named package eclipse because this compilation unit is associated to the named module

I just downloaded eclipse for Java Yesterday but when I was trying to get make my first program, I kept on getting this error:
must declare a named package eclipse because this compilation unit is associated to the named module x.
How do I fix this?
Just delete module-info.java at your Project Explorer tab.
The "delete module-info.java at your Project Explorer tab" answer is the easiest and most straightforward answer, but
for those who would want a little more understanding or control of what's happening, the following alternate methods may be desirable;
make an ever so slightly more realistic application; com.YourCompany.etc
or just com.HelloWorld (Project name: com.HelloWorld and class name: HelloWorld)
or
when creating the java project; when in the Create Java Project dialog, don't choose Finish but Next, and deselect Create module-info.java file
Reason of the error: Package name left blank while creating a class. This make use of default package. Thus causes this error.
Quick fix:
Create a package eg. helloWorld inside the src folder.
Move helloWorld.java file in that package. Just drag and drop on
the package. Error should disappear.
Explanation:
My Eclipse version: 2020-09 (4.17.0)
My Java version: Java 15, 2020-09-15
Latest version of Eclipse required java11 or above. The module feature is introduced in java9 and onward. It was proposed in 2005 for Java7 but later suspended. Java is object oriented based. And module is the moduler approach which can be seen in language like C. It was harder to implement it, due to which it took long time for the release. Source: Understanding Java 9 Modules
When you create a new project in Eclipse then by default module feature is selected. And in Eclipse-2020-09-R, a pop-up appears which ask for creation of module-info.java file. If you select don't create then module-info.java will not create and your project will free from this issue.
Best practice is while crating project, after giving project name. Click on next button instead of finish. On next page at the bottom it ask for creation of module-info.java file. Select or deselect as per need.
If selected: (by default) click on finish button and give name for module. Now while creating a class don't forget to give package name. Whenever you create a class just give package name. Any name, just don't left it blank.
If deselect: No issue

Creating own scaffold plugin: metawidget resource loading exception only when run within forge console

I try to rebuild a scaffold faces plugin separately for some reasons, but found a really annoying bug, that I cannot solve.
java.lang.NoSuchMethodException: class org.metawidget.inspector.impl.BaseObjectInspectorConfig.setPropertyStyle(ForgePropertyStyle). Did you mean setPropertyStyle(PropertyStyle)?
at org.metawidget.config.impl.BaseConfigReader$ConfigHandler.classGetMethod(BaseConfigReader.java:1633)
After trying some tricks, review the metawidget config codes, not found how to solve the problem.
scaffold setup --scaffoldType customfaces
works fine, but the
scaffold from-entity com.domain.entity.* --scaffoldType customfaces
fails.
Is anybody has a same issue? May I mess-up something?
Update#1:
The resource loading fails only, when run within forge console. JUnit test works fine. I assume, that metawidget plugin resource loader try to load metawidget-*.xml not from the new plugin but from the original scaffold-api's context.
Update#2:
The problem is somewehere deep in metawidget and forge relation. I found that if I use directly the SimpleResourceResolver.openResource(), the result is valid. But If I add the StaticHtmlWidget.setConfig(), the result is Unable to locate com/domain/customfaces/metawidget-entity.xml on CLASSPATH at the firs write() call. I have no idea, how to resolve this behavior.
Possibly you're including the Metawidget JARs more than once? Forge uses JBoss Modules, so you must be careful how your classpath gets constructed.
The Metawidget error is basically saying that 'ForgePropertyStyle' is not of type 'PropertyStyle'. But (unless you've changed that code in your customfaces) ForgePropertyStyle does indeed extend PropertyStyle. So you must have two PropertyStyles on your classpath somehow?

Luntbuild No modules defined! Error

I am trying to set up Luntbuild 1.6.2 from scratch in our UAT environment. I have created a project, builder and schedule. We use subversion as source control so i have specified the repository and path as well in luntbuild.
But when I trigger the schedule nothing happens and system log reads as below:
com.luntsys.luntbuild.utility.ValidationException: No modules defined!
at com.luntsys.luntbuild.vcs.Vcs.validateModules(Vcs.java:323)
at com.luntsys.luntbuild.vcs.SvnAdaptor.validateModules(SvnAdaptor.java:739)
at com.luntsys.luntbuild.vcs.Vcs.validate(Vcs.java:342)
at com.luntsys.luntbuild.db.Project.validate(Project.java:347)
at com.luntsys.luntbuild.db.Project.validateAtBuildTime(Project.java:363)
at com.luntsys.luntbuild.db.Schedule.validateAtBuildTime(Schedule.java:383)
at com.luntsys.luntbuild.BuildGenerator.execute(BuildGenerator.java:186)
at org.quartz.core.JobRunShell.run(JobRunShell.java:202)
at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:529)
I don't know what I am missing? any clues...??
I was able to resolve this problem with help of one of my colleague...
You have to add the module inside VCS adapter tab and you need not to define all entries. I left all of it as blank and it resolved the issue.

Eclipse ClassNotFoundException

Everything works fined, but suddenly eclipse stopped execute and junit tests or even main method, when i run them using run as - > Java application, run as -> junit test
It simply throws error
Caused by: java.lang.ClassNotFoundException: package.ClassName
whene ClassName - is class from where i trying to run method main.
It affect only one of my projects ... Different workspaces works fine, other project in same workspace works fine as well.
I'm sure if i recreate current project, error will gone. But the adjustments of this project in eclipse is really hard, so i want to avoid it.
Any clue?
The ClassName is not in the Class Path, if you start from console you should use -cp parameter , if from eclipse, please add ClassName to the sources of current(start) project.
Thanks to adarshr, I was able to look at the Problems window and determine that the build was failing because it could not find a class I had written.
I had used the MS TFS plugin to create a "shelveset" and it was supposed to have removed my pending changes in the process. However, this integration with the TFS snapin and Eclipse is obviously not well implemented, since the Eclipse project still thought the file existed and was complaining that it could not be compiled.
I went and manually deleted those "files" or "non-existing files" from the Eclipse project (that I thought I had removed with the shelveset action) and the problem was solved.
Also....
Another annoying things is that the Tomcat error I was getting by trying to debug within Eclipse was like this:
SEVERE: Error configuring application listener of class
com.CompanyName.ProjectName.servlet.StartupConfigListener
java.lang.ClassNotFoundException:
com.CompanyName.ProjectName.servlet.StartupConfigListener at
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1643)
In reality, there was no problem at all with StartupConfigListener.java!! The build failed due to the OTHER problems I mentioned above, and therefore I guess this was the first class it attempted to load and failed.... because the entire project hadn't been able to compile perhaps?
(Here's to hoping my next project is using Visual Studio instead of Eclipse!)
Ok, I finally figured it out. The problem was with installed JRE in eclipse setting. I was playing around with this setting and changed installed JRE to JDK, and for some reason it broke the eclipse project.
You can also try going back to the basics. Check your command line and VM args. I've had this situation where a VM arg I was passing in was a path to a file that had a space in the path, and I had forgotten to include the full path in quotes. So e.g., if my arg looked something like
-DFILE=C:\Documents and Settings\myfile
...I'd get a java.lang.NoClassDefFoundError caused by a java.lang.ClassNotFoundException.

Categories