Archi Forum

Archi => Archi Development => Topic started by: jucanoma on September 25, 2017, 15:41:17 PM

Title: Issue classpath developping plugin
Post by: jucanoma on September 25, 2017, 15:41:17 PM
Hi everybody
I'm working on a plugin to export selected views in HTML and I want to use base my code in the existing funcionality who use org.stringtemplate.v4.* libraries. When I launch the export, with any of the new funcionalities I have the following error:
java.lang.NoClassDefFoundError: org/stringtemplate/v4/AttributeRenderer
   at org.archicontribs.reports.html.ExportViewsWizard.performFinish(ExportViewsWizard.java:38)
   at org.eclipse.jface.wizard.WizardDialog.finishPressed(WizardDialog.java:790)
   at com.archimatetool.editor.ui.components.ExtendedWizardDialog.finishPressed(ExtendedWizardDialog.java:50)
   at org.eclipse.jface.wizard.WizardDialog.buttonPressed(WizardDialog.java:423)
   at org.eclipse.jface.dialogs.Dialog$2.widgetSelected(Dialog.java:618)
   at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:249)
   at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
   at org.eclipse.swt.widgets.Display.sendEvent(Display.java:5227)
   at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1340)
   at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4561)
   at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:4151)
   at org.eclipse.jface.window.Window.runEventLoop(Window.java:818)
   at org.eclipse.jface.window.Window.open(Window.java:794)
   at org.archicontribs.reports.html.MyExporter.export(MyExporter.java:52)
   at com.archimatetool.editor.actions.ExportModelAction.run(ExportModelAction.java:37)
   at org.eclipse.jface.action.Action.runWithEvent(Action.java:473)
   at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection(ActionContributionItem.java:565)
   at org.eclipse.jface.action.ActionContributionItem.lambda$4(ActionContributionItem.java:397)
   at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
   at org.eclipse.swt.widgets.Display.sendEvent(Display.java:5227)
   at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1340)
   at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4561)
   at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:4151)
   at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$4.run(PartRenderingEngine.java:1121)
   at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:336)
   at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:1022)
   at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:150)
   at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:693)
   at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:336)
   at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:610)
   at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:148)
   at com.archimatetool.editor.Application.start(Application.java:81)
   at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
   at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:134)
   at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:104)
   at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:388)
   at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:243)
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
   at java.lang.reflect.Method.invoke(Method.java:498)
   at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:673)
   at org.eclipse.equinox.launcher.Main.basicRun(Main.java:610)
   at org.eclipse.equinox.launcher.Main.run(Main.java:1519)
   at org.eclipse.equinox.launcher.Main.main(Main.java:1492)
Caused by: java.lang.ClassNotFoundException: org.stringtemplate.v4.AttributeRenderer cannot be found by org.archicontribs.reports.html_1.0.0.qualifier
   at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:461)
   at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:372)
   at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:364)
   at org.eclipse.osgi.internal.loader.ModuleClassLoader.loadClass(ModuleClassLoader.java:161)
   at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
   ... 45 more

I look at the build properties to check if the libraries are included on the classpath and I see it include all the content of /lib

bin.includes = META-INF/,\
               .,\
               plugin.xml,\
               LICENSE.txt,\
               plugin.properties,\
               templates/,\
               lib/
source.org.archicontribs.reports.html.jar = src/
output.org.archicontribs.reports.html.jar = bin/

Do you have any ideas or do I miss some step in the creation of the plugin. I followed the steps of https://www.archimatetool.com/dev/import-export (https://www.archimatetool.com/dev/import-export)
Title: Re: Issue classpath developping plugin
Post by: Phil Beauvoir on September 25, 2017, 15:55:08 PM
Do you have the jar files in the lib directory? If you are using these they need to be included in your project as they are not re-exported from the Archi project.
Title: Re: Issue classpath developping plugin
Post by: jucanoma on September 25, 2017, 18:03:43 PM
Hi
The .jar were in the lib folder. I updated the build to this and It worked.
source.. = src/
output.. = bin/
bin.includes = META-INF/,\
               .,\
               plugin.xml,\
               LICENSE.txt,\
               plugin.properties,\
               lib/antlr-runtime-4.4.jar,\
               lib/ST-4.0.8.jar

I also have to update the manifest to include the activator

Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Export selected views
Bundle-SymbolicName: org.archicontribs.reports.html;singleton:=true
Bundle-Version: 1.0.0.qualifier
Bundle-Vendor: CV
Bundle-Localization: plugin
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Require-Bundle: org.eclipse.ui,
org.eclipse.core.runtime,
com.archimatetool.editor
Import-Package: com.archimatetool.reports.html
Bundle-ClassPath: lib/ST-4.0.8.jar,
lib/antlr-runtime-4.4.jar,
.
Bundle-Activator: org.archicontribs.reports.html.ArchiReportsPlugin
Bundle-ActivationPolicy: lazy


Thx
Best Regards
Juan