Unable to execute testNG in CMD prompt.
I'm getting this error:
java.lang.ClassNotFoundException: com.google.gson.JsonObject
I have all the jars in my build path. gson-2.8.2.jar and all the selenium supported jars and even testng jars.
java.lang.NoClassDefFoundError: com/google/gson/JsonObject Caused by:
java.lang.ClassNotFoundException: com.google.gson.JsonObject
Command used to run:
java -cp bin;jarslib/* org.testng.TestNG testng.xml
All the jars in my JarsLib folder
I found the solution, I've added into my resource but not added into my environment variable. Once I added, it's working fine.
Related
I have set the variable in ~/.bashrc
export HADOOP_CLASSPATH=$HADOOP_CLASSPATH:/usr/lcoal/Hbase/lib/hbase-client-1.2.4.jar
but when i compile the code
java -cp $HADOOP_CLASSPATH:/home/hadoopuser/Downloads/myjar.jar com.bigdata.uniquecoder.WordCountClass
It still gives me this error.
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/hadoop/hbase/HBaseConfiguration
at com.bigdata.uniquecoder.WordCountClass.main(WordCountClass.java:57)
Caused by:java.lang.ClassNotFoundException:org.apache.hadoop.hbase.HBaseConfiguration 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) ... 1 more
NOTE: It works fine when i run it in eclipse but when running on top of hadoop gives this error.
Any help will be highly appreciated.
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/hadoop/hbase/HBaseConfiguration
The missing class will be present in hbase-common-x.y.z.jar
Update the $HADOOP_CLASSPATH with
export HADOOP_CLASSPATH=$HADOOP_CLASSPATH:/usr/local/Hbase/lib/hbase-common-1.2.4.jar
Or,
export HADOOP_CLASSPATH=$HADOOP_CLASSPATH:/usr/local/Hbase/lib/
this will load all the jars under $HBASE_HOME/lib
Make sure $HADOOP_CLASSPATH contains necessary HADOOP libraries. Else, use the below export command in ~/.bashrc
export HADOOP_CLASSPATH=$HADOOP_HOME/share/hadoop/common/:$HADOOP_HOME/share/hadoop/common/lib/:$HADOOP_HOME/share/hadoop/hdfs/:$HADOOP_HOME/share/hadoop/hdfs/lib/:$HADOOP_HOME/share/hadoop/yarn/:$HADOOP_HOME/share/hadoop/yarn/lib/:/usr/local/Hbase/lib/:$CLASSPATH
My glassfish 3.2 embedded was starting with Arquillian and Junit perfectly and now I've getting this Exception in eclipse.
I've replace .m2 repository and it doesn't start.
Anybody could help me:
java.lang.RuntimeException: Could not setup GlassFish Embedded Runtime
Caused by: org.glassfish.embeddable.GlassFishException: A MultiException has 2 exceptions.
1. java.lang.IllegalArgumentException: The scope name given in the descriptor (org.glassfish.hk2.api.PerLookup) did not match the scope annotation on the class (javax.inject.Singleton) in class CommandExecutorImpl
2. java.lang.IllegalArgumentException: Errors were discovered while reifying SystemDescriptor(
implementation=com.sun.enterprise.admin.cli.embeddable.CommandExecutorImpl
contracts={com.sun.enterprise.admin.cli.embeddable.CommandExecutorImpl,org.glassfish.embeddable.CommandRunner
at com.sun.enterprise.glassfish.bootstrap.StaticGlassFishRuntime.newGlassFish(StaticGlassFishRuntime.java:138)
at org.jboss.arquillian.container.glassfish.embedded_3_1.GlassFishContainer.setup(GlassFishContainer.java:138)
... 62 more
I've solved this question deleting all workspace project and eclipse .metadata and RemoteSystemsTempFiles folders, after that I've dowloaded all project with "Checkout Project" and the glassfish-embedded using Junit 4 have started normally.
when I run ant for a Testng application, I am unable to load com.mysql.jdbc.Driver.
Below is the exception thrown.
[testng] java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
[testng] at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
[testng] at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
[testng] at java.security.AccessController.doPrivileged(Native Method)
Thanks and regards,
Sreekanth
The CLASSPATH environment variable is only used by the java.exe command and even then only when used without any of the -cp, -classpath, -jar arguments. It is ignored by IDE's.
That environment variable is in real world also considered a poor practice since it breaks portability. It's only "useful" for Sun to prevent that starters get tired of typing the same classpath again and again in the -cp or -classpath arguments. In real world, batch/shell files are preferred.
If you're using an IDE, The classpath is called the "build path" (it represents both compiletime and runtime classpath). You can configure it in the project's properties. You can add a complete folder, you can add individual/external JAR files, you can link projects, etcetera. Make use of it. Forget the whole CLASSPATH environment variable.
For command prompt,
You have to put the full path to the jarfile in the classpath (including the filename):
.;C:\j2sdk1.4.2_16\jre\lib;
C:\Program Files\mysql-connector-java-3.1.144\mysql-connector-java-3.1.14-bin.jar
As Hippo said, you have to restart cmd after changing that. If it doesn't work, launch your program like this:
java -cp ".;C:\j2sdk1.4.2_16\jre\lib;
C:\Program Files\mysql-connector-java-3.1.144\mysql-connector-java-3.1.14-bin.jar"
my.class.Name
I am trying to run a single JUnit test from the command line but I am getting an error.
I could compile the JUnit test successfully and the class file gets created in the correct location.
But when I try to run it using:
C:\Program Files\Java\jdk1.7.0_01\bin>java org.junit.runner.JUnitCore C:\eclipse\eclipse-java-helios-SR1-win32\eclipse\JunitWS\SeleniumTraining\src\com\org\tests\Nav.class
I get the error:
JUnit version 4.8.1
Could not find class: C:\eclipse\eclipse-java-helios-SR1-win32\eclipse\JunitWS\SeleniumTraining\src\com\org\tests\Nav.class
Exception in thread "main" java.lang.NoClassDefFoundError: org/hamcrest/SelfDesc
ribbing
I don’t know why it is not able to find the class even though it exists in the said location.
You need to specify the name of the class on the command line, not the filename:
java org.junit.runner.JUnitCore com.org.tests.Nav
From the javadoc for JUnitCore:
JUnitCore is a facade for running tests. It supports running JUnit 4
tests, JUnit 3.8.x tests, and mixtures. To run tests from the command
line, run java org.junit.runner.JUnitCore TestClass1 TestClass2 ....
For one-shot test runs, use the static method runClasses(Class[]). If
you want to add special listeners, create an instance of
org.junit.runner.JUnitCore first and use it to run the tests.
and you will have to add the bin directory (note NOT the src) to the classpath of the command line as well. This may look like:
java -cp C:\eclipse\eclipse-java-helios-SR1-win32\eclipse\JunitWS\SeleniumTraining\bin org.junit.runner.JUnitCore com.org.tests.Nav
I have started to look at Hudson as a replacement for CruiseControl. I would like to use it to monitor external jobs as well. I have tried to follow the advice on this page: Monitoring External Jobs
When I run this command:
java -jar hudson-core-1.309.jar
I get this error:
Exception in thread "main" java.lang.NoClassDefFoundError: javax/servlet/http/HttpServletRequest
at hudson.EnvVars.initMaster(EnvVars.java:197)
at hudson.EnvVars.(EnvVars.java:192)
at hudson.Main.getHudsonHome(Main.java:71)
at hudson.Main.run(Main.java:61)
at hudson.Main.main(Main.java:53)
Caused by: java.lang.ClassNotFoundException: javax.servlet.http.HttpServletRequest
Add servlet.jar to the executing classpath. hudson-core-1.309.jar is built to run in a web container and thus doesn't have that included.