Java\Selenium - NoClassDefFoundError: org/openqa/selenium/support/ui/Wait - java

Everything works fine when debugging the project on the intelij environment.
But when I try to execute
java -jar myJar.jar
I get
Exception in thread "main" java.lang.NoClassDefFoundError: org/openqa/selenium/support/ui/Wait
at com.anyclip.App.main(App.java:43)
Caused by: java.lang.ClassNotFoundException: org.openqa.selenium.support.ui.Wait
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:606)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:168)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522)
... 1 more
I tried several solutions, including this one (ClassNotFoundException on a Maven Project using Selenium), but all failed.
How can I overcome this?

Related

java.lang.NoClassDefFoundError: reactivemongo/core/errors/ConnectionException

OS: Ubuntu 22.04.1 LTS
java: openjdk-18.0.2.1
I got the folowing error when trying to connect to a MongoDB database from ReactiveMongo API (reactivemongo_3-1.1.0-noshaded-RC6):
java.lang.NoClassDefFoundError: reactivemongo/core/errors/ConnectionException
Exception in thread "main" java.lang.NoClassDefFoundError: reactivemongo/core/errors/ConnectionException
at reactivemongo.api.AsyncDriver$.apply(AsyncDriver.scala:503)
at e2m.MongoExport.<init>(MongoExport.scala:35)
at e2m.MongoExport$.<clinit>(MongoExport.scala:82)
at e2m.MongoExport.main(MongoExport.scala)
Caused by: java.lang.ClassNotFoundException: reactivemongo.core.errors.ConnectionException
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
... 4 more
I looked for the package "reactivemongo.core.errors" inside the jar file and I did not found it.
Could you help me out by telling me which jar file should I include in my project to solve this problem?
Thanks

NoClassDefFoundError using jars

I am new to Java and trying around. Now I would like to learn about network - server client communications. Long story short I found jars on github which should make the start easier. So I downloaded the file and added it to my Modulepath. Everything looked OK while writing a simple start to just connect but when I want to run for testing I get the NoClassDefFoundError ...
Exception in thread "main" java.lang.NoClassDefFoundError: com/blogspot/debukkitsblog/net/Server
at java.base/java.lang.ClassLoader.defineClass1(Native Method)
at java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:1010)
at java.base/java.security.SecureClassLoader.defineClass(SecureClassLoader.java:150)
at java.base/jdk.internal.loader.BuiltinClassLoader.defineClass(BuiltinClassLoader.java:855)
at java.base/jdk.internal.loader.BuiltinClassLoader.findClassOnClassPathOrNull(BuiltinClassLoader.java:753)
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClassOrNull(BuiltinClassLoader.java:676)
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:634)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:182)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:519)
at fst.serverclient.ssc.SSCNetzwerkTester.main(SSCNetzwerkTester.java:6)
Caused by: java.lang.ClassNotFoundException: com.blogspot.debukkitsblog.net.Server
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:636)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:182)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:519)
... 10 more
I do not have any idea what am I doing wrong, the jar should work otherwise it should not be there for download I guess. But the error comes from one of the jar classes called Server:
java.lang.NoClassDefFoundError: com/blogspot/debukkitsblog/net/Server

How to use Eclipse ClassPath via CMD or Bash?

I have one app which I want to dockerize. But first, I need to run it via console(cmd or bash). When I run it from Eclipse everything is okay, but when I run it from bash(java -jar project-18.5.0-SNAPSHOT.jar) I get this error
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/logging/LogFactory
at com.hp.spacecat.util.PropertyUtil.<clinit>(PropertyUtil.java:35)
at com.hp.spacecat.SpaceCat.main(SpaceCat.java:76)
Caused by: java.lang.ClassNotFoundException: org.apache.commons.logging.LogFactory
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 2 more
I have that jar in m2 and he has this LogFactory class. Mvn clean install is success. But for some reason I can't run it via console. I don't know is there some way to get that classpath from Eclipse or there is another way to solve this.
Similar questions about this logging exception didn't help me.

Failed to create AVD from command line; message says java.se.ee not found

I am trying to create AVD on my mac from command line,
avdmanager create avd -n test -k "system-images;android-28;google_apis;x86"
Then I got this error message
Exception in thread "main" java.lang.NoClassDefFoundError: javax/xml/bind/annotation/XmlSchema
at com.android.repository.api.SchemaModule$SchemaModuleVersion.(SchemaModule.java:156)
at com.android.repository.api.SchemaModule.(SchemaModule.java:75)
at com.android.sdklib.repository.AndroidSdkHandler.(AndroidSdkHandler.java:81)
at com.android.sdklib.tool.AvdManagerCli.run(AvdManagerCli.java:213)
at com.android.sdklib.tool.AvdManagerCli.main(AvdManagerCli.java:200)
Caused by: java.lang.ClassNotFoundException: javax.xml.bind.annotation.XmlSchema
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:602)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
... 5 more
I tried to fix the problem by doing
export JAVA_OPTS='-XX:+IgnoreUnrecognizedVMOptions --add-modules java.se.ee'
And then the error message become
Error occurred during initialization of boot layer
java.lang.module.FindException: Module java.se.ee not found
It seems java.se.ee was removed in JAVA 11 but now I am using JAVA 13. Is there any solution other than downgrade JAVA version?
At last I downgrade my java to 8 and it worked.

Running java project in command prompt

I've created a java project in Netbeans and I am trying to run it in the command prompt by creating a .jar of the project and then doing java -jar nameOfThePorject.jar but I get this error:
Exception in thread "main" java.lang.NoClassDefFoundError: com/coti/tools/Rutas
at controller.Controller.compruebaBinario(Controller.java:41)
at view.Vista.comienzaLaFiesta(Vista.java:23)
at musicfy.Main.main(Main.java:25)
Caused by: java.lang.ClassNotFoundException: com.coti.tools.Rutas
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:604)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
... 3 more
How can I fix it?
PS: I am running the project in Netbeans without any error

Categories