JET error [message #66254] |
Wed, 03 January 2007 08:41 |
Eclipse User |
|
|
|
Originally posted by: rtv222.gmail.com
Hi,
I am using JET to generate code from an EMF model.
I have done the following steps on my JET transformation project and I have
a ecore model
created by importing the example library.xsd
a.. Open the plugin.xml file in the root of the JET transformation
project.
b.. Switch to the 'Extensions' tab.
c.. Find the 'org.eclipse.jet.transform' extension in the 'All Extensions'
tree, and expand it to reveal the 'transform' child element.
d.. Select the 'transform' element, and enter org.eclipse.jet.xml in the
'modelLoader' field.
However, on attempting to run a simple JET template
<%@taglib prefix="c" id="org.eclipse.jet.controlTags" %>
<c:load url="library.xml" var="pluginXML"/>
package org.book;
class <c:get select="$library/books/@title" />Person {
public String getTitle() {
return "<c:get select="$library/books/@title" />";
}
public String getAuthor() {
return "<c:get select="$library/books/@author" />";
}
}
I get the following error.
Exception in thread "main" java.lang.NullPointerException
at
org.eclipse.jet.taglib.TagLibraryManager.getTagLibrary(TagLi braryManager.java:89)
at
org.eclipse.jet.internal.runtime.TagFactoryImpl.createRuntim eTag(TagFactoryImpl.java:61)
at jet2java.Transform$1.createRuntimeTag(Transform.java:33)
at org.eclipse.jet.compiled._jet_test.generate(_jet_test.java:5 4)
at jet2java.Transform.main(Transform.java:149)
Pls let me know what I could be doing wrong.
Rgds,
Rajesh
|
|
|
Re: JET error [message #68240 is a reply to message #66254] |
Tue, 16 January 2007 15:51 |
Paul Elder Messages: 849 Registered: July 2009 |
Senior Member |
|
|
Rajesh:
Looking at your stack trace, it seems you are trying to run an EMFT JET
template directly from a Java program (Transform.main()). EMFT JET doesn't
work that way.
EMFT JET has a concept of a 'transformation', which is a group of templates
that are run together and co-orderated by a 'start template' (be default,
templates/main.jet). You 'run' this transformation by created an 'JET
Transformation' launch configuration, much as you run a Java program by
creating Java Application launch configuration. JET Transformation launch
configurations take a transformation id (plug-in of a JET Transformation)
and a Eclipse resource.
JET Transformations are Eclipse plug-ins. Executing a JET transformation
that is in your workspace will result in the project being temporarily
loaded as a plug-in in your workbench while the templates are executed.
While JET will load a JET Transformation project from the workspace, it will
not load any dependent projects (such as your EMF generated model, edit and
editor code). To have a JET Transformation work against an EMF generated
model, you have one of two choices:
1) install the EMF generated model, edit, and editor plug-ins in your
workbench
2) Create an Eclipse Application launch configuration (i.e. a Runtime
workbench) that includes both the EMF generated projects and the JET
transformation.
To get JET to successfully load you EMF-generated model, you will need to
change the 'modelLoader' attribute on the 'transform' element in the
Extensions tab of the plug-in manifest editor (open plugin.xml). The value
should be 'org.eclipse.jet.emf'. Note that there is a typo in the
documentation (which has been fixed for 0.7.2).
Lastly, I've added some comments in-line on your template.
"Rajesh T V" <rtv222@gmail.com> wrote in message
news:enfq86$5rc$1@utils.eclipse.org...
.... snip...
> <%@taglib prefix="c" id="org.eclipse.jet.controlTags" %>
PE> The above line is not needed if you use the JET New Project wizard. This
tag library is automatically imported into templates.
> <c:load url="library.xml" var="pluginXML"/>
PE> You don't need the above line either. Create a JET Transformation launch
configuration specifying library.xml as your input. c:load is, however,
useful
in loading addition models.
> package org.book;
> class <c:get select="$library/books/@title" />Person {
PE> This will have unexpected results if you have more than one 'books'
element in the library.xml. It will always return the title of the first.
> public String getTitle() {
> return "<c:get select="$library/books/@title" />";
> }
> public String getAuthor() {
> return "<c:get select="$library/books/@author" />";
> }
> }
>
PE> The variable $library is not defined by this template. Assuming that
library is the root element of library.xml, you need something like:
<c:setVariable var="library" select="/*"/>
To 'invoke' this template, you should have the following as the contents for
templates/main.jet:
This can be either in this template, or more often, in the template that
invokes it (usually templates/main.jet).
<%@ taglib prefix="ws" id="org.eclipse.jet.workspaceTags" %>
<c:setVariable var="library" select="/*"/>
<ws:file
path=" {$org.eclipse.jet.resource.project.name}/testOutput/test.jav a "
template="templates/test.jet" />
Paul
|
|
|
Re: JET error [message #601309 is a reply to message #66254] |
Tue, 16 January 2007 15:51 |
Paul Elder Messages: 849 Registered: July 2009 |
Senior Member |
|
|
Rajesh:
Looking at your stack trace, it seems you are trying to run an EMFT JET
template directly from a Java program (Transform.main()). EMFT JET doesn't
work that way.
EMFT JET has a concept of a 'transformation', which is a group of templates
that are run together and co-orderated by a 'start template' (be default,
templates/main.jet). You 'run' this transformation by created an 'JET
Transformation' launch configuration, much as you run a Java program by
creating Java Application launch configuration. JET Transformation launch
configurations take a transformation id (plug-in of a JET Transformation)
and a Eclipse resource.
JET Transformations are Eclipse plug-ins. Executing a JET transformation
that is in your workspace will result in the project being temporarily
loaded as a plug-in in your workbench while the templates are executed.
While JET will load a JET Transformation project from the workspace, it will
not load any dependent projects (such as your EMF generated model, edit and
editor code). To have a JET Transformation work against an EMF generated
model, you have one of two choices:
1) install the EMF generated model, edit, and editor plug-ins in your
workbench
2) Create an Eclipse Application launch configuration (i.e. a Runtime
workbench) that includes both the EMF generated projects and the JET
transformation.
To get JET to successfully load you EMF-generated model, you will need to
change the 'modelLoader' attribute on the 'transform' element in the
Extensions tab of the plug-in manifest editor (open plugin.xml). The value
should be 'org.eclipse.jet.emf'. Note that there is a typo in the
documentation (which has been fixed for 0.7.2).
Lastly, I've added some comments in-line on your template.
"Rajesh T V" <rtv222@gmail.com> wrote in message
news:enfq86$5rc$1@utils.eclipse.org...
.... snip...
> <%@taglib prefix="c" id="org.eclipse.jet.controlTags" %>
PE> The above line is not needed if you use the JET New Project wizard. This
tag library is automatically imported into templates.
> <c:load url="library.xml" var="pluginXML"/>
PE> You don't need the above line either. Create a JET Transformation launch
configuration specifying library.xml as your input. c:load is, however,
useful
in loading addition models.
> package org.book;
> class <c:get select="$library/books/@title" />Person {
PE> This will have unexpected results if you have more than one 'books'
element in the library.xml. It will always return the title of the first.
> public String getTitle() {
> return "<c:get select="$library/books/@title" />";
> }
> public String getAuthor() {
> return "<c:get select="$library/books/@author" />";
> }
> }
>
PE> The variable $library is not defined by this template. Assuming that
library is the root element of library.xml, you need something like:
<c:setVariable var="library" select="/*"/>
To 'invoke' this template, you should have the following as the contents for
templates/main.jet:
This can be either in this template, or more often, in the template that
invokes it (usually templates/main.jet).
<%@ taglib prefix="ws" id="org.eclipse.jet.workspaceTags" %>
<c:setVariable var="library" select="/*"/>
<ws:file
path=" {$org.eclipse.jet.resource.project.name}/testOutput/test.jav a "
template="templates/test.jet" />
Paul
|
|
|
Powered by
FUDForum. Page generated in 0.03676 seconds