Libraries not imported

Hi,

I encounter a little issue in my plugin development.
Before it was ok but now, I got always “java.lang.NoClassDefFoundError: com/overzealous/remark/Options” (or others extern library class).

What’s wrong with my plugin.xml file?

<plugin
        id="com.xxx.vp.plugins"
        name="Export"
        description="Export project on your filesystem"
        provider="Visual Paradigm"
        class="com.xxx.vp.plugins.Export">
	<library path="libs/freemarker-2.3.28.jar" relativePath="true"/>
	<library path="libs/commons-lang3-3.9.jar" relativePath="true"/>
	<library path="libs/jsoup-1.12.1.jar" relativePath="true"/>
	<library path="libs/remark-1.0.0-SNAPSHOT.jar" relativePath="true"/>
    <actionSets>
        <actionSet id="com.xxx.vp.plugins.actionset">
            <action
                    id="com.xxx.vp.plugins.actions.ExportController"
                    actionType="generalAction"
                    label="Export project on your filesystem"
                    tooltip="Export project on your filesystem"
                    style="normal"
                    menuPath="Tools/Report">
                <actionController
                        class="com.xxx.vp.plugins.actions.ExportController"/>
            </action>
            <action
                    id="com.xxx.vp.plugins.actions.ReloadClassesAction"
                    actionType="generalAction"
                    label="Reload Plugin Classes"
                    tooltip="Reload Plugin Classes"
                    style="normal"
                    menuPath="View/#">
                <actionController class="com.xxx.vp.plugins.actions.ReloadClassesActionController" />
            </action>
        </actionSet>
    </actionSets>
</plugin>

And jar files are in folder “C:\Users\xxx\AppData\Roaming\VisualParadigm\plugins\VPExportPlugin\libs”.

What could be wrong?

It’s working when, before exporting with the first action, I reload the plugin with second one.
This second one (com.xxx.vp.plugins.actions.ReloadClassesAction), just execute
ApplicationManager.instance().reloadPluginClasses("com.xxx.vp.plugins");

Why libraries are not correctly imported at start?

Hi,

What IDE are you using? When you use Eclipse, you can specify any external libraries you are referencing within the project properties as shown in this tutorial: https://www.visual-paradigm.com/tutorials/plugin.jsp

Alternatively, try wrapping your libraries in the following element:

<runtime>
    <library path="libs/freemarker-2.3.28.jar" relativePath="true"/>
    <library path="libs/commons-lang3-3.9.jar" relativePath="true"/>
    <library path="libs/jsoup-1.12.1.jar" relativePath="true"/>
    <library path="libs/remark-1.0.0-SNAPSHOT.jar" relativePath="true"/>
</runtime>

Sorry for late reply.

and, thanks GregS,

Right, the <library> should be included in <runtime>. Otherwise those .jar won’t be loaded for your plugin.


FYI:
On another hand, it is a bug (unexpected behavior) that ApplicationManager.reloadPluginClasses(....) will try to load all the <library>(s) in <plugin>...</plugin>, or in <plugin><runtime>...</runtime></plugin> :sweat:

<plugin ...>
    <runtime>
        <library .../>
        ...
    <runtime>

    <library.../>
    ...

</plugin>

1 Like