-
Notifications
You must be signed in to change notification settings - Fork 126
Could not find or load main class #406
Comments
Could it be this problem? If it doesn't look like that's it. You have really not provided enough information for us to guess at the problem. So please provide a sample project and more detailed step-by-step instructions on how to to reproduce the problem. |
I have the same problem. With some investigation using "Show command line" function I found out that when the classpath is very long, eclipse uses the @argfile jdk9+ option, and the command line is like this:
In the generated temp file the classpath includes double quotes (-classpath "C:\path\to\target"). Removing quotes and running from commandline, the main class is found correctly. I think that in @argfile scenario double quotes should not be included |
I found that the bug is documented here: Has been introduced with this commit https://git.eclipse.org/r/#/c/151582/ in 2019-12 and should be fixed in Eclipse 2020-03. There's a suggested workaround but didn't work for me |
Great detective work @bberto . It does sound like that could be the bug responsible. Before closing this ticket as a duplicate of that bug, I think we need to somehow verify that: a) it is indeed the bug responsible So you think you could help me with that by trying to give me some steps to reproduce this bug in STS 4.5.1? From reading the eclipse bug. I figured out:
Do we need something else in terms of special conditions to cause the problem? E.g. some paths with spaces in them? Or a particularly large project with many dependencies? |
@bberto Please give the latest STS 4.5.2 CI builds on Eclipse 4.15 a try, they should already include the fix for the Eclipse platform: http://dist.springsource.com/snapshot/STS4/nightly-distributions.html |
My setup: windows 10, JDK 11 / JDK 13 (tested both), STS 4.5.0
This is the minimal test case, but it's the same with Spring Boot run configurations. I discovered the issue in a Boot project that includes lots of apache camel deps. I can confirm that the issue is solved in STS-4.5.2-CI based on eclipse 2020-03. Also the workaround proposed in linked issue works: you have to manually edit .metadata.plugins\org.eclipse.debug.core.launches run configuration to set org.eclipse.jdt.launching.ATTR_USE_CLASSPATH_ONLY_JAR=true |
My main concern is that we need to confirm the fix in Eclipse which is specifically addressing the problem for plain Java projects also fixes the issue for boot projects/launches. This is probably the case but not guaranteed because "Run As Boot App" is a separate launch configuration implementation. It inherits some functionality from the Java implementation but it is not identical.
Did you confirm this with a "Run as Boot App" launch, or only with the 'minimal' plain Java scenario? |
Performed the same test with a minimal Spring Boot project, including just an ApplicationRunner class that prints Hello World and all the eclipse plugin folder imported in classpath. "Run as Boot App" launch fails in STS-4.5.0 and works in STS-4.5.2-CI |
@bberto Thanks a lot for confirming that. We can close this ticket now. |
The build is successful while executing maven install and the class files are also created. However, while selecting run as java application or Spring boot App, it shows could not find or load main class. moreover, if jar of the project is exported, it runs fine.
The text was updated successfully, but these errors were encountered: