Issue
Firstly, I created an xtext project using default values (with the simple Greetings grammar which comes as an example).
I created then a .java file with some code (that can be seen below) and added it to the validation folder.
I have loaded some jars to the build path as I would do in a normal Java Project. If I run my specific java file as a standalone it will load the libraries and run the code. The java file is quite simple:
import org.semanticweb.owlapi.apibinding.OWLManager;
import org.semanticweb.owlapi.model.OWLOntologyCreationException;
import org.semanticweb.owlapi.model.OWLOntologyManager;
import org.xtext.example.mydsl.myDsl.Greeting;
public static void main(String[] args){
Greeting hey = null;
try {
test(hey);
} catch (OWLOntologyCreationException e) {
e.printStackTrace();
}
}
public static void test(Greeting imp) throws OWLOntologyCreationException {
OWLOntologyManager manager = OWLManager.createOWLOntologyManager();
System.out.println("success!");
}
However, if a call the "test" function from the .xtend validator file, it will generate this error:
java.lang.NoClassDefFoundError: org/semanticweb/owlapi/model/OWLOntologyCreationException
at org.xtext.example.mydsl.validation.MyDslValidator.checkGreetingStartsWithCapital(MyDslValidator.java:24)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
/* (has some more "at" in the middle) */
Caused by: java.lang.ClassNotFoundException: org.semanticweb.owlapi.model.OWLOntologyCreationException cannot be found by org.xtext.example.mydsl_1.0.0.qualifier
at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:461)
at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:372)
at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:364)
at org.eclipse.osgi.internal.loader.ModuleClassLoader.loadClass(ModuleClassLoader.java:161)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 32 more
When it mentioned "cannot be found by org.xtext.example.mydsl_1.0.0.qualifier" I assumed the problem was in the manifest, but I've tried adding the libraries to the manifest in every way possible but to no avail.
Solution
if you add libs to the buildpath
- copy it to a new lib folder inside the plugin
- adapt the manifest and add the jars as entries (runtime tab, classpath section)
- add the jars to be included in build.properties (there should be a warning and a quickfix)
Answered By - Christian Dietrich
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.