Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Problem while adding libraries to xtext Project(The building process runs fine, but when executing, eclipse generates error)
icon5.gif  Problem while adding libraries to xtext Project [message #1748363] Tue, 22 November 2016 13:21 Go to next message
Miguel Rass is currently offline Miguel RassFriend
Messages: 2
Registered: November 2016
Junior Member

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.
Re: Problem while adding libraries to xtext Project [message #1748430 is a reply to message #1748363] Wed, 23 November 2016 07:04 Go to previous messageGo to next message
Uli Merkel is currently offline Uli MerkelFriend
Messages: 223
Registered: June 2013
Senior Member
Have you tried adding the org.semanticweb.owlapi... to the manifest as dependencies ?

and I think the code of your validator would be helpful
Re: Problem while adding libraries to xtext Project [message #1748438 is a reply to message #1748430] Wed, 23 November 2016 08:34 Go to previous messageGo to next message
Akos Kitta is currently offline Akos KittaFriend
Messages: 20
Registered: November 2015
Junior Member
The dependency should be resolved at runtime as well, so it should be added to the manifest. Something like this:
 Bundle-ClassPath: lib/yourDependency.jar,
 lib/anotherDependency.jar,
 .

You can also configure it from the manifest editor's Runtime page > Classpath section. Hope this helps.
Re: Problem while adding libraries to xtext Project [message #1748439 is a reply to message #1748363] Wed, 23 November 2016 08:39 Go to previous messageGo to next message
Jan Koehnlein is currently offline Jan KoehnleinFriend
Messages: 735
Registered: July 2009
Location: Hamburg
Senior Member
Not really an Xtext problem here: The error says the respective class is not on the classpath.

In which library is it? How did you add that library to the classpath (MANIFEST, .classpath)? Does it depend on further classes from other libraries that need to be added to the classpath as well?
Re: Problem while adding libraries to xtext Project [message #1748519 is a reply to message #1748363] Wed, 23 November 2016 22:26 Go to previous message
Miguel Rass is currently offline Miguel RassFriend
Messages: 2
Registered: November 2016
Junior Member
Thanks everyone, I was inserting the semantic libraries in build.properties as a folder, when I inserted each Jar separately, it worked. Very Happy
Previous Topic:Model display on load in XTEXT Web Editor
Next Topic:Content Assist in Web Editor
Goto Forum:
  


Current Time: Sun Apr 23 22:01:34 GMT 2017

Powered by FUDForum. Page generated in 0.02354 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software