Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Standalone project error: couldn't find resource on classpath
icon5.gif  Standalone project error: couldn't find resource on classpath [message #1061683] Mon, 03 June 2013 13:29 Go to next message
Victor Silva is currently offline 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 Go to previous messageGo to next message
Victor Silva is currently offline 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

Re: Standalone project error: couldn't find resource on classpath [message #1061752 is a reply to message #1061743] Mon, 03 June 2013 18:39 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian Dietrich
Messages: 6305
Registered: July 2009
Senior Member
Hi,

why dont you use the Export -> Java -> Runnable Jar FIle Wizard?
Re: Standalone project error: couldn't find resource on classpath [message #1063150 is a reply to message #1061752] Wed, 12 June 2013 13:42 Go to previous messageGo to next message
Victor Silva is currently offline Victor Silva
Messages: 4
Registered: June 2013
Junior Member
Hi Christian,

Sorry for taking so long to reply to this thread. I didn't export as a .jar because I needed to manipulate individual java files outside eclipse.

I am porting the project to a simple webapp that requests a model file from the user, processes the model in memory and performs a file generation (if the model was correctly parsed).

Maybe I could do all this by exporting the original Xtext project as a .jar, but felt more comfortable with the other alternative.
Re: Standalone project error: couldn't find resource on classpath [message #1063154 is a reply to message #1063150] Wed, 12 June 2013 13:48 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian Dietrich
Messages: 6305
Registered: July 2009
Senior Member
Hi,

if so you have to care about the classpath yourself.
Re: Standalone project error: couldn't find resource on classpath [message #1063221 is a reply to message #1063154] Wed, 12 June 2013 17:17 Go to previous messageGo to next message
Victor Silva is currently offline Victor Silva
Messages: 4
Registered: June 2013
Junior Member
Indeed, but performing

javac -cp "lib/*:src" (...)


and providing all needed jars in the lib/ project folder solved the issue for me.
Re: Standalone project error: couldn't find resource on classpath [message #1092079 is a reply to message #1063221] Thu, 22 August 2013 09:51 Go to previous message
Thomas Goossens is currently offline Thomas Goossens
Messages: 32
Registered: August 2013
Member
What did you do to solve the 'missing xmi file' problem?
Previous Topic:Arbitrary Qualifiers
Next Topic:Missing xmi file. What is it? Where should it come from?
Goto Forum:
  


Current Time: Sat Sep 20 04:00:26 GMT 2014

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

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