I am trying to understand the Apache Flink CEP program to monitor rack temperatures in a data center as described by Flink Official Documentation. But when I follow the steps and create a jar using mvn clean package and tried to execute the package using the command
java -cp "../cep-monitoring-1.0.jar" org.stsffap.cep.monitoring.CEPMonitoring
But I get the following error,
Error: A JNI error has occurred, please check your installation and try again
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/flink/streaming/api/functions/source/SourceFunction
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Class.java:2701)
at java.lang.Class.privateGetMethodRecursive(Class.java:3048)
at java.lang.Class.getMethod0(Class.java:3018)
at java.lang.Class.getMethod(Class.java:1784)
at sun.launcher.LauncherHelper.validateMainClass(LauncherHelper.java:544)
at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:526)
Caused by: java.lang.ClassNotFoundException: org.apache.flink.streaming.api.functions.source.SourceFunction
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:335)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 7 more
I tried different variations of giving the classpath as described here but getting the same error. Can someone point out my mistake in running the program?
To submit a job to the local Flink cluster:
Run Flink.
/path/to/flink-1.4.0/bin/start-local.sh
Submit the job.
/path/to/flink-1.4.0/bin/flink run -c com.package.YourClass /path/to/jar.jar
Alternatively you can run the job simply from your IDE:
Your job in this case will be run in a Flink environement.
Check Flink's example: https://github.com/apache/flink/blob/master/flink-examples/flink-examples-streaming/src/main/java/org/apache/flink/streaming/examples/wordcount/WordCount.java
The cep example uses flink version 1.3.2. So here are the steps to run it.
Install version 1.3.2 of apache flink. (wget it from here and extract it).
cd into flink-1.3.2
./bin/start-local.sh, this will start the flink cluster. Do cd ...
Clone this repo using git clone and cd into that.
mvn clean package to build the project. This will create target directory.
Run ../flink-1.3.2/bin/flink run target/cep-monitoring-1.0.jar, to start the process.
In separate terminal the output can be logged like this (assuming that you are in same directory as previous step) tail -f ../flink-1.3.2/log/flink-*-jobmanager-*.out (* will be replaced by specific user detail, press tab to autocomplete those).
Here is the sample output,
rshah9#bn18-20:~/tools/cep-monitoring-master$ tail -f ../flink-1.3.2/log/flink-rshah9-jobmanager-0-bn18-20.dcs.mcnc.org.out
TemperatureWarning(9, 102.45860162626161)
TemperatureWarning(6, 113.21295716135027)
TemperatureWarning(5, 105.46064102697723)
TemperatureWarning(0, 106.44635415722034)
TemperatureWarning(4, 112.07396748089734)
TemperatureWarning(9, 114.53346561628322)
TemperatureWarning(3, 109.05305417712648)
TemperatureWarning(7, 112.3698094257147)
TemperatureWarning(3, 107.78609416982076)
TemperatureWarning(9, 107.34373990230458)
TemperatureWarning(5, 111.46480675461656)
Related
I have a spring boot project, which I am able to run from command line. mean below two command are running fine.
mvn clean package -Dmaven.test.skip=true
java -jar target/Data-Project.jar
I have import projects in IntelliJ like I am doing in other projects but in this project when I run it throwing below error.
Error: A JNI error has occurred, please check your installation and try again
Exception in thread "main" java.lang.NoClassDefFoundError: javax/servlet/Filter
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Class.java:2701)
at java.lang.Class.privateGetMethodRecursive(Class.java:3048)
at java.lang.Class.getMethod0(Class.java:3018)
at java.lang.Class.getMethod(Class.java:1784)
at sun.launcher.LauncherHelper.validateMainClass(LauncherHelper.java:544)
at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:526)
Caused by: java.lang.ClassNotFoundException: javax.servlet.Filter
The IntelliJ's configuration is correct as I have done many projects in IntelliJ. I have try lot of search and tried many things but its not working.
I am stuck here, please get me out.
I have built a Java 1.8 application under Maven in Eclipse that allows me to generate BIRT reports in a programmatic way without the need for the UI. Within Eclipse everything works fine. If I compile the code into a JAR file and try to run it however I run into problems with java.lang.NoClassDefFoundErrors. Clearly I have a missing dependancy but I don't know how to resolve the problem.
The error is
java -cp target/* com.resonancex.scheduler.Scheduler
Establishing conection...
Connected
Got products to report
ProductId=1 ProductType=BREN Isin=XS1939207996 Template=BREN_MU
* birtEngine EngineConfig: org.eclipse.birt.report.engine.api.EngineConfig.emitterConfigs={html=org.eclipse.birt.report.engine.api.HTMLEmitterConfig#71bbf57e};
* Birt Engine Startring ....
Exception in thread "main" java.lang.NoClassDefFoundError: org/eclipse/core/runtime/CoreException
at org.eclipse.birt.core.framework.Platform.createPlatformLauncher(Platform.java:115)
at org.eclipse.birt.core.framework.Platform.startup(Platform.java:74)
at com.resonancex.scheduler.BirtEngine.start(BirtEngine.java:33)
at com.resonancex.scheduler.BirtEngine.getBirtEngine(BirtEngine.java:47)
at com.resonancex.scheduler.BIRTReportGenerator.setReportCustom(BIRTReportGenerator.java:67)
at com.resonancex.scheduler.Scheduler.generateAllReports(Scheduler.java:68)
at com.resonancex.scheduler.Scheduler.main(Scheduler.java:79)
Caused by: java.lang.ClassNotFoundException: org.eclipse.core.runtime.CoreException
at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
I added the library org.eclipse.birt.runtime_4.8.0-20180626-4.8.0 which appears to be the required BIRT runtime. Can anyone give me a few pointers as to what else I may need?
Just in case anyone else tries to do this I thought I would list the libraries I needed to install to get standalone BIRT report generation running running. The list is as follows. Obviously this list may change over time so keep that in mind:
axis-1.4.jar
batik-anim-1.7.jar
batik-awt-util-1.7.jar
batik-bridge-1.7.jar
batik-css-1.7.jar
batik-dom-1.7.jar
batik-gvt-1.7.jar
batik-i18n-1.9.jar
batik-parser-1.7.jar
batik-script-1.7.jar
batik-svg-dom-1.7.jar
batik-transcoder-1.7.jar
batik-util-1.8.jar
batik-xml-1.7.jar
hibernate-agroal-5.4.9.Final.jar
icu4j-4.8.jar
itext-2.1.7.jar
mssql-jdbc-7.4.1.jre8.jar
org.apache.batik.css-1.6.0.jar
org.eclipse.birt.runtime_4.8.0-20180626-4.8.0.jar
org.eclipse.core.runtime_3.14.0.v20180417-0825-4.8.0.jar
org.eclipse.datatools.connectivity.oda-3.5.0.201603142002.jar
org.eclipse.datatools.connectivity.oda.consumer-3.3.0.201603142002.jar
org.eclipse.emf.common-2.16.0.jar
org.eclipse.emf.ecore-2.11.1.jar
org.eclipse.emf.ecore.xmi-2.11.1.jar
org.eclipse.equinox.common_3.10.0.v20180412-1130-4.8.0.jar
org.eclipse.equinox.registry_3.8.0.v20180426-1327-4.8.0.jar
org.eclipse.osgi_3.13.0.v20180409-1500-4.8.0.jar
org.mozilla.javascript-1.7.5.v201504281450.jar
org.w3c.dom.smil_1.0.1.v200903091627-4.8.0.jar
org.w3c.dom.svg-1.1.0.jar
sac-1.3.jar
xml-apis-1.4.01.jar
Since StackExchange advised me to not ask for help or clarification on a previously existing post, I am making a new thread.
On Windows 10x64 I downloaded the Eclipse SWT (in second-to-last section of Downloads page), set my ANDROID_SWT environment variable to <download location>\swt.jar, and have attempted to run uiautomatorviewer from cmd again, only to receive the same error message as when I tried to use the SWT bundled with eclipse:
Error: A JNI error has occurred, please check your installation and try again
Exception in thread "main" java.lang.NoClassDefFoundError: org/eclipse/swt/widgets/Listener
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Class.java:2701)
at java.lang.Class.privateGetMethodRecursive(Class.java:3048)
at java.lang.Class.getMethod0(Class.java:3018)
at java.lang.Class.getMethod(Class.java:1784)
at sun.launcher.LauncherHelper.validateMainClass(LauncherHelper.java:544)
at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:526)
Caused by: java.lang.ClassNotFoundException: org.eclipse.swt.widgets.Listener
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 7 more
Has anyone else encountered this error, and if so, what was the root cause?
Thanks in advance for your time and help!
In my case adding ANDROID_SWT to environment variables or editing PATH didn't solve the problem. Therefore I found a different solution via help from this question.
Running uiautomatorviewer.bat and output :
Error: A JNI error has occurred, please check your installation and try again
Exception in thread "main" java.lang.NoClassDefFoundError: org/eclipse/swt/widgets/Control
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Class.java:2701)
at java.lang.Class.privateGetMethodRecursive(Class.java:3048)
at java.lang.Class.getMethod0(Class.java:3018)
at java.lang.Class.getMethod(Class.java:1784)
at sun.launcher.LauncherHelper.validateMainClass(LauncherHelper.java:650)
at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:632)
Caused by: java.lang.ClassNotFoundException: org.eclipse.swt.widgets.Listener
at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
at java.lang.ClassLoader.loadClass(ClassLoader.java:418)
at java.lang.ClassLoader.loadClass(ClassLoader.java:351)
Solution :
Go to : https://www.findjar.com/ and search for missing class.
In this case search for class :
org.eclipse.swt.widgets.Control
For your case it is:
org.eclipse.swt.widgets.Listener
Names of the classes in the error can change, but all the classes needed comes from .jar file that will be downloaded.
In the results click :
[CLASS] org.eclipse.swt.widgets.Control
or for your case :
[CLASS] org.eclipse.swt.widgets.Listener
Download latest and suitable file for your OS. This was the latest and suitable for Windowsx86_64 currently.
Put downloaded .jar file into :
C:\Users\{userId}\AppData\Local\Android\Sdk\tools\lib
or equivalent path for your OS.
Now uiautomatorviewer.bat should run without any problems.
Make sure JDK location selected in Android studio is same as JDK set in environment variable.
In my case the exception was
Exception in thread "main" java.lang.NoClassDefFoundError:
org/eclipse/swt/custom/TableTreeItem
at org.eclipse.jface.util.OpenStrategy.initializeHandler(OpenStrategy.java:270)
at org.eclipse.jface.util.OpenStrategy.<init>(OpenStrategy.java:108)
at org.eclipse.jface.viewers.StructuredViewer.hookControl(StructuredViewer.java:1213)
at org.eclipse.jface.viewers.ColumnViewer.hookControl(ColumnViewer.java:68)
at org.eclipse.jface.viewers.AbstractTreeViewer.hookControl(AbstractTreeViewer.java:1452)
at org.eclipse.jface.viewers.TreeViewer.hookControl(TreeViewer.java:274)
at org.eclipse.jface.viewers.TreeViewer.<init>(TreeViewer.java:137)
at org.eclipse.jface.viewers.TreeViewer.<init>(TreeViewer.java:124)
at com.android.uiautomator.UiAutomatorView.<init>(UiAutomatorView.java:361)
at com.android.uiautomator.UiAutomatorViewer.createContents(UiAutomatorViewer.java:66)
at org.eclipse.jface.window.Window.create(Window.java:431)
at org.eclipse.jface.window.Window.open(Window.java:790)
at com.android.uiautomator.UiAutomatorViewer.main(UiAutomatorViewer.java:78)
Caused by: java.lang.ClassNotFoundException: org.eclipse.swt.custom.TableTreeItem
at java.net.URLClassLoader.findClass(URLClassLoader.java:387)
at java.lang.ClassLoader.loadClass(ClassLoader.java:418)
at java.lang.ClassLoader.loadClass(ClassLoader.java:351)
... 13 more
Steps followed for the solution
Go to https://jar-download.com/
Search for the missing jar file in my case it was org.eclipse.swt.custom.tabletreeitem
Download the jar file compatible with your system Mac/Win/Linux (In my case it was mac
enter image description here
Extract the jar file and copy it
Go to the lib folder inside SDK (Android/Sdk/Tools/Lib
Paste the jar file into the lib folder
Restart your terminal or cmd
Run the command again for cd $ANDROID_HOME/tools/bin
Run the command ./uiautomatorviewer
Alternatively
Try to download the swt jar file with a different version and copy it to the respective folders.
Follow this thread :
https://github.com/android/android-test/issues/911#issuecomment-849389068
Precisely follow these instructions. I made the mistake of trying to download the Eclipse SWT in order to troubleshoot other issues I was having; setting this different SWT version in the CLASSPATH and ANDROID_SWT environment variables caused this exception.
When following the guide in the storm-starter repo, I'm unable to actually run any topology- like the ExclamationTopology.
mvn clean install -DskipTests=true ran successfully, executed from the top level Storm repo, as did mvn package at the storm-examples level.
When I try to run storm jar target/storm-starter-2.0.0-SNAPSHOT.jar org.apache.storm.starter.ExclamationTopology, I get the error:
Error: A JNI error has occurred, please check your installation and try again
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/storm/topology/IRichSpout
I'm running OS X, Java version:
java version "1.8.0_45"
Java(TM) SE Runtime Environment (build 1.8.0_45-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.45-b02, mixed mode)
Maven version 3.3.9.
Does anyone have any ideas on why I'm getting this error and what I should change in my setup?
Full error output:
Running:
/Library/Java/JavaVirtualMachines/jdk1.8.0_45.jdk/Contents/Home/bin/java -client -Ddaemon.name= -Dstorm.options= -Dstorm.home=/Users/zachary/apache-storm-0.10.0 -Dstorm.log.dir=/Users/zachary/apache-storm-0.10.0/logs -Djava.library.path=/usr/local/lib:/opt/local/lib:/usr/lib -Dstorm.conf.file= -cp /Users/zachary/apache-storm-0.10.0/lib/asm-4.0.jar:/Users/zachary/apache-storm-0.10.0/lib/clojure-1.6.0.jar:/Users/zachary/apache-storm-0.10.0/lib/disruptor-2.10.4.jar:/Users/zachary/apache-storm-0.10.0/lib/hadoop-auth-2.4.0.jar:/Users/zachary/apache-storm-0.10.0/lib/kryo-2.21.jar:/Users/zachary/apache-storm-0.10.0/lib/log4j-api-2.1.jar:/Users/zachary/apache-storm-0.10.0/lib/log4j-core-2.1.jar:/Users/zachary/apache-storm-0.10.0/lib/log4j-over-slf4j-1.6.6.jar:/Users/zachary/apache-storm-0.10.0/lib/log4j-slf4j-impl-2.1.jar:/Users/zachary/apache-storm-0.10.0/lib/minlog-1.2.jar:/Users/zachary/apache-storm-0.10.0/lib/reflectasm-1.07-shaded.jar:/Users/zachary/apache-storm-0.10.0/lib/servlet-api-2.5.jar:/Users/zachary/apache-storm-0.10.0/lib/slf4j-api-1.7.7.jar:/Users/zachary/apache-storm-0.10.0/lib/storm-core-0.10.0.jar:target/storm-starter-2.0.0-SNAPSHOT.jar:/Users/zachary/apache-storm-0.10.0/conf:/Users/zachary/apache-storm-0.10.0/bin -Dstorm.jar=target/storm-starter-2.0.0-SNAPSHOT.jar org.apache.storm.starter.ExclamationTopology
Error: A JNI error has occurred, please check your installation and try again
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/storm/topology/IRichSpout
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Class.java:2701)
at java.lang.Class.privateGetMethodRecursive(Class.java:3048)
at java.lang.Class.getMethod0(Class.java:3018)
at java.lang.Class.getMethod(Class.java:1784)
at sun.launcher.LauncherHelper.validateMainClass(LauncherHelper.java:544)
at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:526)
Caused by: java.lang.ClassNotFoundException: org.apache.storm.topology.IRichSpout
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)
... 7 more
Edit:
After following the suggestions in the answers below of removing the scope line from the pom.xml, this error was gone, but replaced by:
Exception in thread "main" java.lang.ExceptionInInitializerError
Caused by: java.lang.RuntimeException: java.io.IOException: Found multiple defaults.yaml resources. You're probably bundling the Storm jars with your topology jar. [jar:file:/Users/zachary/apache-storm-0.10.0/lib/storm-core-0.10.0.jar!/defaults.yaml, jar:file:/Users/zachary/storm/examples/storm-starter/target/storm-starter-2.0.0-SNAPSHOT.jar!/defaults.yaml]
Final Edit:
For any future googler, I ended up not getting the storm-starterexamples running via the commandline on a LocalCluster. I instead set up a new project with Maven, adding storm-core as a dependency, following [this] (https://github.com/mbonaci/mbo-storm/wiki/Storm-setup-in-Eclipse-with-Maven,-Git-and-GitHub) general guide. Then, in Eclipse, I was able to import the right packages from storm to do the examples, like ExclamationTopology. I rewrote that class using the same imports (changed to import backtype.storm.Config, etc). Then, running the file as is just works.
This quick Maven guide helps too.
To be little bit more precise with regard to Nick's answer.
In storm-starter/pom.xml the dependency storm-core is specified with scope "provided":
<dependency>
<groupId>org.apache.storm</groupId>
<artifactId>storm-core</artifactId>
<version>${project.version}</version>
<!--
Use "provided" scope to keep storm out of the jar-with-dependencies
For IntelliJ dev, intellij will load properly.
-->
<scope>${provided.scope}</scope>
</dependency>
If you run locally using LocalCluster you need to include storm-core as dependency with default scope "compile", ie, just remove the scope tag, and run mvn -DskipTests package in storm-starter again.
NoClassDefFoundError regarding Storm, usually refers to errors coming from the <scope> tag in your pom.xml.
If you are trying to run the project on a cluster of machines where you have installed Storm, the <scope> should be "provided" (<scope>provide</scope>), else if you are trying to execute the topology locally, the scope must be set to "compile".
Hope this helps.
the first time I tried to run storm-starter, I got blocked by the missing pom or some dependencies.
I read the document again. Then I found I should install the storm first from the root directory of project not the storm-starter directory.
scope provided should be fine.
IDE will try to find it from local repository
I too faced the same issue (Initially NoClassDefFoundError later multiple defaults.yaml)
For me following config change in intellij solved the problem.
Run ---> Edit configurations ---> Tick - Include dependencies with "provided" scope.
So basically when you are running in cluster mode, storm-core's scope should be "provided" in pom.xml. And above configuration will ensure that dependencies will be provided from cluster at run-time.
I am using Spoon tool of Pentaho data integration for long and it was working fine on my system. But since i moved it to /opt I am unable to run again . I have Oracle Java 8 installed on my system and each time try to run it i am end up with following exception
Exception in thread "main" java.lang.NoClassDefFoundError: org/eclipse/swt/widgets/Composite
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Class.java:2688)
at java.lang.Class.getMethod0(Class.java:2937)
at java.lang.Class.getMethod(Class.java:1771)
at org.pentaho.commons.launcher.Launcher.main(Launcher.java:149)
Caused by: java.lang.ClassNotFoundException: org.eclipse.swt.widgets.Composite
at java.net.URLClassLoader$1.run(URLClassLoader.java:372)
at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:360)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 5 more
please help me to resolve this error i haven't found any solution yet
I found a solution to this problem I have removed all hidden directories generated by Kettle as well as its copy from /opt . Then I have extracted new version copy . after that I have added /opt/data-integration to my path variable and I have tried to run it from my home . Although it was not a successful run but it has generated all those dependent hidden folders required to run it . then I have to go to that directory by issuing
cd /opt/data-integration
and then I was successful to run it by issuing
sh spoon.sh
I have to go to that directory because Pentaho developers has set it so by placing relative path to launcher folder in their main command at spoon.sh.