Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » M2T (model-to-text transformation) » [JET] How to Dynamically call JET transform api through a plugin?
[JET] How to Dynamically call JET transform api through a plugin? [message #535825] Tue, 25 May 2010 20:18 Go to next message
Herat Acharya is currently offline Herat Acharya
Messages: 7
Registered: May 2010
Junior Member
Hi,
I am trying to dynamically call JET transform api through a plugin. But I am getting some error. Please help me with it

Detailed explanation:

1) I have created a new wizard plugin Which selects a particular file.
2) This is an XML file which i need to futher process using JET and create some new files.
3) I am already done with the JET templates for that XML. Now the question it to merge the 2 systems.
4) Hence on when we click the finish button of the wizard i give the xml file as input to the JET template.
5) I am using the following code to invoke JET template

IResource fileRes = (IResource) file // the path to xml file;
IStatus status = JET2Platform.runTransformOnResource("com.tibco.mdm.trwJetTemplate ",fileRes,monitor);

But it gives me a weird error when i click on finish button an alert message pops up sayin error in org/eclipse/jet/JET2Platform

and it gives no other error.

Please help me with this

Thanks in advance
Herat

[Updated on: Tue, 25 May 2010 20:43]

Report message to a moderator

Re: [JET] How to Dynamically call JET transform api through a plugin? [message #535841 is a reply to message #535825] Tue, 25 May 2010 23:45 Go to previous messageGo to next message
Herat Acharya is currently offline Herat Acharya
Messages: 7
Registered: May 2010
Junior Member
Hi
I just found out the exception its the following.... can any one please help me..

java.lang.NoClassDefFoundError: org/eclipse/jet/JET2PlatformEXCEPT org/eclipse/jet/JET2Platform
MSG org/eclipse/jet/JET2Platform

at com.tibco.mdm.testrepositorywiz.wizards.TestRepositoryWizard .doFinish(TestRepositoryWizard.java:123)
at com.tibco.mdm.testrepositorywiz.wizards.TestRepositoryWizard .access$0(TestRepositoryWizard.java:96)
at com.tibco.mdm.testrepositorywiz.wizards.TestRepositoryWizard $1.run(TestRepositoryWizard.java:67)
at org.eclipse.jface.operation.ModalContext$ModalContextThread. run(ModalContext.java:121)
Caused by: java.lang.ClassNotFoundException: org.eclipse.jet.JET2Platform
at org.eclipse.osgi.framework.internal.core.BundleLoader.findCl assInternal(BundleLoader.java:437)
at org.eclipse.osgi.framework.internal.core.BundleLoader.findCl ass(BundleLoader.java:399)
at org.eclipse.osgi.framework.internal.core.BundleLoader.findCl ass(BundleLoader.java:387)
at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.loa dClass(DefaultClassLoader.java:87)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 4 more


i have included org.eclipse.jet in my plugin dependancies ...

I found some thing here http://wiki.eclipse.org/JET_FAQ_Why_do_I_get_errors_stating_ variable_%27org.eclipse.jet.resource.project.name%27_is_unde fined%3F

and i implemented everything mentioned .. but still not working

the modified code is as follows:

IResource fileRes = (IResource) file;

Map<String, String> variables = new HashMap<String, String>();
variables.put("org.eclipse.jet.resource.project.name", "com.tibco.mdm.trwJetTemplate");

IStatus status = JET2Platform.runTransformOnResource("com.tibco.mdm.trwJetTemplate ",fileRes,variables,monitor);

[Updated on: Tue, 25 May 2010 23:50]

Report message to a moderator

Re: [JET] How to Dynamically call JET transform api through a plugin? [message #536225 is a reply to message #535841] Thu, 27 May 2010 12:41 Go to previous messageGo to next message
Paul Elder is currently offline Paul Elder
Messages: 849
Registered: July 2009
Senior Member
A ClassDefNotFoundError from a referenced plug-in suggests something
went wrong in loading that plug-in in the first place.

We can deduce that the org.eclipse.jet plug-in is installed (otherwise,
your wizard plug-in would not have loaded). But, some other problem may
have occurred that is preventing the org.eclipse.jet plug-in from
loading correctly.

Take a look at the Error Log view, and see whether there are log entries
that might provide more details. (You might need to do Window > Show
View > ... to make the view visible).

Also, take a look in the Plug-ins View to see whether the
org.eclipse.jet plug-in is loaded. Alternatively, you can just create a
simple JET transform and try running it. Successfully doing that is a
sign the JET is correctly installed and operational.

Lastly, in your original post you had this code snippet:

IStatus status = JET2Platform.runTransformOnResource(
"com.tibco.mdm.trwJetTemplate ",fileRes,monitor);

Note the space after trwJetTemplate. Remove it - it cannot be doing
anything good.

Paul
Re: [JET] How to Dynamically call JET transform api through a plugin? [message #536352 is a reply to message #536225] Thu, 27 May 2010 18:10 Go to previous messageGo to next message
Herat Acharya is currently offline Herat Acharya
Messages: 7
Registered: May 2010
Junior Member
Thanks Paul,
Just one last question.
I am selecting a value from the wizard plugin lets say Person. This value i want to send it to the Jet template . is there any way to do it so that i can process the template according to this value.

Thanks in advance
Herat
Re: [JET] How to Dynamically call JET transform api through a plugin? [message #536495 is a reply to message #536352] Fri, 28 May 2010 13:37 Go to previous message
Paul Elder is currently offline Paul Elder
Messages: 849
Registered: July 2009
Senior Member
The method JET2Platform.runTransformOnResource() has a variant that
accepts a Map. This map defines JET variables that will be available to
the templates. A quick example:

Map<String,Object> predefinedVariables = new HashMap<String,Object>();
predefinedVariables.put("myVar", myValue);
JET2Platform.runTransformOnResource(...., predefinedVariables, ... );

In a template you would refer to the variable in XPath epxressions:

<c:get select="$myVar"/>

Paul


On 2010-05-27 2:10 PM, Herat Acharya wrote:
> Thanks Paul,
> Just one last question.
> I am selecting a value from the wizard plugin lets say Person. This
> value i want to send it to the Jet template . is there any way to do it
> so that i can process the template according to this value.
>
> Thanks in advance
> Herat
Previous Topic:[check]
Next Topic:[Check] Checks for Generic EMF Form Editor using Xtend in combination with Java method
Goto Forum:
  


Current Time: Wed Sep 17 11:41:57 GMT 2014

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

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