Standalone project error: couldn't find resource on classpath [message #1061683] |
Mon, 03 June 2013 13:29 |
Victor Silva Messages: 4 Registered: June 2013 |
Junior Member |
|
|
I created a project with the default Xtext language,
Model:
greetings+=Greeting*;
Greeting:
'Hello' name=ID '!';
and, after running the MWE2 Workflow, copied all java files into my standalone project, preserving the original directory hierarchy, and tried to execute the following Main:
import static org.junit.Assert.assertEquals;
import org.antlr.runtime.RecognitionException;
import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.xtext.resource.XtextResource;
import org.eclipse.xtext.resource.XtextResourceSet;
import com.google.inject.Injector;
import org.xtext.example.SimpleDSLStandaloneSetup;
public class Main {
public static void main(String[] args) {
Injector injector = new SimpleDSLStandaloneSetup().createInjectorAndDoEMFRegistration();
XtextResourceSet resourceSet = injector.getInstance(XtextResourceSet.class);
resourceSet.addLoadOption(XtextResource.OPTION_RESOLVE_ALL, Boolean.TRUE);
Resource resource = resourceSet.getResource(URI.createFileURI("src/test.sdsl"), true);
}
}
I get an error which states that
Exception in thread "main" com.google.inject.ProvisionException: Guice provision errors:
1) Error injecting constructor, org.eclipse.emf.common.util.WrappedException: org.eclipse.xtext.resource.ClasspathUriResolutionException: java.lang.IllegalStateException: Couldn't find resource on classpath. URI was 'classpath:/org/xtext/example/SimpleDSL.xmi'
(...)
I am trying to execute with the following command:
java -cp "classes:lib/*:src" Main
And my project hierarchy contains all java files in src/, all jars in lib/ and all .class files in classes/.
What am I missing?
[Updated on: Mon, 03 June 2013 13:40] Report message to a moderator
|
|
|
Re: Standalone project error: couldn't find resource on classpath [message #1061743 is a reply to message #1061683] |
Mon, 03 June 2013 17:30 |
Victor Silva Messages: 4 Registered: June 2013 |
Junior Member |
|
|
I probably figured it out: two files were missing from my project. The first one, <dsl_name>.xmi, originally located on
src-gen
|-> <base_package>
|-> <dsl_name>.xmi
(in my case, src-gen/org.xtext.example/DefaultDSL.xmi) and, the second, Internal<dsl_name>.tokens, located on
src-gen
|-> <base_package>.parser.antlr.internal
|-> Internal<dsl_name>.tokens
(in my case, src-gen/org.xtext.example.parser.antlr.internal/InternalDefaultDSL.tokens)
The aforementioned Main.java file started executing as soon as the missing files were added to the project. I hope this helps anyone with a similar issue!
[Updated on: Mon, 03 June 2013 17:34] Report message to a moderator
|
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.02840 seconds