Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Extending grammar - NoClassDefFoundError
Extending grammar - NoClassDefFoundError [message #830284] Tue, 27 March 2012 12:36 Go to next message
Alex G is currently offline Alex GFriend
Messages: 96
Registered: January 2012
Member
Hi!

I am extending a grammar DSL1 with DSL2.

When I create a file in the editor with the extension of the DSL2 grammar, I get the following error:

Head: "Creation problems"
"Internal error: java.lang.NoClassDefFoundError
org/xtext/examples/mydsl/validation/MyDSLJavaValidator"

Furthermore, if I go to the properties for my DSL2-project, I see on the left side options for both dsls DSL1 and DSL2, but when I click on DSL2, the options field to the right does not show up, I mean the field where I can find the option "Enable project specific settings".

What I have done in order to create the grammar extension:

(1) I have added each of the three projects mydsl, mydsl.tests and mydsl.ui to the projects on the build path for each of the three projects for DSL2.

(2)
// The following two lines can be removed, if Xbase is not used.
// registerGeneratedEPackage = "org.eclipse.xtext.xbase.XbasePackage"
// registerGenModelFile = "platform:/resource/org.eclipse.xtext.xbase/model/Xbase.genmodel"
        registerGeneratedEPackage = "org.xtext.example.mydsl.mydsl.MyDSLPackage"
        registerGenModelFile = "platform:/resource/org.xtext.example.mydsl/src-gen/org/xtext/example/mydsl/MyDSL.genmodel"

This works, since the building the MWE2 workflow is working without errors.

(3) In the grammar of DSL2: (something like)
grammar org.xtext.example.mydsl2.MyDsl2 with org.xtext.example.mydsl.MyDSL
generate mydsl2 "http://www.xtext.org/example/mydsl2/MyDSL2"
import "http://www.xtext.org/example/mydsl/MyDSL" as mydsl

with an overwritten rule in order to extend the grammar.
This compiles also nicely.

(4) In DSL1 I am using XTend in order to create the validation: The java validator extends the XTend validator and this again extends the Abstract
public class MyDSLJavaValidator extends MyDSLXTendValidator

[code}
class MyDSLXTendValidator extends AbstractMyDSLJavaValidator
[/code]

In the bin directory I have the org/xtext/examples/mydsl/validation/MyDSLJavaValidator file, which is not found:
\bin\org\xtext\example\mydsl\validation\MyDSLJavaValidator.class

I don't know where the problem could be! Am I missing something?

Best regards,
Alex.
Re: Extending grammar - NoClassDefFoundError [message #830341 is a reply to message #830284] Tue, 27 March 2012 13:56 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
Hi is the validation package exported by osgi means and has 2 a
plugin dependency to 1


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Extending grammar - NoClassDefFoundError [message #831814 is a reply to message #830341] Thu, 29 March 2012 11:37 Go to previous messageGo to next message
Alex G is currently offline Alex GFriend
Messages: 96
Registered: January 2012
Member
Hi!

The problem I had, is that I had not added the plugin 1 to the dependencies in the Manifest of DSL2.
But now there are other problems:
After adding it, I had to
* extend MyDSL2RuntimeModule from MyDSL1RuntimeModule and
* extend MyDSL2StandaloneSetup from MyDSL1StandaloneSetup.
With these extensions I could use some custom implementations from MyDsl1 like scoping.
But there arose another problem:
java.lang.NoClassDefFoundError: org/xtext/example/myDSL1/ui/contentassist/MyDSL1ProposalProvider

Ok, so lets extend: MyDSL2UIModule from MyDSL1UIModule

When doing this, and starting the editor again, the editor for DSL2 does not even start now Smile.

Am I doing something completely wrong? When I want to extend a grammar and use all of the basic functionality of the first grammar, do I have to extend each of the classes individually, like ScopeProvider, LabelProvider, QualifiedNameProvider, ... - or is there a location (e.g. in the MWE2 of DSL2?) where I can get all of these functionality extensions for "free"?

Furthermore: If I extend a grammar, do I really have to copy&paste the starting rule of DSL1 or is there another way?

Alex.
Re: Extending grammar - NoClassDefFoundError [message #831822 is a reply to message #831814] Thu, 29 March 2012 11:48 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
What about adding a dep from b.UI to a.ui to the manifest of b.ui

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Extending grammar - NoClassDefFoundError [message #831830 is a reply to message #831814] Thu, 29 March 2012 12:01 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
And yes you have to copy and paste the entry rule

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Extending grammar - NoClassDefFoundError [message #831839 is a reply to message #831822] Thu, 29 March 2012 12:24 Go to previous messageGo to next message
Alex G is currently offline Alex GFriend
Messages: 96
Registered: January 2012
Member
Christian Dietrich wrote on Thu, 29 March 2012 07:48
What about adding a dep from b.UI to a.ui to the manifest of b.ui


Oh yes, sure. Thank you again, Christian!

Next problem: My new grammar elements do not show up. I think this is because I have manually extended the old Runtime or Standalone modules with the modules from the first grammar. Is it somehow possible to "extend" both modules: the generated with the new grammar and then overwrite them with the bindings from the first grammar? I do not want to do that manually, since the first grammar might change.
Re: Extending grammar - NoClassDefFoundError [message #831850 is a reply to message #831839] Thu, 29 March 2012 12:37 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
The are/can be module mixes/overrides be done in standalonesetups and
activators , so you could factor out common bindings into a own
module an use it in both activators and standalonesetups

Just have a look at the activators and you will see what I mean


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Extending grammar - NoClassDefFoundError [message #831885 is a reply to message #831850] Thu, 29 March 2012 13:37 Go to previous messageGo to next message
Alex G is currently offline Alex GFriend
Messages: 96
Registered: January 2012
Member
Sorry, I don't know exactly what you mean, and after searching in the dark forest for "Activator" I found:
* in the docu: "Within Eclipse we have a generated Activator, which creates a Guice Injector ..." -> ok, understood, where can I get this "activator"?
* in the mwe: "component = Generator { activator = ..." -> ok, here is an option for an activator, which needs a string. What is this string? Do you mean this "activator"?

Furthermore I found some setters in some of the language fragments in the mwe
* validation.JavaValidatorFragment { inheritImplementation = true }
* scoping.ImportURIScopingFragment { inheritImplementation = true }
* contentAssist.JavaBasedContentAssistFragment { inherit = true }

which had the effect that:
* AbstractDSL2JavaValidator extends DSL1JavaValidator -> perfect!
* AbstractDSL2ProposalProvider extends DSL1ProposalProvider -> perfect!
BUT:
* AbstractDeclarativeScopeProvider does not extend the scope provider from DSL1.

The method with the "activator" is of course more general as just setting some inheritImpls to true, so it would be nice to know how to deal with that.

Alex.
Re: Extending grammar - NoClassDefFoundError [message #831897 is a reply to message #831885] Thu, 29 March 2012 13:53 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
Hi I was talking about the activator class of your UI project.

Regarding to scope provider. Why don't you change to inheritance
manually or try the inheritimplentation flag in the importednamespace
scoping fragment


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Extending grammar - NoClassDefFoundError [message #832455 is a reply to message #831897] Fri, 30 March 2012 07:02 Go to previous messageGo to next message
Alex G is currently offline Alex GFriend
Messages: 96
Registered: January 2012
Member
Hi!
I was talking about the activator class of your UI project.

I see, I will have a look at that.

Regarding to scope provider. Why don't you change to inheritance 
manually

I could have done it manually, just thought that there must be a more generic way.
or try the inheritimplentation flag in the importednamespace 
scoping fragment

I've commented out importedNamespace fragment, since I'm using ImportURIScopingFragment. Inside this one, I have set already the inheritImplementation flag to true, but that didn't help somehow. Is it possibly the case, since I've set to MyDSL1 generateStub to false in the URI scoping fragment, because I'm working with xtend files and don't want to create two Java scoping classes?

Alex.
Re: Extending grammar - NoClassDefFoundError [message #832463 is a reply to message #832455] Fri, 30 March 2012 07:12 Go to previous message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
Sorry I do not know that. You have to debug the workflow yourself

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Previous Topic:Validation of a document
Next Topic:eclipse update broke my xtext
Goto Forum:
  


Current Time: Thu Mar 28 20:19:40 GMT 2024

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

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

Back to the top