LorenzoBettini / packtpub-xtext-book-examples

Examples for the book "Implementing Domain-Specific Languages with Xtext and Xtend" 978-1782160304
Eclipse Public License 1.0
34 stars 20 forks source link

Cannot create a resource for ... a registered resource factory is needed (Chapter 5) #4

Open autohandle opened 9 years ago

autohandle commented 9 years ago

Software-Engineerings-MacBook-Pro:tmp david$ ls -al ~/Documents/eclipsecon/eclipsecon2015/XText_Tutorial/ImplementingDSL/workspaces/Chapter2/org.example.entities/src/org/example/entities/Entities.xtext -rw-r--r-- 1 david staff 503 Apr 17 13:48 /Users/david/Documents/eclipsecon/eclipsecon2015/XText_Tutorial/ImplementingDSL/workspaces/Chapter2/org.example.entities/src/org/example/entities/Entities.xtext Software-Engineerings-MacBook-Pro:tmp david$ cat ~/Documents/eclipsecon/eclipsecon2015/XText_Tutorial/ImplementingDSL/workspaces/Chapter2/org.example.entities/src/org/example/entities/Entities.xtext grammar org.example.entities.Entities with org.eclipse.xtext.common.Terminals

generate entities "http://www.example.org/entities/Entities"

Model: entities+=Entity*;

Entity: 'entity' name=ID ('extends' supertype=[Entity])? '{' attributes+=Attribute* '}';

Attribute: type=AttributeType name=ID ';';

AttributeType: elementType=ElementType (array ?='[' (length=INT)? ']')?;

ElementType: BasicType | EntityType;

BasicType: typeName=('string'|'int'|'boolean');

EntityType: entity=[Entity];Software-Engineeringsjava -jar entities-compiler.jar ~/Documents/eclipsecon/eclipsecon2015/XText_Tutorial/ImplementingDSL/workspaces/Chapter2/org.example.entities/src/org/example/entities/Entities.xtext Exception in thread "main" java.lang.reflect.InvocationTargetException at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader.main(JarRsrcLoader.java:58) Caused by: java.lang.RuntimeException: Cannot create a resource for '/Users/david/Documents/eclipsecon/eclipsecon2015/XText_Tutorial/ImplementingDSL/workspaces/Chapter2/org.example.entities/src/org/example/entities/Entities.xtext'; a registered resource factory is needed at org.eclipse.xtext.resource.XtextResourceSet.getResource(XtextResourceSet.java:258) at org.eclipse.xtext.resource.SynchronizedXtextResourceSet.getResource(SynchronizedXtextResourceSet.java:24) at org.example.entities.generator.Main.runGenerator(Main.java:49) at org.example.entities.generator.Main.main(Main.java:31) ... 5 more Software-Engineerings-MacBook-Pro:tmp david$

LorenzoBettini commented 9 years ago

Sorry, I need some more information: you're trying to call the command line compiler and it gives you this error? How did you export the jar for the command line compiler?

autohandle commented 9 years ago

yes, i am trying to use the command line. unless i too eager and made a mistake, i exported it just like it said in the book to /tmp: Software-Engineerings-MacBook-Pro:tmp david$ ls -l entities-compiler.jar -rw-r--r-- 1 david wheel 26965265 Apr 17 15:29 entities-compiler.jar at 26M, it is about the right size according to the book.

thanks for taking time to help me.