classifier4j class not found exception on addMatch() method - java

i have a strange behaviour when trying to use bayesian classifier class from classifier4j package
basically my code is:
String test_string = "some bla bla web designers in here whatever";
SimpleWordsDataSource wds = new SimpleWordsDataSource();
BayesianClassifier classifier = new BayesianClassifier(wds);
wds.addMatch("Web Design")
Double d = classifier.classify(test_string);
what i'm getting when trying to run this code is:
run:
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/logging/LogFactory
at net.sf.classifier4J.bayesian.WordProbability.calculateProbability(WordProbability.java:167)
at net.sf.classifier4J.bayesian.WordProbability.setMatchingCount(WordProbability.java:138)
at net.sf.classifier4J.bayesian.WordProbability.<init>(WordProbability.java:115)
at net.sf.classifier4J.bayesian.SimpleWordsDataSource.addMatch(SimpleWordsDataSource.java:94)
at tothego_classifier_test.Main.main(Main.java:44)
Caused by: java.lang.ClassNotFoundException: org.apache.commons.logging.LogFactory
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)
... 5 more
Java Result: 1
BUILD SUCCESSFUL (total time: 0 seconds)
which is pretty annoying since i've been trying to run a simple hello-world test (as in the website's usage part). I'm on netbeans 6.9 and i've ofc included classifier4j 0.6 jar and optional jar, also have the correct import statements in my main class.
I know Nick Lothian contributes here, so i tought would be good asking!
thanks everybody for efforts

ok i solved the problem, and here we go with a quick howto for everyone:
http://commons.apache.org/logging/download_logging.cgi click on this link and download the binary file
unzip the file you just downloaded
add commons-logging-xxx.jar, commons-logging-adapters.jar, commons-logging-api.jar to your CLASSPATH / project libs (i tried an awful lot, and it only seems to work with the whole jars included)
rebuild and rerun
hope this is helpful :)

Related

Exception in Dynamic Report

Hi I am trying to generate dynamic report in NetBeans7 IDE, java6, glassfish3.2 environment.
I am creating project using java> web application. I used below jars
commons-collections-3.2.1
commons-digester-2.0
dynamicreports-1.3.0
dynamicreports-adhoc-4.0.1
dynamicreports-core-4.0.1
itext-2.1.7
jasperreports-6.1.0
commons-logging-1.2
commons-logging-1.2-javadoc
common-lang3.jar
but I am getting
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/lang/Validate
I investigate the issue and find that
I have to add
1)common-lang3.jar
2)and common-lang3.jar is missing inside WEB-INF>lib ,
I added mentioned jar and
it is also available in WEB-INF>lib.
but still I am facing same issue.
find the below exception while running java file
run:
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/lang/Validate
at net.sf.dynamicreports.report.base.component.DRList.setType(DRList.java:78)
at net.sf.dynamicreports.report.base.component.DRList.<init>(DRList.java:50)
at net.sf.dynamicreports.report.base.DRBand.<init>(DRBand.java:41)
at net.sf.dynamicreports.report.base.DRReport.init(DRReport.java:113)
at net.sf.dynamicreports.report.base.DRReport.<init>(DRReport.java:97)
at net.sf.dynamicreports.report.builder.ReportBuilder.<init>(ReportBuilder.java:60)
at net.sf.dynamicreports.jasper.builder.JasperReportBuilder.<init>(JasperReportBuilder.java:95)
at net.sf.dynamicreports.report.builder.DynamicReports.report(DynamicReports.java:65)
at net.sf.dynamicreports.examples.adhoc.DynamicReporting.main(DynamicReporting.java:20)
Caused by: java.lang.ClassNotFoundException: org.apache.commons.lang.Validate
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)
... 9 more
Java Result: 1
BUILD SUCCESSFUL (total time: 2 seconds)
my code:
public class DynamicReporting{
public static void main(String args[]) throws DRException, FileNotFoundException{
JasperReportBuilder report= DynamicReports.report();
report.toPdf(new FileOutputStream(new File("c:/report.pdf")));
System.out.print("Report generated");
}
}
can any one suggest what I am missing.Thanks in advance
From this dynamicreports-core-4.0.1 in your jar list, I can say that you are using 4.0.1 version, So you do not need dynamicreports-1.3.0 this.
I just downloaded dependencies from below link,
http://sourceforge.net/projects/dynamicreports/files/dynamicreports/4.0.1/
And all you need to run snippet of yours is this list of jars in your project class path,
You can see that this does not match with yours so you are mixing lots diff versions of jar.
Note: All this jars can be found under that links.
If you are using Dynamic Reports 4.1.1 released, you should opt for JasperReports 6.2.2
DynamicReports 4.1.0 released JasperReports 6.2.0,
DynamicReports 4.0.2 released JasperReports 6.1.1
etc.
http://www.dynamicreports.org/news
And the libraries to be added should be as follows. I took the same mistake and solved it by loading these libraries,I hope it helps.
result:

Running jzy3d demos result in ClassNotFoundException

The problem is as follows, during startup of the jzy3d demo ScatterDemo.java :
Exception in thread "main" java.lang.NoClassDefFoundError: javax/media/opengl/GLProfile
at org.jzy3d.chart.Settings.<init>(Settings.java:19)
at org.jzy3d.chart.Settings.getInstance(Settings.java:48)
at org.jzy3d.analysis.AnalysisLauncher.open(AnalysisLauncher.java:18)
at org.jzy3d.analysis.AnalysisLauncher.open(AnalysisLauncher.java:13)
at org.jzy3d.demos.scatter.ScatterDemo.main(ScatterDemo.java:16)
Caused by: java.lang.ClassNotFoundException: javax.media.opengl.GLProfile
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:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 5 more
Java Result: 1
Configuration is NetBeans 7.3.1, jzy3d-api-0.9.1, jzy3d-swt-0.9.1, log4j-1.2.17, gluegen-rt (latest stable), jogl-all (latest stable), JDK1.7
I am aware of the following change (Moving all of javax.media.opengl to com.jogamp.opengl, https://jogamp.org/bugzilla/show_bug.cgi?id=682). I have gone through the usual process of including .jar files into the project.
Project compiles fine, does not run.
My question(s) are: Can I somehow redirect javax.media.opengl.* to com.jogamp.opengl.* ? What is the correct way to resolve this problem?
As you can see here, even the code on the master branch (0.9.2) isn't based on the latest version of JOGL. Please ask Martin Pernollet to make the necessary changes (replace javax.media.* by com.jogamp.*) or do it yourself. You can rebuild Jzy3d to test it with the modifications of the import clauses. This is the correct way of solving this simple problem.

Install and compile JacORB

I was following this tutorial to install JacORB Tutorial. In the last step, when I want to compile it, I got this error
Buildfile: /Users/adm/Downloads/jacorb/build.xml
base-init:
init-properties:
init-path:
init-javac-common:
init-javac-jdk:
init-javac-j2me:
init:
src-check:
BUILD FAILED
/Users/adm/Downloads/jacorb/build.xml:21: Unable to find src files. Is this a binary distribution?
But if I try ant in a demo file it builde successfully. I don't have to do the last step in the tutorial ? The second question is how to excute the build file ? after I builded the hello demo, I tried "jaco build" but I got a java exception
jaco build
Exception in thread "main" java.lang.NoClassDefFoundError: build
Caused by: java.lang.ClassNotFoundException: build
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)
You likely have the binary distribution of JacORB.
Download the source distribution of JacORB instead. On the JacORB Download page, click the link for Full source code.
Or see https://github.com/JacORB/JacORB/ for the official source code.
I would recommend asking questions about JacORB on the jacorb-developer list (http://www.jacorb.org/contact.html)

How to fix ClassPath in Netbeans on Windows

I just restarted java for university and I have a pretty basic program that I need to code. The thing is every time I try to run it, I get a NoClassDefFoundError as follow:
run:
java.lang.NoClassDefFoundError: log120/devoir1/LOG120Devoir1
Caused by: java.lang.ClassNotFoundException: log120.devoir1.LOG120Devoir1
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)
Could not find the main class: log120.devoir1.LOG120Devoir1. Program will exit.
Exception in thread "main" Java Result: 1
BUILD SUCCESSFUL (total time: 0 seconds)
I am using Netbeans 7.0.1 since it was the IDE I was using a couple of years ago to code java. I googled the error and found something about the class path but all the example I found were for LINUX based OS so I am kinda lost as to how to set it right on Windows.
The class does exist, the program did compile, from what I understand this error comes when the JVM tries to run the code and does not find the class.
Anyone can help me with finding the ClassPath on Netbeans 7.0.1 or if it is not the ClassPath finding why this error keeps popping up?
If you're trying to run your own code, setting your classpath is probably barking up the wrong tree. Netbeans should be including your code automatically on the classpath when it tries to run it.
Please describe how you have your code laid out within your project (eg do you have LOG120Devoir1.java in a log120/devoir1 directory?) as well as how you told netbeans that you wanted to run that class as your main method.

google data api for youtube

I'm trying to run the sample program, which comes with Google Data API. I get a runtime error at following line
YouTubeService myService = new YouTubeService("gdataSample-YouTube-1");
The error is the following:
run:
Exception in thread "main" java.lang.NoClassDefFoundError: com/google/common/collect/Maps
at com.google.gdata.wireformats.AltRegistry.<init>(AltRegistry.java:118)
at com.google.gdata.wireformats.AltRegistry.<init>(AltRegistry.java:100)
at com.google.gdata.client.Service.<clinit>(Service.java:532)
at YouTubeReadonlyClient.main(YouTubeReadonlyClient.java:713)
Caused by: java.lang.ClassNotFoundException: com.google.common.collect.Maps
at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
... 4 more
Java Result: 1
BUILD SUCCESSFUL (total time: 0 seconds)
I tried both Google Data API versions 1.35.0 and 1.35.1, and I get the same error in both cases.
Looks like you don't have the collections library in your class path.
It's in the gdata/java/deps directory in the zip file. Include the google-collect-1.0-rc1.jar file in your classpath and you should be fine. (You may also need jsr305.jar - I'm not sure.)
Three little steps:
Download the zip file from
http://www.docjar.com/jar_detail/google-collect-1.0-rc1.jar.html
Extract the zip file
Add the jar to your build path.

Categories

Resources