Reputation: 181
Execution failed for task ':Main.main()'.
Process 'command '/Library/Java/JavaVirtualMachines/jdk1.8.0_77.jdk/Contents/Home/bin/java'' finished with non-zero exit value 1
This is a java project with Gradle. Not sure what this error means.
Upvotes: 12
Views: 36509
Reputation: 1
This error maybe due to the port already being in use. Try again after closing other running instances of the application.
Hope this works!
Upvotes: 0
Reputation: 81
For those who use IntelliJ IDE, if the solutions above don't work for your project, I have another solution: Prefereces->Build, Exectution, Deployment->Build Tools->Gradle->Build and run
change "build and run using" and "run testing using" from Gradle to IntelliJ IDEA, then reload all Gradle projects
Upvotes: 8
Reputation: 1090
This is a very generic error which I've faced as well with my Java Gradle Spring-Boot project. The reason being it so difficult to debug is that it doesn't give out any useful clue as to where the error occurred even if you provide the --stacktrace
or --debug
arguments to your gradle bootRun
command.
However this can be easily determined if you wrap your Spring-Boot bootstrapper code in a try-catch and print the exception stacktrace as below:
@SpringBootApplication
public class MyApplicationServer {
public static void main(String[] args) {
try {
SpringApplication.run(MyApplicationServer.class, args);
} catch (Exception e) {
e.printStackTrace();
}
}
}
In my case, the exception was due to an unquoted special character (*) in application.yml
which lead to a parsing failure. Excerpt of stacktrace below:
java.lang.IllegalStateException: Failed to load property source from location 'classpath:/application-local.yml'
at org.springframework.boot.context.config.ConfigFileApplicationListener$Loader.load(ConfigFileApplicationListener.java:535)
...(truncated logs)
at org.springframework.boot.SpringApplication.prepareEnvironment(SpringApplication.java:358)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:317)
at com.ekart.citylogistics.payout.MyApplicationServer.main(MyApplicationServer.java:24) Caused by: while scanning an alias in 'reader', line 5, column 44:
... endpoints.web.exposure.include: *
^ expected alphabetic or numeric character, but found (10) in 'reader', line 5, column 45:
... ndpoints.web.exposure.include: *
^
at org.yaml.snakeyaml.scanner.ScannerImpl.scanAnchor(ScannerImpl.java:1447)
at org.yaml.snakeyaml.scanner.ScannerImpl.fetchAlias(ScannerImpl.java:918)
at org.yaml.snakeyaml.scanner.ScannerImpl.fetchMoreTokens(ScannerImpl.java:366)
...(truncated logs)
Upvotes: 19
Reputation: 33
This error goes away after updating IDE Compiler version rightly when you have multiple JDK installed on your machine (In my Mac, had JDK8 and JDK11). You may need to restart IDE once you make changes if needed. As in my case IntelliJ IDE, It works after doing invalidate cache and restart IDE.
Upvotes: 1
Reputation: 81
This error is actually very general. I saw this error in my Scala project too. You need to click on the parent error with the line main(), which would show you the actual error. In my case, it is because I didn't download a specific file and there is a null pointer issue. Hope this helps!
Upvotes: 8
Reputation: 375
Try clicking on the parent error with the line Main.main(). This should show you the actual error that occurred. For me, this was occurring because I hadn't set up a database connection in the application.properties file. Hope this helps.
Upvotes: 0