Cross Plugin use of classes

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Cross Plugin use of classes

Paul Wölfel-2
Hi Josm Devs!

TLDR: I can't access any classes from other plugins, I receive a
ClassNotFoundException.
This did work before (working on 12321, broken on 12327)

I wanted to update the areaselector plugin (
https://github.com/JOSM/areaselector) and include new functionality which
is based on utilsplugin2. I am able to compile my code, but on runtime it
failed to load the ReplaceGeometryUtils class with a
ClassNotFoundException. The strange thing is, that the utilsplugin2 had
already been loaded and included in the requirements of areaselector. With
a reference to ReplaceGeometryUtils my plugin failed to load with a
ClassNotFoundException even if the class was not accessed.(
https://github.com/JOSM/areaselector/blob/master/src/org/openstreetmap/josm/plugins/areaselector/AreaSelectorPlugin.java#L39)
As this did not work I implemented the logic myself.

I'm using a second optional plugin called austriaaddresshelper (
https://github.com/JOSM/austriaaddresshelper). This did work before and I
was getting a ClassNotFoundException, if the plugin wasn't loaded. This
exception is thrown at AreaSelectorAction line 263 (
https://github.com/JOSM/areaselector/blob/master/src/org/openstreetmap/josm/plugins/areaselector/AreaSelectorAction.java#L263
).

Starting from some version after 12327 of JOSM a ClassNotFoundException is
thrown, even if the plugin is loaded and can be used. I even played around
with the Scripting plugin and
Class.forName("org.openstreetmap.josm.plugins.austriaaddresshelper.AustriaAddressHelperAction")
or even
Class.forName("org.openstreetmap.josm.plugins.areaselector.AreaSelectorAction")
always fails.

So finally my question:
Have there been any changes to the ClassLoader which prevent accessing
classes from another plugin and how can I fix this?

This issue can be reproduced with the Scripting plugin an Groovy with this
simple line of Code (you need areaselector plugin installed):
println
Class.forName("org.openstreetmap.josm.plugins.areaselector.AreaSelectorAction").toString()

Script execution has failed.
javax.script.ScriptException: javax.script.ScriptException:
java.lang.ClassNotFoundException:
org.openstreetmap.josm.plugins.areaselector.AreaSelectorAction
at
org.codehaus.groovy.jsr223.GroovyScriptEngineImpl.eval(GroovyScriptEngineImpl.java:155)



--


Mit freundlichen Grüßen
Paul Wölfel

Email [hidden email]
Tel. +43 664 88 533 801
Pappelweg 9/2/6
7100 Neusiedl am See
Austria
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Cross Plugin use of classes

Paul Wölfel-2
I think I found the cause of my issue, it is the plugin ClassLoader change
in 12322 (
https://josm.openstreetmap.de/changeset?sfp_email=&sfph_mail=&reponame=josm&new=12322%40trunk&old=12321%40trunk)
which relates to #14901 (https://josm.openstreetmap.de/ticket/14901).

I've added austriaaddresshelper to the required plugins (
https://github.com/JOSM/areaselector/commit/2f08c13dd0f5d9fd3cb2b62e6091bd696f0f8a8c),
but I'm still not able to access the class.

<property name="plugin.requires" value="log4j;austriaaddresshelper"/>

If I read the code diff of 12322 (
https://josm.openstreetmap.de/changeset?sfp_email=&sfph_mail=&reponame=josm&new=12322%40trunk&old=12321%40trunk)
correctly, this should do the trick, but it's still not working out.
for (String depName : info.getRequiredPlugins()) {

Is there someone who can help me with that issue, or should I open a bug
tracker?

Paul Wölfel <[hidden email]> schrieb am Sa., 15. Juli 2017 um 20:27 Uhr:

> Hi Josm Devs!
>
> TLDR: I can't access any classes from other plugins, I receive a
> ClassNotFoundException.
> This did work before (working on 12321, broken on 12327)
>
> I wanted to update the areaselector plugin (
> https://github.com/JOSM/areaselector) and include new functionality which
> is based on utilsplugin2. I am able to compile my code, but on runtime it
> failed to load the ReplaceGeometryUtils class with a
> ClassNotFoundException. The strange thing is, that the utilsplugin2 had
> already been loaded and included in the requirements of areaselector. With
> a reference to ReplaceGeometryUtils my plugin failed to load with a
> ClassNotFoundException even if the class was not accessed.(
> https://github.com/JOSM/areaselector/blob/master/src/org/openstreetmap/josm/plugins/areaselector/AreaSelectorPlugin.java#L39)
> As this did not work I implemented the logic myself.
>
> I'm using a second optional plugin called austriaaddresshelper (
> https://github.com/JOSM/austriaaddresshelper). This did work before and I
> was getting a ClassNotFoundException, if the plugin wasn't loaded. This
> exception is thrown at AreaSelectorAction line 263 (
> https://github.com/JOSM/areaselector/blob/master/src/org/openstreetmap/josm/plugins/areaselector/AreaSelectorAction.java#L263
> ).
>
> Starting from some version after 12327 of JOSM a ClassNotFoundException is
> thrown, even if the plugin is loaded and can be used. I even played around
> with the Scripting plugin and
> Class.forName("org.openstreetmap.josm.plugins.austriaaddresshelper.AustriaAddressHelperAction")
> or even
> Class.forName("org.openstreetmap.josm.plugins.areaselector.AreaSelectorAction")
> always fails.
>
> So finally my question:
> Have there been any changes to the ClassLoader which prevent accessing
> classes from another plugin and how can I fix this?
>
> This issue can be reproduced with the Scripting plugin an Groovy with this
> simple line of Code (you need areaselector plugin installed):
> println
> Class.forName("org.openstreetmap.josm.plugins.areaselector.AreaSelectorAction").toString()
>
> Script execution has failed.
> javax.script.ScriptException: javax.script.ScriptException:
> java.lang.ClassNotFoundException:
> org.openstreetmap.josm.plugins.areaselector.AreaSelectorAction
> at
> org.codehaus.groovy.jsr223.GroovyScriptEngineImpl.eval(GroovyScriptEngineImpl.java:155)
>
>
>
> --
>
>
> Mit freundlichen Grüßen
> Paul Wölfel
>
> Email [hidden email]
> Tel. +43 664 88 533 801
> Pappelweg 9/2/6
> 7100 Neusiedl am See
> Austria
>
--


Mit freundlichen Grüßen
Paul Wölfel

Email [hidden email]
Tel. +43 664 88 533 801
Pappelweg 9/2/6
7100 Neusiedl am See
Austria
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Cross Plugin use of classes

Paul Hartmann-2
One problem, you might be having, is that JOSM ignores the Manifest of
the compiled plugin and still uses the stale information from the
downloaded plugin list.
One way around would be to temporarily rename the plugin (or bump the
version number).

It this doesn't help, you can open a ticket and give us some pointers
how to reproduce the issue.

Paul


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Cross Plugin use of classes

Paul Wölfel-2
Hi Paul,

I released a new version of the plugin, which includes austriaaddresshelper
as a requirement, but still no luck.

I've opened a ticket:
https://josm.openstreetmap.de/ticket/15025#ticket



Paul Hartmann <[hidden email]> schrieb am So., 16. Juli 2017 um
00:48 Uhr:

> One problem, you might be having, is that JOSM ignores the Manifest of
> the compiled plugin and still uses the stale information from the
> downloaded plugin list.
> One way around would be to temporarily rename the plugin (or bump the
> version number).
>
> It this doesn't help, you can open a ticket and give us some pointers
> how to reproduce the issue.
>
> Paul
>
>
> --


Mit freundlichen Grüßen
Paul Wölfel
Loading...