Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [henshin-dev] Java Package import at Rule Level

Hi Markus,

can you try to pass the class loader of the class that you want to use as parameter of the DelegatingClassLoader?

Cheers,
Christian


2014-09-23 10:00 GMT+02:00 <mke@xxxxxxxxxx>:

Hi Christian,

 

thanks for the update on the issue. I tested the newest git pull and unfortunately the example only works, if the Class to load is in the same subpackage as the rule itself.

 

We obtain the same issue, if the Class to load is in a neighbor package (not sub to the package where the rule is in).

 

Greetings,

 

i. A. Markus Klenke
Software und Consulting
--
TEAM GmbH
Hermann-Löns-Str. 88 | 33104 Paderborn | Fon +49 5254 8008-55 | Fax +49 5254 8008-19
Mail mke@xxxxxxxxxx | Web http://www.team-pb.de/
------------------------------------
Geschäftsführer: Heike Käferle, Michael Baranowski, Dr. Winfried Materna, Helmut an de Meulen
Geschäftssitz: Paderborn, HRB 955 Amtsgericht Paderborn, UST-IdNr.: DE 126336040
-------------
TEAM-Veranstaltungen in 2014:

Praxistag bei der Diesel Technic AG am 09. Oktober in Kirchdorf

TEAM auf der DOAG Konferenz + Ausstellung vom 18.-21. November in Nürnberg
15. TEAMLogistikforum am 25. November in Paderborn

http://www.team-pb.de/veranstaltungen
-------------

 

Von: henshin-dev-bounces@xxxxxxxxxxx [mailto:henshin-dev-bounces@xxxxxxxxxxx] Im Auftrag von Christian Krause
Gesendet: Montag, 22. September 2014 10:59


An: Henshin developers mailing list
Betreff: Re: [henshin-dev] Java Package import at Rule Level

 

Hi Markus,

 

the change with the example is still under review. When it is merged, you need some additional code in your application so that the script engine can find your classes. It looks more or less like this:

 

Thread thread = Thread.currentThread();
thread.setContextClassLoader(new InterpreterUtil.DelegatingClassLoader(thread.getContextClassLoader(), getClassLoader());

Engine engine = ...

 

Cheers,

Christian

 

 

 

 

2014-09-22 10:21 GMT+02:00 <mke@xxxxxxxxxx>:

Hi Christian,

 

unfortunately I get the same error results when using the latest nightly build of Henshin.

 

When trying to import a class or package (“de.teampb.MyClass” or “de.teampb”)

 

I get the following exception:

 

java.lang.RuntimeException: ReferenceError: "de" is not defined in <eval> at line number 1

at org.eclipse.emf.henshin.interpreter.impl.EngineImpl.evalAttributeExpression(EngineImpl.java:927)

       at org.eclipse.emf.henshin.interpreter.impl.EngineImpl.createChanges(EngineImpl.java:880)

       at org.eclipse.emf.henshin.interpreter.impl.EngineImpl.createChanges(EngineImpl.java:897)

       at org.eclipse.emf.henshin.interpreter.impl.EngineImpl.createChange(EngineImpl.java:782)

       at org.eclipse.emf.henshin.interpreter.impl.RuleApplicationImpl.execute(RuleApplicationImpl.java:99)

       at org.eclipse.emf.henshin.interpreter.impl.UnitApplicationImpl.executeRule(UnitApplicationImpl.java:175)

       at org.eclipse.emf.henshin.interpreter.impl.UnitApplicationImpl.doExecute(UnitApplicationImpl.java:99)

       at org.eclipse.emf.henshin.interpreter.impl.UnitApplicationImpl.execute(UnitApplicationImpl.java:89)

       at org.eclipse.emf.henshin.interpreter.impl.UnitApplicationImpl.executeSequentialUnit(UnitApplicationImpl.java:222)

       at org.eclipse.emf.henshin.interpreter.impl.UnitApplicationImpl.doExecute(UnitApplicationImpl.java:103)

       at org.eclipse.emf.henshin.interpreter.impl.UnitApplicationImpl.execute(UnitApplicationImpl.java:89)

       at org.eclipse.emf.henshin.interpreter.impl.UnitApplicationImpl.executeSequentialUnit(UnitApplicationImpl.java:222)

       at org.eclipse.emf.henshin.interpreter.impl.UnitApplicationImpl.doExecute(UnitApplicationImpl.java:103)

       at org.eclipse.emf.henshin.interpreter.impl.UnitApplicationImpl.execute(UnitApplicationImpl.java:89)

       at org.eclipse.emf.henshin.interpreter.impl.UnitApplicationImpl.executeSequentialUnit(UnitApplicationImpl.java:222)

       at org.eclipse.emf.henshin.interpreter.impl.UnitApplicationImpl.doExecute(UnitApplicationImpl.java:103)

       at org.eclipse.emf.henshin.interpreter.impl.UnitApplicationImpl.execute(UnitApplicationImpl.java:89)

       at de.teampb.rma.transformator.jasper.concretize.ReportsConcretization.applyRule(ReportsConcretization.java:171)

       at de.teampb.rma.transformator.jasper.concretize.ReportsConcretization.executeRuleSet(ReportsConcretization.java:101)

       at de.teampb.rma.transformator.jasper.run.Transformator.main(Transformator.java:48)

 

using the legacy-rhino-package import mechanism (“Packages.de.teampb”) leads to the error I already posted:

 

java.lang.AssertionError: __noSuchProperty__ placeholder called

       at jdk.nashorn.internal.objects.NativeJavaImporter.__noSuchProperty__(NativeJavaImporter.java:109)

       at jdk.nashorn.internal.runtime.ScriptFunctionData.invoke(ScriptFunctionData.java:520)

       at jdk.nashorn.internal.runtime.ScriptFunction.invoke(ScriptFunction.java:206)

       at jdk.nashorn.internal.runtime.ScriptRuntime.apply(ScriptRuntime.java:378)

       at jdk.nashorn.internal.runtime.ScriptObject.invokeNoSuchProperty(ScriptObject.java:2064)

       at jdk.nashorn.internal.runtime.ScriptObject.megamorphicGet(ScriptObject.java:1787)

       at jdk.nashorn.internal.scripts.Script$\^eval\_.runScript(<eval>:1)

       at jdk.nashorn.internal.runtime.ScriptFunctionData.invoke(ScriptFunctionData.java:498)

       at jdk.nashorn.internal.runtime.ScriptFunction.invoke(ScriptFunction.java:206)

       at jdk.nashorn.internal.runtime.ScriptRuntime.apply(ScriptRuntime.java:378)

       at jdk.nashorn.api.scripting.NashornScriptEngine.evalImpl(NashornScriptEngine.java:546)

       at jdk.nashorn.api.scripting.NashornScriptEngine.evalImpl(NashornScriptEngine.java:528)

       at jdk.nashorn.api.scripting.NashornScriptEngine.evalImpl(NashornScriptEngine.java:524)

       at jdk.nashorn.api.scripting.NashornScriptEngine.eval(NashornScriptEngine.java:194)

       at javax.script.AbstractScriptEngine.eval(Unknown Source)

       at org.eclipse.emf.henshin.interpreter.impl.ScriptEngineWrapper.eval(ScriptEngineWrapper.java:91)

       at org.eclipse.emf.henshin.interpreter.impl.EngineImpl.evalAttributeExpression(EngineImpl.java:923)

       at org.eclipse.emf.henshin.interpreter.impl.EngineImpl.createChanges(EngineImpl.java:880)

       at org.eclipse.emf.henshin.interpreter.impl.EngineImpl.createChanges(EngineImpl.java:897)

       at org.eclipse.emf.henshin.interpreter.impl.EngineImpl.createChange(EngineImpl.java:782)

       at org.eclipse.emf.henshin.interpreter.impl.RuleApplicationImpl.execute(RuleApplicationImpl.java:99)

       at org.eclipse.emf.henshin.interpreter.impl.UnitApplicationImpl.executeRule(UnitApplicationImpl.java:175)

       at org.eclipse.emf.henshin.interpreter.impl.UnitApplicationImpl.doExecute(UnitApplicationImpl.java:99)

       at org.eclipse.emf.henshin.interpreter.impl.UnitApplicationImpl.execute(UnitApplicationImpl.java:89)

       at org.eclipse.emf.henshin.interpreter.impl.UnitApplicationImpl.executeSequentialUnit(UnitApplicationImpl.java:222)

       at org.eclipse.emf.henshin.interpreter.impl.UnitApplicationImpl.doExecute(UnitApplicationImpl.java:103)

       at org.eclipse.emf.henshin.interpreter.impl.UnitApplicationImpl.execute(UnitApplicationImpl.java:89)

       at org.eclipse.emf.henshin.interpreter.impl.UnitApplicationImpl.executeSequentialUnit(UnitApplicationImpl.java:222)

       at org.eclipse.emf.henshin.interpreter.impl.UnitApplicationImpl.doExecute(UnitApplicationImpl.java:103)

       at org.eclipse.emf.henshin.interpreter.impl.UnitApplicationImpl.execute(UnitApplicationImpl.java:89)

       at org.eclipse.emf.henshin.interpreter.impl.UnitApplicationImpl.executeSequentialUnit(UnitApplicationImpl.java:222)

       at org.eclipse.emf.henshin.interpreter.impl.UnitApplicationImpl.doExecute(UnitApplicationImpl.java:103)

       at org.eclipse.emf.henshin.interpreter.impl.UnitApplicationImpl.execute(UnitApplicationImpl.java:89)

       at de.teampb.rma.transformator.jasper.concretize.ReportsConcretization.applyRule(ReportsConcretization.java:166)

       at de.teampb.rma.transformator.jasper.concretize.ReportsConcretization.executeRuleSet(ReportsConcretization.java:101)

       at de.teampb.rma.transformator.jasper.run.Transformator.main(Transformator.java:48)

 

Just to make sure, I use the right global importing mechanism, I create the Engine by calling

 

new EngineImpl(new String[]{"de.teampb"});

 

Thanks for keeping active on this point and for all the effort coming with this!

 

If I can help you with anything regarding this point or if I should do some investigation, please let me know.

 

Greetings,

 

Markus

 

Von: henshin-dev-bounces@xxxxxxxxxxx [mailto:henshin-dev-bounces@xxxxxxxxxxx] Im Auftrag von Christian Krause
Gesendet: Samstag, 20. September 2014 14:19


An: Henshin developers mailing list
Betreff: Re: [henshin-dev] Java Package import at Rule Level

 

Hi,

 

I found a working solution. The trick is to create a class loader that can delegate to the Eclipse class loader and the current's thread class loader. It is not enough to just use the Eclipse class loader because then for some reason the _javascript_ engine cannot be loaded.

 

For convenience I added a minimal delegating class loader to the InterpreterUtil class. I wanted to avoid to mess around with the class loader inside the engine. There is also an example and a test now. The change still needs to be reviewed:

 

 

Cheers,
Christian 

 

 

2014-09-15 21:58 GMT+02:00 Christian Krause <henshin.ck@xxxxxxxxx>:

I found a similar issue and solution at GitHub: https://github.com/walterhiggins/ScriptCraft/pull/154

 

I had a quick try but in the first run I was not able to instantiate the script engine.

 

Christian

 

 

2014-09-08 21:22 GMT+02:00 Christian Krause <henshin.ck@xxxxxxxxx>:

A first analysis shows that the problem does not occur in stand-alone Java applications or when using a Java built-in method. When trying to run it in an Eclipse application (e.g. plug-in JUnit tests), the error occurs. Also when I replace the JavaImporter by importPackage(), the problem still occurs. Maybe it is related to the classloader.

 

Christian

 

2014-09-04 8:05 GMT+02:00 <mke@xxxxxxxxxx>:

 

Hi Christian,

 

most commonly, we use Java Classes to change a parameter found in the LHS to create a new attribute in the RHS.

 

Let’s say I have a class StringManipulator in the package de.teampb.utils that has a static method public String manipulate(String anyString).

 

Then my _expression_ in the RHS would be <<create>> attributeName = StringManipulator.manipulate(stringParameterFromLHS).

 

I also tried to access via full qualified name, but then js is arguing about the not defined parameter de.

 

Greetings,

 

Markus

 

Von: henshin-dev-bounces@xxxxxxxxxxx [mailto:henshin-dev-bounces@xxxxxxxxxxx] Im Auftrag von Christian Krause
Gesendet: Mittwoch, 3. September 2014 13:35


An: Henshin developers mailing list
Betreff: Re: [henshin-dev] Java Package import at Rule Level

 

Hi Markus,

how does the _expression_ look like?

 

Cheers,
Christian

 

2014-09-03 12:50 GMT+02:00 <mke@xxxxxxxxxx>:

I’tried different variations of calls.

 

The Package, that I try to include is de.teampb.tma

 

for the global import I called the EngineImpl constructor via new String[]{“de.teampb.tma”} and via String[]{de.teampb.tma.ClassName}

 

for the local import on the necessary rule, I added the String to the rule property.

 

All this source is compiled on JDK 7.

 

Greetings and thanks for the help,

 

Markus

 

Von: henshin-dev-bounces@xxxxxxxxxxx [mailto:henshin-dev-bounces@xxxxxxxxxxx] Im Auftrag von Christian Krause
Gesendet: Dienstag, 2. September 2014 10:50


An: Henshin developers mailing list
Betreff: Re: [henshin-dev] Java Package import at Rule Level

 

How does your package import and your _expression_ look like?

 

Cheers,

Christian

 

2014-09-02 9:20 GMT+02:00 <mke@xxxxxxxxxx>:

Hi Christian,

 

unfortunately the patch did not work out for me.

 

Getting the following stack trace:

 

Exception in thread "main" java.lang.AssertionError: __noSuchProperty__ placeholder called

       at jdk.nashorn.internal.objects.NativeJavaImporter.__noSuchProperty__(NativeJavaImporter.java:109)

       at jdk.nashorn.internal.scripts.Script$\^eval\_.runScript(<eval>:1)

       at jdk.nashorn.internal.runtime.ScriptFunctionData.invoke(ScriptFunctionData.java:498)

       at jdk.nashorn.internal.runtime.ScriptFunction.invoke(ScriptFunction.java:206)

       at jdk.nashorn.internal.runtime.ScriptRuntime.apply(ScriptRuntime.java:378)

       at jdk.nashorn.api.scripting.NashornScriptEngine.evalImpl(NashornScriptEngine.java:546)

       at jdk.nashorn.api.scripting.NashornScriptEngine.evalImpl(NashornScriptEngine.java:528)

       at jdk.nashorn.api.scripting.NashornScriptEngine.evalImpl(NashornScriptEngine.java:524)

       at jdk.nashorn.api.scripting.NashornScriptEngine.eval(NashornScriptEngine.java:194)

       at javax.script.AbstractScriptEngine.eval(Unknown Source)

       at org.eclipse.emf.henshin.interpreter.impl.ScriptEngineWrapper.eval(ScriptEngineWrapper.java:99)

       at org.eclipse.emf.henshin.interpreter.impl.EngineImpl.evalAttributeExpression(EngineImpl.java:909)

       at org.eclipse.emf.henshin.interpreter.impl.EngineImpl.createChanges(EngineImpl.java:869)

       at org.eclipse.emf.henshin.interpreter.impl.EngineImpl.createChanges(EngineImpl.java:884)

       at org.eclipse.emf.henshin.interpreter.impl.EngineImpl.createChange(EngineImpl.java:761)

       at org.eclipse.emf.henshin.interpreter.impl.RuleApplicationImpl.execute(RuleApplicationImpl.java:99)

       at org.eclipse.emf.henshin.interpreter.impl.UnitApplicationImpl.executeRule(UnitApplicationImpl.java:175)

       at org.eclipse.emf.henshin.interpreter.impl.UnitApplicationImpl.doExecute(UnitApplicationImpl.java:99)

       at org.eclipse.emf.henshin.interpreter.impl.UnitApplicationImpl.execute(UnitApplicationImpl.java:89)

       at org.eclipse.emf.henshin.interpreter.impl.UnitApplicationImpl.executeSequentialUnit(UnitApplicationImpl.java:222)

       at org.eclipse.emf.henshin.interpreter.impl.UnitApplicationImpl.doExecute(UnitApplicationImpl.java:103)

       at org.eclipse.emf.henshin.interpreter.impl.UnitApplicationImpl.execute(UnitApplicationImpl.java:89)

       at org.eclipse.emf.henshin.interpreter.impl.UnitApplicationImpl.executeSequentialUnit(UnitApplicationImpl.java:222)

       at org.eclipse.emf.henshin.interpreter.impl.UnitApplicationImpl.doExecute(UnitApplicationImpl.java:103)

       at org.eclipse.emf.henshin.interpreter.impl.UnitApplicationImpl.execute(UnitApplicationImpl.java:89)

       at org.eclipse.emf.henshin.interpreter.impl.UnitApplicationImpl.executeSequentialUnit(UnitApplicationImpl.java:222)

       at org.eclipse.emf.henshin.interpreter.impl.UnitApplicationImpl.doExecute(UnitApplicationImpl.java:103)

       at org.eclipse.emf.henshin.interpreter.impl.UnitApplicationImpl.execute(UnitApplicationImpl.java:89)

 

regardless, which import mechanism I’m using.

 

Greetings,

 

Markus

Von: henshin-dev-bounces@xxxxxxxxxxx [mailto:henshin-dev-bounces@xxxxxxxxxxx] Im Auftrag von Christian Krause


Gesendet: Freitag, 22. August 2014 14:04


An: Henshin developers mailing list

Betreff: Re: [henshin-dev] Java Package import at Rule Level

 

Hi Markus,

 

there is currently no global import mechanism (you could inject them into the JS engine I guess, but thats not really convenient). Could you maybe send us a patch of your implementation? 

 

Cheers,

Christian

 

PS: Please note that if we include it, it will be of course published under the terms of the EPL. If you don't want that, please don't send us anything...

 

2014-08-22 12:25 GMT+02:00 <mke@xxxxxxxxxx>:

Just wanted to say thanks for an implementation of a JS- Java Package import Feature at Rule level. Works like a charm!

 

A small question regarding global imports of java packages into the JS-Engine:

 

Would it be possible to extend the Engine interface resp. EngineImpl with a constructor, where String array of globally imported packages can be set, because we use java methods quite regularly, and it would save a huge amount of time, if we could import all libraries at once during the startup of the engine. I’ve done it for my local work, but I’m not sure if anything else will break using this extension.

 

Or is there already a global import mechanism, that I overlooked?

 

Greetings,

 

Markus

 

Von: henshin-dev-bounces@xxxxxxxxxxx [mailto:henshin-dev-bounces@xxxxxxxxxxx] Im Auftrag von Christian Krause
Gesendet: Mittwoch, 20. August 2014 19:24
An: Henshin developers mailing list
Betreff: [henshin-dev] Git config for Windows

 

Hi,

please use this Git config in Windows:

 

core.autocrlf=true

core.filemode=false

 

If you have dirty projects due to windows line endings, try a hard reset after setting the config.

 

Cheers,

Christian


_______________________________________________
henshin-dev mailing list
henshin-dev@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/henshin-dev

 


_______________________________________________
henshin-dev mailing list
henshin-dev@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/henshin-dev

 


_______________________________________________
henshin-dev mailing list
henshin-dev@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/henshin-dev

 


_______________________________________________
henshin-dev mailing list
henshin-dev@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/henshin-dev

 


_______________________________________________
henshin-dev mailing list
henshin-dev@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/henshin-dev

 


_______________________________________________
henshin-dev mailing list
henshin-dev@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/henshin-dev

 

 

 


_______________________________________________
henshin-dev mailing list
henshin-dev@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/henshin-dev

 


_______________________________________________
henshin-dev mailing list
henshin-dev@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/henshin-dev


Back to the top