Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » M2T (model-to-text transformation) » Xpand: could not find the property exception
Xpand: could not find the property exception [message #519097] Sat, 06 March 2010 12:32 Go to next message
zakir Hussain is currently offline zakir HussainFriend
Messages: 76
Registered: July 2009
Member
Hello All,

I am executing Xpand template in multiple threads.

In each thread i am creating a new XpandExecutioncontextImpl object, fetching the XpandFacade object and then calling evaluate method on XpandFacade with an object of my object model and with an Xpand template path .

In Xpand script, i am importing my ecore model, my XpandScript internally uses lot of java extensions (which are all static methods in java code). As my application is multithreaded application, i have made all the java extension(i.e in java code) as synchronized methods, and all these java extensions returns an object or collection of objects which are part of my object model (i.e ecore)

After a call to java extension, on the return value of it, when i try to fetch the attributes of the object returned, i am getting no property found exception.

Example:

Assume my ecore is having School as a class and students as a list, and each student is having a name attribute as String...

when i invoke a java extension from my Xpand template, return value is Student, when i call name attribute in Xpand, i am getting property not found exeception.

This behaviour is not consistent................


So please suggest me how to proceed regarding this.........now i dont know what to be synchronized....





Re: Xpand: could not find the property exception [message #519161 is a reply to message #519097] Sun, 07 March 2010 15:24 Go to previous messageGo to next message
Sven Efftinge is currently offline Sven EfftingeFriend
Messages: 1823
Registered: July 2009
Senior Member
zakir,

> In Xpand script, i am importing my ecore model, my XpandScript
> internally uses lot of java extensions (which are all static methods in
> java code). As my application is multithreaded application, i have made
> all the java extension(i.e in java code) as synchronized methods, and
> all these java extensions returns an object or collection of objects
> which are part of my object model (i.e ecore)

Do they modify shared state?

> After a call to java extension, on the return value of it, when i try to
> fetch the attributes of the object returned, i am getting no property
> found exception.

For what kind of property?
Do you create that object in the java extension?
If yes, how do you create it resp. how do you obtain the EFactory?

Sven


--
Need professional support for Xtext and EMF?
Go to: http://xtext.itemis.com
Twitter : @svenefftinge
Blog : blog.efftinge.de
Re: Xpand: could not find the property exception [message #519164 is a reply to message #519097] Sun, 07 March 2010 16:35 Go to previous messageGo to next message
zakir Hussain is currently offline zakir HussainFriend
Messages: 76
Registered: July 2009
Member
Hello Sven,

> Do they modify shared state?

These threads does not modify the shared state....

>For what kind of property?
In my example as i had described about my School model which is having list of Students, When java extensions return me a list of Student objects, when i call name attribute of Student class i am getting property not found exception

my code looks like this:


«FOREACH getStudentsList()  AS st»

Name of student is : «st.name» 

«ENDFOREACH»


Quote:
st.name is the place where i am getting property not found exception


In the above code, getStudentsList() is an extend method which is a JAVA extension method, i.e this method internally is calling java method getAllStudents()

getAllStudents() method definition is in the following way

public static synchronized List<Student> getAllStudents(School school){
		List<Student> students=new ArrayList<Student>();
		
		for(int i=0;i<10;i++){
			Student student = RootFactory.eINSTANCE.createStudent();
			student.setName(""+i);
			students.add(student);
		}
		return students;
	}


>Do you create that object in the java extension?
Yes i create objects inside java extension methods

>If yes, how do you create it resp. how do you obtain the EFactory?
I have a dependecy of my model plugin on the plugin where java extensions are present.

I create the objects using RootFactory.eINSTANCE

Regards,

Zakir
Re: Xpand: could not find the property exception [message #519256 is a reply to message #519164] Mon, 08 March 2010 09:45 Go to previous messageGo to next message
Sven Efftinge is currently offline Sven EfftingeFriend
Messages: 1823
Registered: July 2009
Senior Member
A couple of additional questions:
- How do you call Xpand?
- Do you load your model form XMI? Does it refer to its ecore model by
nsURI or resource URI?
- Have you registered the RootPackage.eInstance?

Sven

--
Need professional support for Xtext and EMF?
Go to: http://xtext.itemis.com
Twitter : @svenefftinge
Blog : blog.efftinge.de
Re: Xpand: could not find the property exception [message #519269 is a reply to message #519256] Mon, 08 March 2010 10:39 Go to previous messageGo to next message
zakir Hussain is currently offline zakir HussainFriend
Messages: 76
Registered: July 2009
Member
Hello Sven,

> How do you call Xpand?


XpandExecutionContext executionContext = new XpandExecutionContext(outputImpl, null, globalVarsMap, null, null);
XpandFacade xpandFacade = XpandFacade.create(executionContext);

xpandFacade.evaluate(definitionName, schoolObject, new Object[] {});


>Do you load your model form XMI? Does it refer to its ecore model by nsURI or resource URI?

No the model is not referred from XMI, instead object model is passed to the method where XpandFacade is created and it is again passed to evaluate method of XpandFacade


>Have you registered the RootPackage.eInstance?

Yes i have registered RootPackage in the following way:

MetaModel root_META_MODEL = new EmfRegistryMetaModel() {
@Override
protected EPackage[] allPackages() {
return new EPackage[] { RootPackage.eINSTANCE,
RootPackage.eINSTANCE };
}
};
executionContext.registerMetaModel(root_META_MODEL);

Re: Xpand: could not find the property exception [message #519332 is a reply to message #519269] Mon, 08 March 2010 14:24 Go to previous message
Sven Efftinge is currently offline Sven EfftingeFriend
Messages: 1823
Registered: July 2009
Senior Member
My suspection is that the original model is not an instance of the same
EPackage you use in the Java extension.
Could you check, whether the model elements are actuially instances of
the generated EClasses?

Sven

--
Need professional support for Xtext and EMF?
Go to: http://xtext.itemis.com
Twitter : @svenefftinge
Blog : blog.efftinge.de
Previous Topic:[xTend] GLOBALVAR causes exception
Next Topic:Trouble getting a list of "items" of a certain type
Goto Forum:
  


Current Time: Tue Apr 23 12:21:27 GMT 2024

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

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

Back to the top