ClassNotFoundException with SIGAR API - classnotfoundexception

I'm trying to work with the SIGAR API, and I added the external jar "sigar.jar" to my Build Path eclipse project.
It compiles with no problem, but when I try to run the main class, that only does :
Cpu cpu = new Cpu();
it gives me this error:
[java] Exception in thread "main" java.lang.NoClassDefFoundError: org/hyperic/sigar/Cpu
[java] at pt.client.User.main(User.java:90)
[java] Caused by: java.lang.ClassNotFoundException: org.hyperic.sigar.Cpu
[java] at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
[java] at java.security.AccessController.doPrivileged(Native Method)
[java] at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
[java] at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
[java] at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
[java] at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
[java] ... 1 more
[java] Java Result: 1
What may be missing?

I think you missed to include .so file specific for your platform.
These files are located ../hyperic-sigar-folder/sigar-bin/lib.
For example, if you are running under Linux 32 Bit, you have to include the file libsigar-x86-linux.so into your class-path as well.

Related

Jitsi include external jar for customization

Currently I am working on customization of Open Source Jitsi. And Somehow, I want to add 3rd party jar for customization.
I tried a lot to include 3rd party jar but I am facing this error.
So please help me to get rid of this error or provide some guidance to add 3rd party jar .
Auto-properties install: reference:file:sc-bundles/commons-vfs2-2.0.jar (org.osgi.framework.BundleException: Unable to cache bundle: reference:file:sc-bundles/commons-vfs2-2.0.jar - java.io.IOException: Referenced file does not exist: sc-bundles\commons-vfs2-2.0.jar)
[java] org.osgi.framework.BundleException: Unable to cache bundle: reference:file:sc-bundles/commons-vfs2-2.0.jar
[java] at org.apache.felix.framework.Felix.installBundle(Felix.java:2876)
[java] at org.apache.felix.framework.BundleContextImpl.installBundle(BundleContextImpl.java:165)
[java] at org.apache.felix.main.AutoProcessor.processAutoProperties(AutoProcessor.java:296)
[java] at org.apache.felix.main.AutoProcessor.process(AutoProcessor.java:79)
[java] at org.apache.felix.main.Main.main(Main.java:292)
[java] at net.java.sip.communicator.launcher.SIPCommunicator.main(SIPCommunicator.java:219)
[java] Caused by: java.io.IOException: Referenced file does not exist: sc-bundles\commons-vfs2-2.0.jar
[java] at org.apache.felix.framework.cache.BundleArchive.createRevisionFromLocation(BundleArchive.java:852)
[java] at org.apache.felix.framework.cache.BundleArchive.reviseInternal(BundleArchive.java:550)
[java] at org.apache.felix.framework.cache.BundleArchive.<init>(BundleArchive.java:153)
[java] at org.apache.felix.framework.cache.BundleCache.create(BundleCache.java:277)
[java] at org.apache.felix.framework.Felix.installBundle(Felix.java:2872)
[java] ... 5 more
Add your JAR file (custom.jar) to the lib/ directory. Then edit the two files as indicated below:
jitsi.eml - Add the following entry to the file :
<lib name="custom.jar" scope="COMPILE">
<relative-module-cls project-related="jar://$PROJECT_DIR$/lib/custom.jar!/"/>
</lib>
nbproject/project.xml - Search for <classpath mode="compile"> (there are two such occurences) and enlist your jar file as
<classpath mode="compile">lib/custom.jar:lib/felix.jar:[MORE JARS HERE]</classpath>
and
<classpath mode="compile">classes:lib/custom.jar:lib/felix.jar:[MORE JARS HERE]</classpath>
After editing the files, run ant clean; ant clean-bundles; ant make
And you are good to go.

Caused by: org.sonar.api.utils.SonarException: No license for objc

I am trying to set up Sonar qube for my XCode project on my mac.
I have done the set up and trying to execute sonar-runner command. I am receiving error Caused by: org.sonar.api.utils.SonarException: No license for objc
Below is stacktrace:
INFO: ------------------------------------------------------------------------
INFO: EXECUTION FAILURE
INFO: ----------------------------------------------------------------- -------
Total time: 2.692s
Final Memory: 12M/301M
INFO: ------------------------------------------------------------------------
ERROR: Error during Sonar runner execution
org.sonar.runner.impl.RunnerException: Unable to execute Sonar
at org.sonar.runner.impl.BatchLauncher$1.delegateExecution(BatchLauncher.java:91)
at org.sonar.runner.impl.BatchLauncher$1.run(BatchLauncher.java:75)
at java.security.AccessController.doPrivileged(Native Method)
at org.sonar.runner.impl.BatchLauncher.doExecute(BatchLauncher.java:69)
at org.sonar.runner.impl.BatchLauncher.execute(BatchLauncher.java:50)
at org.sonar.runner.api.EmbeddedRunner.doExecute(EmbeddedRunner.java:102)
at org.sonar.runner.api.Runner.execute(Runner.java:100)
at org.sonar.runner.Main.executeTask(Main.java:70)
at org.sonar.runner.Main.execute(Main.java:59)
at org.sonar.runner.Main.main(Main.java:53)
Caused by: org.sonar.api.utils.SonarException: No license for objc
at com.A.A.A.B.B.A(Unknown Source)
at com.A.A.A.B.B.A(Unknown Source)
at com.A.A.A.B.H.A(Unknown Source)
at com.A.A.A.B.H.A(Unknown Source)
at com.A.A.A.B.I.B(Unknown Source)
at com.A.A.A.B.I.onSensorsPhase(Unknown Source)
at org.sonar.batch.phases.SensorsPhaseEvent.dispatch(SensorsPhaseEvent.java:44)
at org.sonar.batch.phases.SensorsPhaseEvent.dispatch(SensorsPhaseEvent.java:27)
at org.sonar.batch.events.EventBus.doFireEvent(EventBus.java:49)
at org.sonar.batch.events.EventBus.fireEvent(EventBus.java:43)
at org.sonar.batch.phases.SensorsExecutor.execute(SensorsExecutor.java:47)
at org.sonar.batch.phases.PhaseExecutor.execute(PhaseExecutor.java:98)
at org.sonar.batch.scan.ModuleScanContainer.doAfterStart(ModuleScanContainer.java:192)
at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:100)
at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:85)
at org.sonar.batch.scan.ProjectScanContainer.scan(ProjectScanContainer.java:258)
at org.sonar.batch.scan.ProjectScanContainer.scanRecursively(ProjectScanContainer.java:253)
at org.sonar.batch.scan.ProjectScanContainer.doAfterStart(ProjectScanContainer.java:243)
at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:100)
at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:85)
at org.sonar.batch.bootstrap.GlobalContainer.executeAnalysis(GlobalContainer.java:153)
at org.sonar.batch.bootstrapper.Batch.executeTask(Batch.java:110)
at org.sonar.batch.bootstrapper.Batch.execute(Batch.java:76)
at org.sonar.runner.batch.IsolatedLauncher.execute(IsolatedLauncher.java:48)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at org.sonar.runner.impl.BatchLauncher$1.delegateExecution(BatchLauncher.java:87)
... 9 more
Any help?
You have apparently installed the C/C++, Objective-C plugin, and you have .m files in your project. Since the C-Family plugin registers .m files as belonging to the Objective-C language, and those files are included in the analysis, you're inherently trying to use functionality you don't have a license for. You'll need to do one of the following:
obtain a license
remove the plugin from your SonarQube instance and restart it
remove the .m files from your project
remove .m from the extensions mapped to Objective-C (Administration > General Settings > C / C++ / Objective-C > Objective-C > Objective-C File Suffixes) . Since .m is the default value; you'll have to accomplish this by filling in nonsense.

Xcode: Cannot load JDBC driver class 'org.h2.Driver'

I'm using sonar-runner 2.4 with JDK 1.8 to build a sonar report on OSX.
It fails with the error Cannot load JDBC driver class 'org.h2.Driver'
Here's the full stack trace:
SonarQube Runner 2.4
Java 1.8.0_60 Oracle Corporation (64-bit)
Mac OS X 10.10.5 x86_64
INFO: Error stacktraces are turned on.
INFO: Runner configuration file: /...../External/Sonar/sonar-runner/conf/sonar-runner.properties
INFO: Project configuration file: NONE
INFO: Default locale: "en_US", source code encoding: "UTF-8" (analysis is platform dependent)
INFO: Work directory: /...../External/Sonar/sonar-runner/bin/./.sonar
INFO: SonarQube Server 5.1
21:43:38.350 INFO - Load global repositories
21:43:39.809 INFO - Load global repositories (done) | time=1459ms
21:43:39.810 INFO - Server id: 20150902220143
21:43:39.811 INFO - User cache: /Users/...../.sonar/cache
21:43:39.818 INFO - Install plugins
21:43:40.541 INFO - Install JDBC driver
21:43:41.034 INFO - Create JDBC datasource for jdbc:h2:tcp://localhost/sonar
INFO: ------------------------------------------------------------------------
INFO: EXECUTION FAILURE
INFO: ------------------------------------------------------------------------
Total time: 5.062s
Final Memory: 11M/245M
INFO: ------------------------------------------------------------------------
ERROR: Error during Sonar runner execution
org.sonar.runner.impl.RunnerException: Unable to execute Sonar
at org.sonar.runner.impl.BatchLauncher$1.delegateExecution(BatchLauncher.java:91)
at org.sonar.runner.impl.BatchLauncher$1.run(BatchLauncher.java:75)
at java.security.AccessController.doPrivileged(Native Method)
at org.sonar.runner.impl.BatchLauncher.doExecute(BatchLauncher.java:69)
at org.sonar.runner.impl.BatchLauncher.execute(BatchLauncher.java:50)
at org.sonar.runner.api.EmbeddedRunner.doExecute(EmbeddedRunner.java:102)
at org.sonar.runner.api.Runner.execute(Runner.java:100)
at org.sonar.runner.Main.executeTask(Main.java:70)
at org.sonar.runner.Main.execute(Main.java:59)
at org.sonar.runner.Main.main(Main.java:53)
Caused by: java.lang.IllegalStateException: Fail to connect to database
at org.sonar.core.persistence.DefaultDatabase.start(DefaultDatabase.java:77)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at org.picocontainer.lifecycle.ReflectionLifecycleStrategy.invokeMethod(ReflectionLifecycleStrategy.java:110)
at org.picocontainer.lifecycle.ReflectionLifecycleStrategy.start(ReflectionLifecycleStrategy.java:89)
at org.picocontainer.injectors.AbstractInjectionFactory$LifecycleAdapter.start(AbstractInjectionFactory.java:84)
at org.picocontainer.behaviors.AbstractBehavior.start(AbstractBehavior.java:169)
at org.picocontainer.behaviors.Stored$RealComponentLifecycle.start(Stored.java:132)
at org.picocontainer.behaviors.Stored.start(Stored.java:110)
at org.picocontainer.DefaultPicoContainer.potentiallyStartAdapter(DefaultPicoContainer.java:1015)
at org.picocontainer.DefaultPicoContainer.startAdapters(DefaultPicoContainer.java:1008)
at org.picocontainer.DefaultPicoContainer.start(DefaultPicoContainer.java:766)
at org.sonar.api.platform.ComponentContainer.startComponents(ComponentContainer.java:91)
at org.sonar.batch.bootstrapper.Batch.start(Batch.java:81)
at org.sonar.batch.bootstrapper.Batch.execute(Batch.java:67)
at org.sonar.runner.batch.IsolatedLauncher.execute(IsolatedLauncher.java:48)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at org.sonar.runner.impl.BatchLauncher$1.delegateExecution(BatchLauncher.java:87)
... 9 more
Caused by: org.apache.commons.dbcp.SQLNestedException: Cannot load JDBC driver class 'org.h2.Driver'
at org.apache.commons.dbcp.BasicDataSource.createConnectionFactory(BasicDataSource.java:1429)
at org.apache.commons.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:1371)
at org.apache.commons.dbcp.BasicDataSource.getLogWriter(BasicDataSource.java:1098)
at org.apache.commons.dbcp.BasicDataSourceFactory.createDataSource(BasicDataSourceFactory.java:350)
at org.sonar.core.persistence.DefaultDatabase.initDatasource(DefaultDatabase.java:103)
at org.sonar.core.persistence.DefaultDatabase.start(DefaultDatabase.java:72)
... 31 more
Caused by: java.lang.ClassNotFoundException: org.h2.Driver
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at org.apache.commons.dbcp.BasicDataSource.createConnectionFactory(BasicDataSource.java:1420)
... 36 more
It somehow looks like I need to install H2, but I have not been able to find out how and trial and error did not succeed.

Run a maven test-jar file for GroovyTestCase (junit)

I have a maven project that contains 30 GroovyTestCase 'junit' test classes. I was able to generate the test-jar file that contains all the test classes, using http://maven.apache.org/guides/mini/guide-attached-tests.html . However, every time I try to run the jar file using the following command:
java -cp target/groovy-tests-1.0-SNAPSHOT-tests.jar com.mycompany.TestClass
I get the following error:
Exception in thread "main" java.lang.NoClassDefFoundError: groovy/lang/GroovyObject
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClassCond(ClassLoader.java:631)
at java.lang.ClassLoader.defineClass(ClassLoader.java:615)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:283)
at java.net.URLClassLoader.access$000(URLClassLoader.java:58)
at java.net.URLClassLoader$1.run(URLClassLoader.java:197)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
Caused by: java.lang.ClassNotFoundException: groovy.lang.GroovyObject
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
... 12 more
I have been struggling to find a way to generate the jar file so I can run all tests without the maven project.
Please let me know if there is another way to generate the jar file...

NoClassDefFoundError while installing Mondrian on Mac

I am trying to install Mondrian on my Mac OS X. I am facing the below error at step 12 of this guide
Command is as below :-
java -cp “/usr/local/tomcat/webapps/mondrian/WEB-INF/lib/mondrian.jar: /usr/local/tomcat/webapps/mondrian/WEB-INF/lib/log4j-1.2.9.jar: /usr/local/tomcat/webapps/mondrian/WEB-INF/lib/eigenbase-xom.jar: /usr/local/tomcat/webapps/mondrian/WEB-INF/lib/eigenbase-resgen.jar: /usr/local/tomcat/webapps/mondrian/WEB-INF/lib/eigenbase-properties.jar: /usr/local/tomcat/webapps/mondrian/WEB-INF/lib/mysql-connector-java-5.1.5-bin.jar” mondrian.test.loader.MondrianFoodMartLoader -verbose -tables -data -indexes -jdbcDrivers=com.mysql.jdbc.Driver -inputFile=/usr/local/mondrian/demo/FoodMartCreateData.sql -outputJdbcURL=”jdbc:mysql://localhost/foodmart?user=foodmart&password=foodmart”
The error is as below :-
Exception in thread "main" java.lang.NoClassDefFoundError: /usr/local/tomcat/webapps/mondrian/WEB-INF/lib/log4j-1/2/9/jar:
Caused by: java.lang.ClassNotFoundException: .usr.local.tomcat.webapps.mondrian.WEB-INF.lib.log4j-1.2.9.jar:
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
Do you have log4j jar in your /usr/local/tomcat/webapps/mondrian/WEB-INF/lib/ folder? Cause the class loader id not able to find log4j that you have mentioned in your class path.

Resources