Java XMPP clint with smack 4.1 NoClassDefFoundError: - eclipse

I am trying to write XMPP Clint using smack 4.1.1. I have added smack jar files into build path. I am using eclipse IDE to write the code.
However, when I am trying to run application I get NoClassDefFoundErrors. I fixed some of these errors adding xpp3, jxmpp and minidns jar files into the build path. Yet, I am getting the following error.
Exception in thread "main" java.lang.NoClassDefFoundError: org/jxmpp/util/cache/ExpirationCache
at org.jivesoftware.smack.util.dns.minidns.MiniDnsResolver.<clinit>(MiniDnsResolver.java:46)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:274)
at org.jivesoftware.smack.SmackInitialization.loadSmackClass(SmackInitialization.java:213)
at org.jivesoftware.smack.SmackInitialization.parseClassesToLoad(SmackInitialization.java:193)
at org.jivesoftware.smack.SmackInitialization.processConfigFile(SmackInitialization.java:163)
at org.jivesoftware.smack.SmackInitialization.processConfigFile(SmackInitialization.java:148)
at org.jivesoftware.smack.SmackInitialization.<clinit>(SmackInitialization.java:116)
at org.jivesoftware.smack.SmackConfiguration.getVersion(SmackConfiguration.java:96)
at org.jivesoftware.smack.ConnectionConfiguration.<clinit>(ConnectionConfiguration.java:38)
at JabberSmackAPI.login(JabberSmackAPI.java:29)
at JabberSmackAPI.main(JabberSmackAPI.java:76)
Caused by: java.lang.ClassNotFoundException: org.jxmpp.util.cache.ExpirationCache
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
... 12 more
How to fix this issue?
In the internet, it is advised to use gradle or maven for building the same. If so, can you help me how to use the same? I have never used them before.

As per below stack trace
Caused by: java.lang.ClassNotFoundException: org.jxmpp.util.cache.ExpirationCache
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
It seem You are missing jxmpp-util-cache-0.5.0-alpha2.jar in your class path. Download and add this jar to your lib/ directory of your application .
In the internet, it is advised to use gradle or maven for building the
same. If so, can you help me how to use the same?
Create a meven project in eclipse .If you are new to meven project refer
How to create a Java project with Maven
And add Below dependencies to pom.xml of your meven build project
<dependency>
<groupId>org.igniterealtime.smack</groupId>
<artifactId>smack-java7</artifactId>
<version>4.1.0</version>
</dependency>
<dependency>
<groupId>org.igniterealtime.smack</groupId>
<artifactId>smack-tcp</artifactId>
<version>4.1.0</version>
</dependency>
<dependency>
<groupId>org.igniterealtime.smack</groupId>
<artifactId>smack-im</artifactId>
<version>4.1.0</version>
</dependency>
<dependency>
<groupId>org.igniterealtime.smack</groupId>
<artifactId>smack-extensions</artifactId>
<version>4.1.0</version>
</dependency>
For more details refer this link

Related

Not able to connect to Redshift server using postgresql or redshift driver

I have a code which connects to redshift server and gets some table entry. When I run it locally it works fine. But when I build it as a jar and run it on hadoop then I am getting this exception :
java.lang.ClassNotFoundException: org.postgresql.Driver
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
at java.lang.Class.forName0(Native Method)
I have added this in my pom.xml :
<dependency>
<groupId>postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>9.1-901-1.jdbc4</version>
</dependency>
I have also added the jar file location in HADOOP_CLASSPATH variable in hadoop-env.sh.
Is there something I am missing?
Thanks.
I changed the location of my jar and it is working now. I still don't understand why it was not picking up the jar from previous path.

Including nonfree module in eclipse openCV 3.0 project

I want to use some functionality from nonfree library so I added javacv to my maven project and I have installed opencv_contrib package.
<dependency>
<groupId>org.bytedeco</groupId>
<artifactId>javacv</artifactId>
<version>1.1</version>
</dependency>
As a result I have opencv_xfeatures2d.class as a part of opencv-3.0.0-1.1.jar library.
I have following import:
import static org.bytedeco.javacpp.opencv_xfeatures2d.*;
in my project. The library is added properly because following
SURF surf = new SURF();
line (ctrl + left mouse button) it redirects me to proper function inside opencv_xfeatures2d file. But when I try to compile project I get following error:
Exception in thread "main" java.lang.UnsatisfiedLinkError: no
jniopencv_xfeatures2d in java.library.path at
java.lang.ClassLoader.loadLibrary(ClassLoader.java:1864) at
java.lang.Runtime.loadLibrary0(Runtime.java:870) at
java.lang.System.loadLibrary(System.java:1122) at
org.bytedeco.javacpp.Loader.loadLibrary(Loader.java:597) at
org.bytedeco.javacpp.Loader.load(Loader.java:438) at
org.bytedeco.javacpp.Loader.load(Loader.java:381) at
org.bytedeco.javacpp.opencv_xfeatures2d.(opencv_xfeatures2d.java:19)
at java.lang.Class.forName0(Native Method) at
java.lang.Class.forName(Class.java:348) at
org.bytedeco.javacpp.Loader.load(Loader.java:413) at
org.bytedeco.javacpp.Loader.load(Loader.java:381) at
org.bytedeco.javacpp.opencv_xfeatures2d$SURF.(opencv_xfeatures2d.java:489)
at mypr.rec.Clsm.Cmpr(Clsm.java:18) at
mypr.mn.Main.main(Main.java:21) Caused by:
java.lang.UnsatisfiedLinkError:
/tmp/javacpp8449996504597/libjniopencv_xfeatures2d.so:
/usr/local/lib/libopencv_calib3d.so.3.0: undefined symbol:
ippicvJumpIndexForMergedLibs at
java.lang.ClassLoader$NativeLibrary.load(Native Method) at
java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1938) at
java.lang.ClassLoader.loadLibrary(ClassLoader.java:1821) at
java.lang.Runtime.load0(Runtime.java:809) at
java.lang.System.load(System.java:1086) at
org.bytedeco.javacpp.Loader.loadLibrary(Loader.java:580) ... 10 more
The strange thing is that it says about jniopencv_xfeatures2d instead of opencv_xfeatures2d. What am I doing wrong?

Not able to insert data using MongoTemplate of Spring data MongoDB

``I am getting the following exception while instantiatingthg mongoTemplate
Exception in thread "main" java.lang.NoClassDefFoundError: org/springframework/data/mapping/model/FieldNamingStrategy
at org.springframework.data.mongodb.core.MongoTemplate.getDefaultMongoConverter(MongoTemplate.java:1962)
at org.springframework.data.mongodb.core.MongoTemplate.(MongoTemplate.java:210)
at org.springframework.data.mongodb.core.MongoTemplate.(MongoTemplate.java:174)
at com.adobe.ffc.controller.MongoDBTest.createData(MongoDBTest.java:29)
at com.adobe.ffc.controller.MongoDBTest.main(MongoDBTest.java:24)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:134)
Caused by: java.lang.ClassNotFoundException: org.springframework.data.mapping.model.FieldNamingStrategy
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
... 10 more
Process finished with exit code 1
the error is coming from line 1 in the following code :
MongoOperations mongoOps = new MongoTemplate(new Mongo(),"database");
User user = new User();
user.setId("200");
user.setFullName("Mongo Template");
user.setStatus("A");
user.setAge("29");
mongoOps.insert(user);
The pom configration are as follows:
<dependency>
<groupId>org.mongodb</groupId>
<artifactId>mongo-java-driver</artifactId>
<version>2.11.4</version>
</dependency>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-mongodb</artifactId>
<version>1.4.1.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-commons</artifactId>
<version>1.5.0.RELEASE</version>
</dependency>
The problem is mixing Spring Data Release Trains with one another.
spring-data-mongodb 1.4 is part of Release Train Codd that requies to have spring-data-commons 1.7, while spring-data-commons 1.5 which you're currently using was part of the Arora release.
So either downgrade to spring-data-mongodb 1.2 or upgrade to spring-data-commons 1.7. Maybe also have a look at your dependencies and check for potential conflicts.
Sidenote: you can checout the spring data wiki pages to see which versions have been part of a particular release.

NoClassDefFoundError: StoppedByUserException with Eclipse and Quick JUnit

Eclipse with Quick JUnit plugin gives the me following error when I try to run a JUnit test with Ctrl+0:
java.lang.NoClassDefFoundError: org/junit/runner/notification/StoppedByUserException
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader.createTest(JUnit4TestLoader.java:48)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader.loadTests(JUnit4TestLoader.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:452)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
Caused by: java.lang.ClassNotFoundException: org.junit.runner.notification.StoppedByUserException
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:423)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
... 6 more
JUnit is in the pom.xml:
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.9</version>
<scope>test</scope>
</dependency>
...
</dependencies>
Installing the m2e - Maven Integration for Eclipse plugin (which disappeared during a previous Eclipse upgrade) fixed the error.
I solved by installing Ive DE. The problem was basically dependencies not being resolved.
I did not notice until running Junit as the project was already compiled with an older eclipse.
I found this may be due to opening an eclipse mars workspace with eclipse luna. I did that and couldn't get it to work until i remembered that I had updated eclipse but not the link to eclipse. opening with eclipse mars all unit tests worked again.

java.lang.NoClassDefFoundError: com/jogamp/common/type/WriteCloneable jogl 2 in eclipse

I am on windows 7 64 bit and using eclipse indigo. I downloaded the latest version of jogl 2 and i have created an eclipse project following this link
https://sites.google.com/site/justinscsstuff/jogl-tutorial-2
this tutorial is old as the jars in the jogl download dont match and i have included all the jars and for each jar set the native libraries directory. I have written a small jogl test program that creates a GLProfile, GlCapabilities and an awt frame. I get this exception:
java.lang.NoClassDefFoundError: com/jogamp/common/type/WriteCloneable
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClassCond(ClassLoader.java:632)
at java.lang.ClassLoader.defineClass(ClassLoader.java:616)
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:307)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClassCond(ClassLoader.java:632)
at java.lang.ClassLoader.defineClass(ClassLoader.java:616)
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:307)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
Caused by: java.lang.ClassNotFoundException: com.jogamp.common.type.WriteCloneable
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:307)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
... 24 more
Exception in thread "main"
seems like im missing a jar..could any let me know what im doing wrong here?
I am using the jogl-all.jar from Matlab 2014a. The error above disappeared and everything run smoothly when I added the library glugen-rt.jar.
(remember also to -Djava.library.path=/path/to/native/files when you execute your application, in my case this was -Djava.library.path=/Applications/MATLAB_R2014a.app/bin/maci64)
Try to add gluegen as well.
For example
<dependency>
<groupId>org.jogamp.jogl</groupId>
<artifactId>jogl-all</artifactId>
<version>2.0-rc11</version>
</dependency>
AND
<dependency>
<groupId>org.jogamp.gluegen</groupId>
<artifactId>gluegen-rt-main</artifactId>
<version>2.0-rc11</version>
</dependency>
I had a similar problem with the JOGL jar files. See here. Also, check out the tutorials on the jogamp wiki (by the looks of it Wade is pretty active on the wiki).