Modify

Opened 7 years ago

Closed 7 years ago

#15025 closed defect (fixed)

plugin ClassLoader #14901 does not allow access to required classes

Reported by: pwoelfel Owned by: team
Priority: normal Milestone: 17.09
Component: Core Version:
Keywords: plugin classloader Cc:

Description

Hi Josm devs!

As written on the mailing list the new ClassLoader breaks access to AustriaAddressHelper.

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.

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()) {

I've published the latest version of my plugin 2.4.0 with the requirement, but it's still not working out.

It seems like the list of required plugins is not loaded to the PluginClassLoader.

This is the test procedure:

  1. install areaselector 2.4.0 and austriaaddresshelper plugins
  2. download bounding box (47.9238485, 16.8693566) - (47.9271844,16.8741202)
  3. load imagery basemap.at
  4. press CMD+Shift+A or Tools > Area Selection
  5. Click in the middle of a red building
  6. console output will show 08:59:20.722 [AWT-EventQueue-0] WARN org.openstreetmap.josm.plugins.areaselector.AreaSelectorAction - Austria Address Helper not loaded

Attachments (0)

Change History (4)

comment:1 by pwoelfel, 7 years ago

It's working now without any code changes on my side. Maybe Paul Hartmann was right and the dependencies were cached somewhere.

How are dependencies fetched from the plugin? IMHO the dependencies should be read from the plugin jar file.

in reply to:  1 comment:2 by bastiK, 7 years ago

Resolution: worksforme
Status: newclosed

Replying to pwoelfel:

It's working now without any code changes on my side. Maybe Paul Hartmann was right and the dependencies were cached somewhere.

How are dependencies fetched from the plugin? IMHO the dependencies should be read from the plugin jar file.

JOSM downloads (and caches) this file, which is updated about every 5 minutes on the server.

If you like, you can open another ticket for issues on how the dependencies (and other metadata) is fetched for the plugins. As always, concrete step-by-step description is appreciated.

comment:3 by Don-vip, 7 years ago

Keywords: plugin classloader added
Milestone: 17.09
Resolution: worksforme
Status: closedreopened

Got the same error for one of my plugins, it's actually a core bug: we use the remote information (from josm website) instead of local information from plugin jar (which is available when building the classloader).

comment:4 by Don-vip, 7 years ago

Resolution: fixed
Status: reopenedclosed

In 12896/josm:

fix #15025 - use local list (from jar) of required plugins when building plugin classloader, instead of remote list (from update site). Allow plugin developers to test plugins changing their required plugins since the latest released version

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain team.
as The resolution will be set.
The resolution will be deleted. Next status will be 'reopened'.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.