Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » M2T (model-to-text transformation) » Comprehensive list of rules for JET classpath
Comprehensive list of rules for JET classpath [message #54073] Mon, 15 December 2008 19:12 Go to next message
Paul Hammond is currently offline Paul HammondFriend
Messages: 17
Registered: July 2009
Junior Member
Hi Paul,

Despite having been able to develop custom tags and see them run, I'm
having some problems with those that are referring to 3rd party libraries.
I know you've posted on this before, and having read all of those posts
and checked everything I've done, I'm still getting problems, and have
spend over a day making tweaks, stopping and restarting trying to figure
this out to no avail, it's a bit confusing, the JET2 runtime rules of
engagement. I'd just like to clear this up as best as possible.

I'm going to describe what I do to try in light of the fact that JET2 does
some trickery by faking a transformation as a temporary plugin etc. If you
could please show me where I'm going wrong.

I have a JET transformation project just containing templates, let's call
it JETProject.
I also have my own separate plugin project, let's call it
CustomPluginProject, which contains my own custom tags. I have no problem
getting tags recognised, configured as an extension at all.
In the implementation of my tags, they call my own custom non-tag classes,
which I also include in the CustomPluginProject. Everything compiles no
problem.
CustomPluginProject classes refer to quite a few of the Apache Commons
libraries.
To keep everything working in the Eclipse plugin framework, I've created
my own Eclipse plugins for these libraries, and added these as plugin
dependencies to CustomPluginProject. All packages are fully exported in
the manifest.
I export CustomPluginProject to a plugin JAR in the Eclipse plugins
directory, and restart with -clean.
I make CustomPluginProject a plugin dependency of JETProject.
I then 'Run as transformation' my sample XML file.

What I find:

As you've previously posted, JET only sees the classes in the
CustomPluginProject directly, it does not see any of the plugins that
CustomPluginProject itself depends on even if you re-export them.
With that in mind, I manually add one Apache Commons plugin as a plugin
dependency of JETProject.
Just as a test, in the main.jet template, I have some simple Java imports
of the Apache classes, and do some trivial object instantiations. Seems to
work fine. So far so good.
However, when any of the CustomPluginProject classes have to run as part
of a real JET transformation, they must not be able to see any of the one
Apache linrary I manually added because I get a
java.lang.NoClassDefFoundError exception for the same classes I was able
to use in main.jet
If I run these same classes in CustomPluginProject on their own in a
simple Java main, they have no such classpath issues, this is only
happening inside JET.

So I've tried removing the Apache plugin dependency from the JET project,
and adding it as a straight library dependency, which didn't work as in
Java Build Path/Libraries I had added 'Plugin Dependencies' which means
that adding the Apache plugin clashed with the entry in the Plugin
Dependencies coming from CustomPluginProject.

I tried adding it as a system library so it's on the boot classpath (I
assume JETs class loader would have the main Eclipse classloader as a
parent?) and that didn't work either.

I'm at a complete crossroads here, any advice on what I'm doing wrong
would be great.

Is it the case that for any 3rd party library L, that I want to use in my
CustomPluginProject and hence in JETProject at transformation time, I have
to avoid creating it as a plugin and adding it into CustomPluginProject,
but rather add it as an external JAR to both CustomPluginProject and
JETProject and just forget about plugins completely?

What is the sure fire way, regardless of even convenience, that I can set
this up so that I can guarantee that any code I want can be seen by JET?

Thx.

Paul
Re: Comprehensive list of rules for JET classpath [message #54231 is a reply to message #54073] Tue, 16 December 2008 13:58 Go to previous messageGo to next message
Paul Elder is currently offline Paul ElderFriend
Messages: 849
Registered: July 2009
Senior Member
Paul:

Plug-ins that make third party code available to other plug-ins are
possible. But I must warn you, I'm far from an expert on this area. I've
looked around the Orbit project (whose mission in life is to package and
distribute third party JARs for other Eclipse projects). Here's how they
suggest packaging your JAR into a plug-in:

a.. Start the New > Project > Plugin Development > Plug-in from existing JAR
wizard to effectively import the library into a new project.
a.. Enter the new bundle name etc.
a.. Ensure that the Analyze library contents and add dependencies checkbox
is selected.
a.. Ensure that the Unzip the JAR into the project checkbox is selected.
a.. Click Finish

If you haven't read enough already, you can see way too much detail on Orbit
here
( http://wiki.eclipse.org/Adding_Bundles_to_Orbit#Adding_a_lib rary_for_the_first_time)

You would then have to export this JAR or test from a runtime workbench.

As for dependencies. The JET project should only need explicit dependencies
on the plug-ins its Java classes explicitly 'import'. All other dependences
will be resolved through the magic of OSGi. Your tag library plug-in should
have a dependency on the third party JAR plugin.

Finally, before you go even this far, there is a chance that your Apache
commons JAR is already in Orbit. A quick look in the plugins directory of my
Eclipse install shows the following Apache plug-ins:

org.apache.commons.codec
org.apache.commons.el
org.apache.commons.httpclient
org.apache.commons.jxpath
org.apache.commons.lang
org.apache.commons.logging

And, there are a pile of other apache plug-ins, too!

Paul
Re: Comprehensive list of rules for JET classpath [message #54467 is a reply to message #54231] Wed, 17 December 2008 16:04 Go to previous message
Paul Hammond is currently offline Paul HammondFriend
Messages: 17
Registered: July 2009
Junior Member
Yes, I am using the existing Eclipse Apache commons plugins where I can.

When I add my plugins as dependencies to my custom tags plugin project, I
click Properties on each one and check the 'Reexport dependency' on them.
I guess this makes JET then have explicit dependencies on these projects
instead of just depending on my custom tags plugin alone.

That seemed to work for me in that things got to where some code I wanted
executed was getting executed now with no missing class exceptions.

However I made some modifications, added a new 3rd library as a plugin I
prepared, using the same method, made some code changes, re exported,
restarted Eclipse etc, and now I just get:

'Could not load template error' with no log messages on the console,
problem or error view so I've nothing to go on.

The setup, most likely down to me, is just very brittle.

Paul
Previous Topic:Problem loading model after updating to latest version of JET
Next Topic:Using your own context or writer
Goto Forum:
  


Current Time: Sun Nov 23 14:59:03 GMT 2014

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

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