Home » Modeling » M2T (model-to-text transformation) » [Acceleo/MoDisco] Problem generating Java source code
[Acceleo/MoDisco] Problem generating Java source code [message #528009] |
Sun, 18 April 2010 17:31 |
Philip Mayer Messages: 30 Registered: July 2009 |
Member |
|
|
Dear all,
I am having a problem generating java source code from java models using MoDisco (similar but not identical to the problem of Timothy Marc).
I am running a Junit4 PLUGIN test case to create a java model and to write it out as java code.
First: Creating the model works nicely, and it is serialised just fine (I can open the resulting file "x.javaxmi" in Eclipse with the MoDisco Model Browser):
Model model = JavaFactory.eINSTANCE.createModel();
ResourceSet resourceSet = new ResourceSetImpl();
URI fileURI = URI.createFileURI("x.javaxmi");
XMIResource xmlResource = (XMIResource) resourceSet
.createResource(fileURI);
xmlResource.getContents().add(model);
xmlResource.save(null);
The problem arises when I try to generate code with the following fragment:
Generate_JavaStructures s = new Generate_JavaStructures(model,
new File("."), new ArrayList<Object>());
s.doGenerate(new BasicMonitor());
I get the error message
org.eclipse.emf.ecore.resource.Resource$IOWrappedException: Package with uri 'http://www.eclipse.org/acceleo/mtl/0.8.0' not found.
I have installed a plain helios m6 to test this (I understood that I need helios, correct?) I have used the following packages, nothing else is installed;
I installed eclipse-modeling-helios-M6-incubation-win32.zip, afterwards, via downloaded JAR update sites and the "Install New Software", the following (all these were required to allow me to finally install "MODISCO-Update-0.8.0M6"
- m2t-jet-Update-1.1.0M6
- m2m-atl-Update-3.1.0M6
- mdt-ocl-Update-3.0.0M6
- m2t-acceleo-Update-incubation-3.0.0M6
- MODISCO-Update-0.8.0M6
Please let me know how to correct this problem, and whether there is an easier way of installing all of this - I am probably doing something horribly wrong
(By the way, another question would by why I need to serialize the model first - the generation seems to require an attached resource set. Is there another way?).
Thanks a lot!
Philip
[Updated on: Mon, 19 April 2010 06:35] Report message to a moderator
|
|
|
Re: [Acceleo/MoDisco] Problem generating Java source code [message #528132 is a reply to message #528009] |
Mon, 19 April 2010 13:19 |
|
This is a multi-part message in MIME format.
--------------060007020206010203060905
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Hi Philip,
I'd say yours is the "easy" problem I told Timothy Marc about at the
very beginning of his thread (and which wasn't the issue for him :p).
First of all, Helios is not required for Acceleo 3.0. We're compatible
with Eclipse 3.4, Eclipse 3.5 and Eclipse 3.6. The changes that can
arise are behavioral changes in the OCL parsing : an Acceleo module that
parses well in 3.6 (with OCL 3.0) may not parse in Eclipse 3.4 (with OCL
1.2). However a module that can be parsed in 3.4 will parser in 3.6. The
runtime is fully compatible as far as my tests have gone : a template
parsed in 3.6, 3.5 or 3.4 can be evaluated in all three seamlessly.
That aside, what you have here is that you compiled a module (mtl file)
with Acceleo previous to 3.0M6 (thus creating an emtl file) ; yet you
try to load and evaluate this compiled emtl with Acceleo 3.0M6. The
issue is : we changed the Acceleo metamodels' URIs for M6. What was
"http://www.eclipse.org/acceleo/mtl/0.8.0" before is now
"http://www.eclipse.org/acceleo/mtl/3.0".
Recompile your generation modules with your current Acceleo (3.0M6) and
you shouldn't see this problem again.
Laurent Goubet
Obeo
P.S: if you are not responsible for the module files
("generate_javastucture.mtl"), but try to run the generation from your
code anyway, you'll have to switch back to the Acceleo version the
module manager uses, in this case, anything previous to 3.0M6.
Philip Mayer wrote:
> Dear all,
>
> I am having a problem generating java source code from java models using
> MoDisco (similar but not identical to the problem of Timothy Marc).
>
> I am running a Junit4 PLUGIN test case to create a java modeland to
> serialise it.
> First: Creating the model works nicely, and it is serialised just fine
> (I can open the resulting file "x.javaxmi" in Eclipse with the MoDisco
> Model Browser):
>
>
> Model model = JavaFactory.eINSTANCE.createModel();
> ResourceSet resourceSet = new ResourceSetImpl();
> URI fileURI = URI.createFileURI("x.javaxmi");
>
> XMIResource xmlResource = (XMIResource) resourceSet
> .createResource(fileURI);
> xmlResource.getContents().add(model);
> xmlResource.save(null);
>
>
> The problem arises when I try to generate code with the following fragment:
>
>
> Generate_JavaStructures s = new Generate_JavaStructures(model,
> new File("."), new ArrayList<Object>());
> s.doGenerate(new BasicMonitor());
>
>
> I get the error message
>
>
> org.eclipse.emf.ecore.resource.Resource$IOWrappedException: Package with
> uri 'http://www.eclipse.org/acceleo/mtl/0.8.0' not found.
>
> I have installed a plain helios m6 to test this (I understood that I
> need helios, correct?) I have used the following packages, nothing else
> is installed;
>
> I installed eclipse-modeling-helios-M6-incubation-win32.zip, afterwards,
> via downloaded JAR update sites and the "Install New Software", the
> following (all these were required to allow me to finally install
> "MODISCO-Update-0.8.0M6"
>
>
> m2t-jet-Update-1.1.0M6
> m2m-atl-Update-3.1.0M6
> mdt-ocl-Update-3.0.0M6
> m2t-acceleo-Update-incubation-3.0.0M6
> MODISCO-Update-0.8.0M6
>
>
> Please let me know how to correct this problem, and whether there is an
> easier way of installing all of this - I am probably doing something
> horribly wrong ;)
>
> Thanks a lot!
>
> Philip
>
--------------060007020206010203060905
Content-Type: text/x-vcard; charset=utf-8;
name="laurent_goubet.vcf"
Content-Transfer-Encoding: base64
Content-Disposition: attachment;
filename="laurent_goubet.vcf"
YmVnaW46dmNhcmQNCmZuOkxhdXJlbnQgR291YmV0DQpuOkdvdWJldDtMYXVy ZW50DQpvcmc6
PGEgaHJlZj0iaHR0cDovL3d3dy5vYmVvLmZyIj5PYmVvPC9hPg0KZW1haWw7 aW50ZXJuZXQ6
bGF1cmVudC5nb3ViZXRAb2Jlby5mcg0KdXJsOmh0dHA6Ly93d3cub2Jlby5m cg0KdmVyc2lv
bjoyLjENCmVuZDp2Y2FyZA0KDQo=
--------------060007020206010203060905--
|
|
| |
Re: [Acceleo/MoDisco] Problem generating Java source code [message #528329 is a reply to message #528196] |
Tue, 20 April 2010 07:54 |
|
This is a multi-part message in MIME format.
--------------030005040201010405030009
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Hi Philip,
Ok, much I didn't understand in your first post, notably the relation
with modisco. In short : you need to install an earlier version of
Acceleo to use the generators bundled with modisco. Easiest way to do
this is to go to
http://www.eclipse.org/modeling/m2t/downloads/?project=accel eo and
download the all in one update site for the 0.9.0M5 version (which is
the build previous to 3.0.0M6). This particular update site is on
http://www.eclipse.org/modeling/download.php?file=/modeling/ m2t/acceleo/downloads/drops/0.9.0/S201002020636/m2t-acceleo- Update-incubation-0.9.0M5.zip
..
For a longer explanation, see my comments inlined below :p.
Laurent Goubet
Obeo
Philip Mayer wrote:
> Dear Laurent,
>
> first of all, thanks for your answer. I believe, however, that my
> problem is more with MoDisco than with Acceleo.
> What I am trying to do is invoke the modisco java code generator, as
> described on the website
> http://wiki.eclipse.org/MoDisco/Components/Java/Documentatio n/0.8#Java_Generation
> So let's go away from my initial code and to just invoking this code
> generation.
>
>> P.S: if you are not responsible for the module files
>> ("generate_javastucture.mtl"),
>
> You are correct, I am not. I am simply trying to use this file, which is
> provided in the "org.eclipse.gmt.modisco.java.generation" plugin, to
> generate java code. As far as I understand the picture, the code
> generation is a modisco feature, but it requires acceleo to run (and
> herein lies the problem).
Yup, and they used Acceleo 0.8.* or 0.9.* to compile their generator,
which is why you cannot launch the generation with Acceleo 3.0 (see my
previous mail).
>
> Now, the MoDisco website (http://wiki.eclipse.org/MoDisco/Components)
> states that the full java metamodel and the code generation is only
> available in "MoDisco 0.8". The same page also says that "MoDisco 0.8"
> is for helios.
> So I assumed that I need Helios. I actually tried checking out the
> modisco plugins from SVN in a galileo eclipse instance, too, but there
> were lots of compile errors (for example, the class import
> org.eclipse.acceleo.engine.generation.strategy.DefaultStrate gy is not
> found in the Generate_JavaStructure.java file). So I assume that it
> indeed does not work in Galileo.
True, my comment on us being compatible with Ganymede, Galileo and
Helios was only related to Acceleo ; maintaining compatibility with
different versions of Eclipse is not mandatory and other projects (such
as MoDisco) may not do it.
>
> I thus installed everything in Helios M6 + Acceleo 3.0.0 + the milestone
> modisco update site
> ( http://download.eclipse.org/modeling/gmt/modisco/updates/mil estones/).
> Now, the website
> http://wiki.eclipse.org/MoDisco/Components/Java/Documentatio n/0.8#Java_Generation
> states two methods of invoking the code generator:
>
> a) use the import plugin wizard for the java.generation package and run
> an Acceleo launch configuration for the Generate_JavaStructures class.
> When I do this, I get (in the error log)
>
>
> ERROR: Couldn't load class
> org.eclipse.gmt.modisco.java.generation.files.Generate_JavaS tructures
> from project org.eclipse.gmt.modisco.java.generation
>
> WARN:
> org.eclipse.osgi.framework.internal.core.Framework$Duplicate BundleException:
> Bundle "org.eclipse.gmt.modisco.java.generation" version
> "0.8.0.v201003161136" has already been installed from:
> reference:file:plugins/org.eclipse.gmt.modisco.java.generati on_0.8.0.v201003161136.jar
>
The warning and error are not related, the warning being an information
that we keep for debugging purposes (it'll be removed from the Helios
release, we're mostly done with the underlying problem's correction).
And the error indicating a classpath issue ... yet indeed the issue
seems to lie in having a generator project in both workspace and
installed plugins.
>
>
> b) again, use the import plugin wizard for the java.generation package ,
> but launch the main class not with a Acceleo launch config but as
> standard java app (this should be equivalent to launching it from my own
> plugin) This yields:
>
>
> org.eclipse.emf.ecore.resource.Resource$IOWrappedException: Package with
> uri 'http://www.eclipse.org/acceleo/mtl/0.8.0' not found.
>
And we're back at the initial issue : MoDisco compiles its Acceleo
generator with a version prior to 3.0M6, and you try to load it with
this version. Uninstall 3.0M6 and switch back to anything previous to
it, and the issue shall be gone.
>
>
> So, in a) I seem to not be allowed to have a copy of the .generation
> project in the workspace and somehow it cannot find the class, and in
> b), the acceleo version does not match, because the
> generate_javastructure.emtl which is provided in "MoDisco 0.8" in the
> "org.eclipse.gmt.modisco.java.generation" plugin carries the namespace
> "http://www.eclipse.org/acceleo/mtl/0.8.0", but the Acceleo version
> installed in Helios is actually 3.0.0.
>
> I sadly do not know how to proceed. Can you point out to me how to set
> up an Eclipse installation in which I can use the MoDisco java model
> generator? What is the preferred way of doing this?
>
>
> Thanks,
>
> Philip
--------------030005040201010405030009
Content-Type: text/x-vcard; charset=utf-8;
name="laurent_goubet.vcf"
Content-Transfer-Encoding: base64
Content-Disposition: attachment;
filename="laurent_goubet.vcf"
YmVnaW46dmNhcmQNCmZuOkxhdXJlbnQgR291YmV0DQpuOkdvdWJldDtMYXVy ZW50DQpvcmc6
PGEgaHJlZj0iaHR0cDovL3d3dy5vYmVvLmZyIj5PYmVvPC9hPg0KZW1haWw7 aW50ZXJuZXQ6
bGF1cmVudC5nb3ViZXRAb2Jlby5mcg0KdXJsOmh0dHA6Ly93d3cub2Jlby5m cg0KdmVyc2lv
bjoyLjENCmVuZDp2Y2FyZA0KDQo=
--------------030005040201010405030009--
|
|
| |
Re: [Acceleo/MoDisco] Problem generating Java source code [message #528402 is a reply to message #528393] |
Tue, 20 April 2010 12:05 |
|
This is a multi-part message in MIME format.
--------------050307030303080409020303
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Philip,
I fail to see where the issue for a) comes from... I'll have to look a
bit more into it.
For b), this seems to be a problem when you select "Java application" in
the launch configuration ; this is under investigation, but I'd say
we're missing a reexport dependency somewhere ^^. In eclipse, select Run
=> Run configurations... => select your Acceleo launch config and in the
dropdown menu at the bottom of the panel switch from "Java application"
to "Acceleo plug-in application". This should allow you to run the
generation.
Laurent Goubet
Obeo
Philip Mayer wrote:
> Dear Laurent,
>
> thanks again for your answer, I now have a better understanding of the
> relationship between the components.
>
> (I have moved my question also to
> http://www.eclipse.org/forums/index.php?t=msg&goto=52823 9&#msg_528239
> but there is no reply yet).
>
> I have done as you suggested and installed HeliosM6 Classic + Acceleo
> (m2t-acceleo-Update-incubation-0.9.0M5) + MoDisco 0.8.0.
>
> regarding a): Trying to run "Generate_JavaStructures.java" as an Acceleo
> launch config now is not possible because it does not even create the
> launch configuration, instead giving a dialog with this message:
>
>
> Plug-In org.eclipse.acceleo.ide.ui was unable to load class
> org.eclipse.acceleo.internal.ide.ui.launching.AcceleoApplica tionTabGroup
>
>
> regarding b): This yields
>
>
> Exception in thread "main" java.lang.NoClassDefFoundError:
> org/eclipse/acceleo/common/internal/utils/compatibility/Acce leoOCLStdLibReflection
>
> at
> org.eclipse.acceleo.engine.internal.environment.AcceleoEnvir onment.getOCLStandardLibraryReflection(AcceleoEnvironment.ja va:66)
>
> at
> org.eclipse.acceleo.engine.internal.evaluation.AcceleoEvalua tionVisitor. <init>(AcceleoEvaluationVisitor.java:145)
>
> at
> org.eclipse.acceleo.engine.internal.environment.AcceleoEnvir onmentFactory.createEvaluationVisitor(AcceleoEnvironmentFact ory.java:150)
>
> at
> org.eclipse.ocl.internal.evaluation.QueryImpl.evaluate(Query Impl.java:146)
> at org.eclipse.ocl.ecore.QueryImpl.evaluate(QueryImpl.java:62)
> at
> org.eclipse.acceleo.engine.generation.AcceleoEngine.doEvalua te(AcceleoEngine.java:320)
>
> at
> org.eclipse.acceleo.engine.generation.AcceleoEngine.evaluate (AcceleoEngine.java:148)
>
> at
> org.eclipse.acceleo.engine.service.AcceleoService.doGenerate Template(AcceleoService.java:593)
>
> at
> org.eclipse.acceleo.engine.service.AcceleoService.doGenerate (AcceleoService.java:438)
>
> at
> org.eclipse.gmt.modisco.java.generation.files.Generate_JavaS tructures.doGenerate(Generate_JavaStructures.java:301)
>
> at
> org.eclipse.gmt.modisco.java.generation.files.Generate_JavaS tructures.main(Generate_JavaStructures.java:280)
>
> Caused by: java.lang.ClassNotFoundException:
> org.eclipse.acceleo.common.internal.utils.compatibility.Acce leoOCLStdLibReflection
>
> at java.net.URLClassLoader$1.run(Unknown Source)
> at java.security.AccessController.doPrivileged(Native Method)
> at java.net.URLClassLoader.findClass(Unknown Source)
> at java.lang.ClassLoader.loadClass(Unknown Source)
> at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
> at java.lang.ClassLoader.loadClass(Unknown Source)
> at java.lang.ClassLoader.loadClassInternal(Unknown Source)
> ... 11 more
>
>
> Is there anything else I am missing? Installation went smoothly with the
> install manager without any errors.
>
> Philip
--------------050307030303080409020303
Content-Type: text/x-vcard; charset=utf-8;
name="laurent_goubet.vcf"
Content-Transfer-Encoding: base64
Content-Disposition: attachment;
filename="laurent_goubet.vcf"
YmVnaW46dmNhcmQNCmZuOkxhdXJlbnQgR291YmV0DQpuOkdvdWJldDtMYXVy ZW50DQpvcmc6
PGEgaHJlZj0iaHR0cDovL3d3dy5vYmVvLmZyIj5PYmVvPC9hPg0KZW1haWw7 aW50ZXJuZXQ6
bGF1cmVudC5nb3ViZXRAb2Jlby5mcg0KdXJsOmh0dHA6Ly93d3cub2Jlby5m cg0KdmVyc2lv
bjoyLjENCmVuZDp2Y2FyZA0KDQo=
--------------050307030303080409020303--
|
|
| | |
Re: [Acceleo/MoDisco] Problem generating Java source code [message #528423 is a reply to message #528416] |
Tue, 20 April 2010 13:18 |
|
This is a multi-part message in MIME format.
--------------070700020608070200050407
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Thanks Fabien,
Using the latest Acceleo build should help on this issue as what Philip
encounters with his last attempt really sounds odd to me.
You talk about problems because of the changes we released along with
Acceleo 3.0M6, do not hesitate to raise bugs or discussions on the
bugzilla or here when you encounter strange behavior with Acceleo ...
Knowing about them allows us to fix the issues :).
Philip, Can you confirm whether Fabien's advice does the trick?
Laurent Goubet
Obeo
Fabien wrote:
> Hi Philip, Hi Laurent,
>
> on MoDisco forum, i propose a way for using MoDisco java generation
> component with last Acceleo 3.0 milestone.
>
> http://www.eclipse.org/forums/index.php?t=msg&goto=52823 9&#msg_528239
>
> Regards.
--------------070700020608070200050407
Content-Type: text/x-vcard; charset=utf-8;
name="laurent_goubet.vcf"
Content-Transfer-Encoding: base64
Content-Disposition: attachment;
filename="laurent_goubet.vcf"
YmVnaW46dmNhcmQNCmZuOkxhdXJlbnQgR291YmV0DQpuOkdvdWJldDtMYXVy ZW50DQpvcmc6
PGEgaHJlZj0iaHR0cDovL3d3dy5vYmVvLmZyIj5PYmVvPC9hPg0KZW1haWw7 aW50ZXJuZXQ6
bGF1cmVudC5nb3ViZXRAb2Jlby5mcg0KdXJsOmh0dHA6Ly93d3cub2Jlby5m cg0KdmVyc2lv
bjoyLjENCmVuZDp2Y2FyZA0KDQo=
--------------070700020608070200050407--
|
|
| |
Goto Forum:
Current Time: Thu Apr 25 08:26:13 GMT 2024
Powered by FUDForum. Page generated in 0.03874 seconds
|