Error while running Jetty server with Maven in Eclipse - eclipse

I am using m2eclipse.
I configured jetty-maven plugin in pom.xml properly.
when I try to execute through CMD its working fine. No error
Whereas when I try to execute through eclipse,
$ java.lang.NoClassDefFoundError: MAVEN_OPTS=-Xdebug -Xnoagent -Djava/compiler=NONE -Xrunjdwp:transport=dt_socket,server=y,suspended=y,address=8000
Exception in thread "main" $
I am missing some Jetty - Eclipse configuration. Can someone suggest on this.
D0 you find any error in this,
MAVEN_OPTS="-XX:MaxPermSize=256M -Xmx512M -Xdebug
-Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=y"

I found it.... the mistake is in VM arguments.. If ur VM arguments is misspelled or something, it throws filenotfound error.
MAVEN_OPTS="-XX:MaxPermSize=256M -Xmx512M -Xdebug -Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=y"
Actual:
-XX:MaxPermSize=256M -Xmx512M -Xdebug -Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=y
No MAVEN_OPTS no quotation in VM arguments while u enter in eclipse...

Related

sbt failed to start with NoClassDefFoundError

On a remote Windows 10 system sbt failes to start with a NoClassDefFoundError:
C:\WORKBENCH\BPF\my-project>sbt -Djavax.net.ssl.trustStoreType=WINDOWS-ROOT -Dsbt.boot.credentials="C:\WORKBENCH\BPF\my-project\credentials.txt" -Dsbt.boot.directory=C:\WORKBENCH\BPF\.sbt\boot -Dsbt.coursier.home=C:\WORKBENCH\BPF\coursier -v
# Executing command line:
"C:\Program Files (x86)\Java\jre1.8.0_321\bin\java.exe"
-Djavax.net.ssl.trustStore="C:\Program Files (x86)\Java\jre1.8.0_321\lib\security\cacerts"
-Djavax.net.ssl.trustStorePassword=changeit
-Xms1024m
-Xmx1024m
-Xss4M
-XX:ReservedCodeCacheSize=128m
-cp
"C:\Program Files (x86)\sbt\bin\sbt-launch.jar"
xsbt.boot.Boot
-Djavax.net.ssl.trustStoreType=WINDOWS-ROOT
-Dsbt.boot.credentials=C:\WORKBENCH\BPF\my-project\credentials.txt
-Dsbt.boot.directory=C:\WORKBENCH\BPF\.sbt\boot
-Dsbt.coursier.home=C:\WORKBENCH\BPF\coursier
java.lang.ClassCastException: java.lang.NoClassDefFoundError cannot be cast to xsbti.FullReload
at sbt.internal.XMainConfiguration.run(XMainConfiguration.java:59)
at sbt.xMain.run(Main.scala:46)
at xsbt.boot.Launch$.$anonfun$run$1(Launch.scala:149)
at xsbt.boot.Launch$.withContextLoader(Launch.scala:176)
at xsbt.boot.Launch$.run(Launch.scala:149)
at xsbt.boot.Launch$.$anonfun$apply$1(Launch.scala:44)
at xsbt.boot.Launch$.launch(Launch.scala:159)
at xsbt.boot.Launch$.apply(Launch.scala:44)
at xsbt.boot.Launch$.apply(Launch.scala:21)
at xsbt.boot.Boot$.runImpl(Boot.scala:78)
at xsbt.boot.Boot$.run(Boot.scala:73)
at xsbt.boot.Boot$.main(Boot.scala:21)
at xsbt.boot.Boot.main(Boot.scala)
[error] [launcher] error during sbt launcher: java.lang.ClassCastException: java.lang.NoClassDefFoundError cannot be cast to xsbti.FullReload
Tried with different SBT versions (1.6.2, 1.5.8, 1.4.9) by changing project/build.properties): The Stack Trace differs depending on the version, but it is always a NoClassDefFoundError.
The SBT version specified in the project is successfully downloaded by the launcher.
I suspect local file permission problems as cause (e.g. due to security policies) therefore i moved the boot and the coursier cache directory. However, this did not bring the desired success.
Does anyone have an idea what the Problem could be?
(I did not do much findings about it.) In my case i could fix it by changing to appropriate java version. Initially i ran with java 18v mistakenly and then changing to java 11v it worked.
I don't have a real diagnosis or causal explanation, but I did solve a similar problem (identical error message, Linux) by clearing out the sbt cache (the .sbt folder within your user directory).

Eclipse Plugin --add-exports Java 16+

Using the google-java-format eclipse plugin works great when running Eclipse under Java 11, but when running on Java 16+, it fails with the following error:
Full error: A save participant caused problems. The save participant 'Code Clean Up' caused an exception: java.lang.IllegalAccessError: class com.google.googlejavaformat.java.JavaInput (in unnamed module #0x99c5646) cannot access class com.sun.tools.javac.parser.Tokens$TokenKind (in module jdk.compiler) because module jdk.compiler does not export com.sun.tools.javac.parser to unnamed module #0x99c5646. See the error log for details.
The google-java-formatter does note that when running on JDK 16+, you need to set the --add-exports flag when running the formatter, due to JEP-396 (strong encapsulation of JDK Internals). What isn't clear is how to tell set --add-exports for Eclipse plugins.
Adding the following to eclipse.ini (or in my case SpringToolSuite4.ini) doesn't seem to help (not to mention it feels wrong since its not targetting that particular plugin). Is there a different way to approach/fix this?
-vmargs
-Dosgi.requiredJavaVersion=11
-Dosgi.dataAreaRequiresExplicitInit=true
-Xms256m
-Xmx2048m
--illegal-access=permit
--add-modules=ALL-SYSTEM
--add-exports jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED
--add-exports jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED
--add-exports jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED
--add-exports jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED
--add-exports jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED
Just like xDeyan said above, your eclipse.ini file must have the following lines below the -vmargs line
--add-exports=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED
--add-exports=jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED
--add-exports=jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED
--add-exports=jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED
--add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED
This has been tested and works with JDK17
For anyone still having this issue running on JDK 17, just add = between the --add-exports like so:
--add-exports=jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED

running testng.xml via command line- error Cannot find class in classpath: com.companyname.SSProject.LaunchSSProject

I am using following command on command line:
C:\Users\MyScriptDirectory>java -classpath ".;Lib\selenium-2.45.0\libs\testng-6.8.5.jar" org.testng.TestNG testng.xml
Getting error message:
[TestNG] [Error]
Cannot find class in classpath: com.companyname.SSProject.LaunchSSProject
I have made following entry in testng.xml:
<class name="com.companyname.SSProject.LaunchSSProject" />
"com.companyname.SSProject" is my package having LaunchSSProject.java file inside it
When I am running the same testng.xml from eclipse, it's working fine.
Does anyone know how to fix this problem?
Thanks in advance
Try the following command: C:\SSProject> java -cp "path/to/your/jar/testng.jar:path/to/your/test_classes" org.testng.TestNG testng.xml
If your testng.xml is not in C:\SSProject than give the full path to the testng.xml.
SO user Patton has explained this very nicely here - How to run TestNG from command line
Updated:
For windows user, following command worked - C:\Project\Path> java -cp "path/to/your/jar/testng.jar;path/to/your/test_classes" org.testng.TestNG testng.xml
I use testNg on windows, in the windows command prompt the execution, I use the command: java -cp bin;libs/* org.testng.TestNG testng.xml
Result: test run successfully
always on windows: I use git bash command, the command does not execute successfully
Image
This worked for me -- go to the project folder in command prompt and type:
java --class-path "/lib/*;/bin" org.testng.TestNG testng.xml
OR
java -cp "lib/*;bin" org.testng.TestNG testng.xml

Jenkins SBT plugin fails with classpath error

I'm trying to get the Jenkins SBT plugin working, which involves referencing the launcher jar, rather than the full SBT install.
This results in "class not found errors", which I believe is because the manifest does not contain the appropriate classpath to allow the launcher to be run like this:
java -Xms512M -Xmx1536M -Xss1M -XX:+CMSClassUnloadingEnabled -XX:MaxPermSize=256M -Dsbt.log.noformat=true -jar /path-to/sbt/sbt-launch.jar package
However, this is exactly how the manual installation instructions at http://www.scala-sbt.org/0.13/tutorial/Manual-Installation.html say it should run.
Have I missed something, or should I be filing a bug report (either with the jenkins SBT plugin team or with SBT)?
EDIT: On closer inspection, it's actually failing due to "java.io.EOFException: Unexpected end of ZLIB input stream". I'll investigate this further and update my own question, as I have seen a few other people run into this same problem with SBT.
Try:
java -Xms512M -Xmx1536M -Xss1M -XX:MaxPermSize=256M -Dsbt.log.noformat=true -jar /path-to/sbt/sbt-launch.jar
If you create own file use (bash script):
java -Xms512M -Xmx1536M -Xss1M -XX:MaxPermSize=256M -Dsbt.log.noformat=true -jar /path-to/sbt/sbt-launch.jar "$#"
Note:
-XX:+CMSClassUnloadingEnabled is only valid for CMS Garbage collector. If you use java 7+ you can remove it. For java 8 remove also -XX:MaxPermSize=256M

Can't deploy app engine project (for jsp file)

When i deploy my eclipse appengine project their is no error and successfully deployed. But when i add a .jsp file in my war folder, i can't deploy. The error message is ==> java.lang.RuntimeException: Cannot get the System Java Compiler. Please use a JDK, not a JRE.
my eclipse jre home definition is ==>
eclipse.ini
pc environment variable
and path
Where is the problem??? I cant understand? Please help someone...
In the eclipse.ini file the change is ==>
-vm
C:\Program Files (x86)\Java\jdk1.7.0_15\bin\javaw.exe
-vmargs
-Dosgi.requiredJavaVersion=1.7
-Dhelp.lucene.tokenizer=standard
-Dosgi.requiredJavaVersion=1.7
Dosgi.requiredJavaVersion=(must be the java version.)