Skip to main content


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: 250
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: 25
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: 760
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?


---
Get professional support from the Xtext committers at www.typefox.io
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 messageGo to next 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
Re: Problem while adding libraries to xtext Project [message #1856861 is a reply to message #1748363] Thu, 05 January 2023 18:18 Go to previous messageGo to next message
Allan Wá is currently offline Allan WáFriend
Messages: 1
Registered: January 2023
Junior Member
Hello, Im having the same problem while running the jar file I created

Should I manually add the libraries in the manifest of the jar? and what libraries?
Re: Problem while adding libraries to xtext Project [message #1856885 is a reply to message #1856861] Sat, 07 January 2023 10:00 Go to previous message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
There should be exports for the stuff you want too (runtime tab in manifest editor )
You also need to make sure the jar is packaged (build.properties)


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Previous Topic:Only allow explicit imports
Next Topic:Xtext 2.30.0.M1 is out
Goto Forum:
  


Current Time: Wed Apr 24 18:16:54 GMT 2024

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

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

Back to the top