I have a Dynamic Web Project in Java and I use Jena and D2RQ libraries.
When I start my project as "Java Application", I have this problem:
Exception in thread "main"
java.lang.IncompatibleClassChangeError: Implementing class at
java.lang.ClassLoader.defineClass1(Native Method) at
java.lang.ClassLoader.defineClass(Unknown Source) at
java.security.SecureClassLoader.defineClass(Unknown Source) at
java.net.URLClassLoader.defineClass(Unknown Source) at
java.net.URLClassLoader.access$100(Unknown Source) at
java.net.URLClassLoader$1.run(Unknown Source) at
java.net.URLClassLoader$1.run(Unknown Source) at
java.security.AccessController.doPrivileged(Native Method) at
java.net.URLClassLoader.findClass(Unknown Source) at
java.lang.ClassLoader.loadClass(Unknown Source) at
sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source) at
java.lang.ClassLoader.loadClass(Unknown Source) at
de.fuberlin.wiwiss.d2rq.algebra.CompatibleRelationGroup.addNodeRelation(CompatibleRelationGroup.java:53)
at
de.fuberlin.wiwiss.d2rq.algebra.CompatibleRelationGroup.groupNodeRelations(CompatibleRelationGroup.java:38)
at de.fuberlin.wiwiss.d2rq.find.FindQuery.iterator(FindQuery.java:78)
at
de.fuberlin.wiwiss.d2rq.jena.GraphD2RQ.graphBaseFind(GraphD2RQ.java:88)
at com.hp.hpl.jena.graph.impl.GraphBase.find(GraphBase.java:240) at
com.hp.hpl.jena.graph.compose.DisjointUnion.graphBaseFind(DisjointUnion.java:27)
at com.hp.hpl.jena.graph.impl.GraphBase.find(GraphBase.java:240) at
com.hp.hpl.jena.graph.impl.GraphBase.graphBaseFind(GraphBase.java:260)
at com.hp.hpl.jena.graph.impl.GraphBase.find(GraphBase.java:257) at
com.hp.hpl.jena.graph.query.SimpleQueryHandler.predicatesFor(SimpleQueryHandler.java:68)
at
com.hp.hpl.jena.graph.query.SimpleQueryHandler.predicatesFor(SimpleQueryHandler.java:47)
at
com.hp.hpl.jena.rdf.model.impl.ModelCom.listPredicates(ModelCom.java:751)
at
com.hp.hpl.jena.rdf.model.impl.ModelCom.listNameSpaces(ModelCom.java:763)
at
com.hp.hpl.jena.xmloutput.impl.BaseXMLWriter.addNameSpaces(BaseXMLWriter.java:233)
at
com.hp.hpl.jena.xmloutput.impl.BaseXMLWriter.setupNamespaces(BaseXMLWriter.java:487)
at
com.hp.hpl.jena.xmloutput.impl.BaseXMLWriter.write(BaseXMLWriter.java:469)
at MyPackage.MyClass.Mymethod(MyClass.java:118) at
MyPackage.Test.main(Test.java:77)
The row 118 of the class "MyClass" contains this code:
writer.write(d2rqModel, new OutputStreamWriter(out, "utf-8"),loader.getResourceBaseURI());
with
RDFWriter writer;
and
import com.hp.hpl.jena.rdf.model.RDFWriter;
Why I have this problem?
In addition, the same class in a different project works well!!! Why?
You've changed and recompiled the class without recompiling everything that depends on it. Do a clean build. You may get some compiler errors in the process.
You may have added dependency that are ambiguous to compiler's understanding. Verify that you don't have duplicate dependency for same class.
Related
I am very new to boilerpipe and I am trying out the following basic code:
package contentExtraction;
import java.net.URL;
import de.l3s.boilerpipe.extractors.ArticleExtractor;
public class ContentExtractor {
public static void main(String[] args) throws Exception {
final URL url = new URL(
// "http://www.l3s.de/web/page11g.do?sp=page11g&link=ln104g&stu1g.LanguageISOCtxParam=en"
"http://www.dn.se/nyheter/vetenskap/annu-godare-choklad-med-hjalp-av-dna-teknik"
);
System.out.println(ArticleExtractor.INSTANCE.getText(url));
}
}
But I am getting the following error when trying to run the above piece of code:
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/xerces/parsers/AbstractSAXParser
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.access$100(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at de.l3s.boilerpipe.sax.BoilerpipeSAXInput.getTextDocument(BoilerpipeSAXInput.java:51)
at de.l3s.boilerpipe.extractors.ExtractorBase.getText(ExtractorBase.java:69)
at de.l3s.boilerpipe.extractors.ExtractorBase.getText(ExtractorBase.java:87)
at contentExtraction.ContentExtractor.main(ContentExtractor.java:16)
Caused by: java.lang.ClassNotFoundException: org.apache.xerces.parsers.AbstractSAXParser
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 16 more
I googled the error and came across this link. I thought that I was missing xercesImpl.jar in my dependencies. I included the same, still my code is giving the same error. What is the issue?
I figured the solution myself. The boilerpipe jar has further dependencies. I converted my project to maven project, included the dependency:
<dependency>
<groupId>com.syncthemall</groupId>
<artifactId>boilerpipe</artifactId>
<version>1.2.1</version>
</dependency>
When I build the above project, I can see there are actually 4 jars that are imported in Maven Dependencies folder:
boilerpipe-1.2.1.jar
nekohtml-1.9.18.jar
xercesImpl-2.11.0.jar
xml-apis-1.4.01.jar
We had installed version of our applications (without any instrumentation or cobertura jar included before generating application bundles).
After installation we instrumented all the jar with cobertura, and included cobertura jar file in java classpath. but while starting application it give below error.
any input will really help, thanks.
Java version "1.7.0_25"
cobertura ver 1.9.4.1
Exception in thread "main" java.lang.NoClassDefFoundError: net/sourceforge/cobertura/coveragedata/HasBeenInstrumented
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.access$100(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.launcher.LauncherHelper.checkAndLoadMain(Unknown Source)
Caused by: java.lang.ClassNotFoundException: net.sourceforge.cobertura.coveragedata.HasBeenInstrumented
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 13 more
You should add cobetura.jar to Bootstrap Classes with -Xbootclasspath. More info: https://docs.oracle.com/javase/8/docs/technotes/tools/findingclasses.html
This needs to be done in order to load the cobetura classes, which are needed in order to load your app classes.
I have been able to get rid of this problem by running a late package goal, as it re-compiles and re-packages de code without Cobertura.
The goals I use are:
clean site package
I have the project based on JavFX 2, it`s done and works perfect in Eclipse. Now i am trying to deploy it on computer(self-service,terminal,..). I have created jar file, but when i am trying to "java -jar myproject.jar" i take the following
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.access$100(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.launcher.LauncherHelper.checkAndLoadMain(Unknown Source)
Caused by: java.lang.ClassNotFoundException: javafx.application.Application
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 13 more
UDT:
I think there is some problem with jfxrt.jar where javafx.application.Application class stored, in eclipse i added this jar in build path manually..
In Java 7, JavaFX is included with the JDK download but is not on the classpath (JavaFX is not part of the core libraries in Java 7). Have a look at the tutorial on deployment, which shows mechanisms for deploying a jar file that will work.
(In Java 8, JavaFX becomes part of the core libraries and will be included on the classpath, so your regular jar file may well work. There are still some cool things you can do with the proper deployment process, though.)
I am currently trying to build a simple java Game with Slick and Maven.
My Setup does work basicly. But when I extend my Main Class to be a Slick "BasicGame" I can't execute the jar anymore, promting this error message:
D:\workspace\GameTest\target>java -jar GameTest-1.0-SNAPSHOT.jar
Exception in thread "main" java.lang.NoClassDefFoundError: org/newdawn/slick/BasicGame
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClassCond(Unknown Source)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.access$000(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
Caused by: java.lang.ClassNotFoundException: org.newdawn.slick.BasicGame
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 12 more
Could not find the main class: gameTest.MyGame. Program will exit.
Before I did this everything executed just fine. The Pom.xml is copied from here.
the MyGame class looks like this:
...
imports
...
public class MyGame extends BasicGame {
...
empty implementations of BasicGame Methods
...
public static void main(String[] args){
System.out.println("Hello World");
}
}
Does anyone know why this error occures?
Does anyone know why this error occurs?
When you switched to using an executable jar, you created a situation where your dependent library - slick.jar - is no longer in your class path. Everything starts out OK because MyGame is in your jar file. But MyGame extends BasicGame which is not in your jar file. It is in slick.jar and your java command makes no reference to slick.jar.
Somehow you have to get all your dependencies back into your class path. For more information check out related question Is it possible to create an "uber" jar containing the project classes and the project dependencies as jars with a custom manifest file?
Just checked your pom.xml file - you'll have to integrate lwjgl and vecmath into your class path also.
I'm trying to use the Lizzy library (http://lizzy.sourceforge.net/) to do some playlist manipulation. As a dependency, it requires that I have the Castor library (http://www.castor.org/) in my build path. So I went to the site, and downloaded Castor 1.3.1, then put the .jar into my build path.
However, when I try to run this line of code to convert a specific playlist file to a generic playlist object:
specificPlaylist = SpecificPlaylistFactory.getInstance().readFrom(playlistFile);
I end up getting a NoClassDefFoundError:
Exception in thread "AWT-EventQueue-0" java.lang.NoClassDefFoundError: org/exolab/castor/core/exceptions/CastorException
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClassCond(Unknown Source)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.access$000(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClassCond(Unknown Source)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.access$000(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at org.exolab.castor.mapping.Mapping.<init>(Mapping.java:81)
at christophedelory.xml.XmlSerializer.getMapping(XmlSerializer.java:100)
at christophedelory.playlist.asx.AsxProvider.readFrom(AsxProvider.java:202)
at christophedelory.playlist.SpecificPlaylistFactory.readFrom(SpecificPlaylistFactory.java:132)
at christophedelory.playlist.SpecificPlaylistFactory.readFrom(SpecificPlaylistFactory.java:168)
...
Am I missing a .jar file? I managed to create an instance of a CastorException class (but it was in a different package than the one the exception is talking about). I thought that the basic Castor-1.3.1.jar file held all of the classes it needed.
Additional information: I'm trying to decode a .wpl playlist file, which should be supported by Lizzy. And my build path looks like this:
Thanks for any help.
You can easily look in the Castor jar to see what's there using a wide variety of tools - WinZip happens to be my tool of choice. You'll find that while there's a CastorException, it's in the wrong package.
Looking at the old downloads page under 1.3.1, I see a Castor-1.3.1-core.jar. Looking in it, I see CastorException in the right package. You may need other jars too - I'd consult the documentation, or continue by trial-and-error, or try to find a POM that will tell you.