I have a testing application running as expected when executed on Eclipse IDE.
We want to export it to a jar and execute it via command line.
After executing, and running the application with the following comand, i encounter an error
java -jar testclient.jar -info
Error: Unable to initialize main class testclient.Main
Caused by: java.lang.NoClassDefFoundError: org/junit/runners/model/InitializationError
( -info) is an argument for the main method in the class.
Manifest file is pointing to the correct class.
On research of this topic, i checked whether the required libraries are added to the path. They are correctly added.
Could anyone provide some guidance
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.
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)
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!
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
build and run
reload Gradle projects
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.
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.
This error maybe due to the port already being in use. Try again after closing other running instances of the application.
Hope this works!
I'm just starting out with Scala and have been following its Getting Started instructions. The second part of the instruction involves pulling the hello-world template by running the sbt new scala/hello-world.g8 command.
My problem is that it keeps on giving me this error:
Error: Could not find or load main class Anne
Caused by: java.lang.ClassNotFoundException: Anne
I'd like to know the reason for this, as well as any possible fix I might use.
The following is my insight and attempts on fixing this problem.
Insight:
1. I might have a problem with java installation/scala/sbt installation that needs this class Anne since even with other sbt commands like sbt sbtVersion I get the same error
Attempts:
1. Change command to retrieve from full url:
sbt new https://github.com/scala/hello-world.g8
2.(Edit): Previously I thought the repository scala/hello-world.g8 did not exist and tried getting from other repositories with no luck and with the same error as above. However it was pointed out below that the repository actually exists in this url https://github.com/scala/hello-world.g8, thanks Dmytro Mitin.
I was looking into the incorrect account (sbt) instead of (scala)
(Edit): Day 2
3. Uninstall/Reinstall sbt -- still getting the error
4. Checked if java running properly by compiling sample code and running ( successful )
I was actually running the command in Visual Studio Code's bash terminal. I tried running it with cmd and everything's now working fine.
Running Unity 4.5.4f1 and Playscape SDK version 1.14, building for android target, I am getting an Error unknown during the apply patch process in Unity. When running the executed command in CMD, I get the following error:
Error: Could not find or load main class com.googlecode.dex2jar.tools.Dex2jarCmd
The command input I provide (taken from the SDK logger) is the following:
"C:\Program Files (x86)\Java\jdk1.8.0_51/bin/java.exe" -clas
spath Assets/Plugins/Playscape/Editor/ThirdParty/dex2jar\lib/asm-all-3.3.1.jar;A
ssets/Plugins/Playscape/Editor/ThirdParty/dex2jar\lib/commons-lite-1.15.jar;Asse
ts/Plugins/Playscape/Editor/ThirdParty/dex2jar\lib/dex-ir-1.12.jar;Assets/Plugin
s/Playscape/Editor/ThirdParty/dex2jar\lib/dex-reader-1.15.jar;Assets/Plugins/Pla
yscape/Editor/ThirdParty/dex2jar\lib/dex-tools-0.0.9.15.jar;Assets/Plugins/Plays
cape/Editor/ThirdParty/dex2jar\lib/dex-translator-0.0.9.15.jar;Assets/Plugins/Pl
ayscape/Editor/ThirdParty/dex2jar\lib/dx.jar;Assets/Plugins/Playscape/Editor/Thi
rdParty/dex2jar\lib/jar-rename-1.6.jar;Assets/Plugins/Playscape/Editor/ThirdPart
y/dex2jar\lib/asmin-p2.5.jar -Xms1024m -Xms1024m com.googlecode.dex2jar.tools.De
x2jarCmd -f -o "C:\Users\THREEG~1\AppData\Local\Temp\vbqpzsn0.9r6.jar" "C:\Users
\THREEG~1\AppData\Local\Temp\jhcbrbrz.ocm./classes.dex"
I have checked the folder structure inside the project and dex2jar seems to be present. We did not see this issue before updating.
How can I resolve this?
I found it myself. This is most likely due to a spelling error in AndroidApkCreator.cs, row 39, where "lib/asmin-p2.5.jar" instead should read "lib/jasmin-p2.5.jar", judging by the file name inside the lib folder. This does not seem to completely remove the issue, however, as the CMD prompt still throws the following Error:
Could not find or load main class com.googlecode.dex2jar.tools.Dex2JarCmd
Execution exception
NoSuchMethodError occured : com.test.refFilesDataService.service.RefFilesDataServiceDelegate.fetchSegmentation(Lcom/test/refFilesDataService/service/RefFilesDataServiceSegmentationRequest;)Lcom/test/refFilesDataService/service/RefFilesDataServiceSegmentationResponse;
Calling using the following line:
RefFilesDataServiceSegmentationResponse response = getService()
.fetchSegmentation(request);
This is a newly added method to the external jar I'm referring to. All other methods in the jar works without a problem except this. Works in my local but fails in the Dev environment
Try
javap -classpath yourexternal.jar com.test.refFilesDataService.service.RefFilesDataServiceDelegate
on your test & dev environment and compare the method & signatures.
javap documentation available at
http://docs.oracle.com/javase/7/docs/technotes/tools/windows/javap.html