Hello,
I am new to eclipse RCP plugins, and I am adding a ViewPart extension which includes a Jasper report. The report should be displayed when an action from a menu is generated.
However, I get these errors when I click on the menu.
Please, any ideas why these are generated?
Thanks.
________________________________________________
java.lang.NoClassDefFoundError: com/jasperassistant/designer/viewer/ViewerComposite
at java.lang.Class.getDeclaredConstructors0(Native Method)
at java.lang.Class.privateGetDeclaredConstructors(Unknown Source)
at java.lang.Class.getConstructor0(Unknown Source)
at java.lang.Class.newInstance0(Unknown Source)
at java.lang.Class.newInstance(Unknown Source)
at org.eclipse.core.internal.registry.osgi.RegistryStrategyOSGI.createExecutableExtension(RegistryStrategyOSGI.java:170)
at org.eclipse.core.internal.registry.ExtensionRegistry.createExecutableExtension(ExtensionRegistry.java:867)
at org.eclipse.core.internal.registry.ConfigurationElement.createExecutableExtension(ConfigurationElement.java:243)
at org.eclipse.core.internal.registry.ConfigurationElementHandle.createExecutableExtension(ConfigurationElementHandle.java:51)
at org.eclipse.ui.internal.WorkbenchPlugin$1.run(WorkbenchPlugin.java:267)
at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:70)
at org.eclipse.ui.internal.WorkbenchPlugin.createExtension(WorkbenchPlugin.java:263)
at org.eclipse.ui.internal.registry.ViewDescriptor.createView(ViewDescriptor.java:63)
at org.eclipse.ui.internal.ViewReference.createPartHelper(ViewReference.java:328)
at org.eclipse.ui.internal.ViewReference.createPart(ViewReference.java:230)
at org.eclipse.ui.internal.WorkbenchPartReference.getPart(WorkbenchPartReference.java:594)
at org.eclipse.ui.internal.Perspective.showView(Perspective.java:2131)
at org.eclipse.ui.internal.WorkbenchPage.busyShowView(WorkbenchPage.java:1062)
at org.eclipse.ui.internal.WorkbenchPage$19.run(WorkbenchPage.java:3773)
at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:70)
at org.eclipse.ui.internal.WorkbenchPage.showView(WorkbenchPage.java:3770)
at org.eclipse.ui.internal.WorkbenchPage.showView(WorkbenchPage.java:3746)
at report.jasper.ReportAction2.<init>(ReportAction2.java:25)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at java.lang.Class.newInstance0(Unknown Source)
at java.lang.Class.newInstance(Unknown Source)
at org.eclipse.core.internal.registry.osgi.RegistryStrategyOSGI.createExecutableExtension(RegistryStrategyOSGI.java:170)
at org.eclipse.core.internal.registry.ExtensionRegistry.createExecutableExtension(ExtensionRegistry.java:867)
at org.eclipse.core.internal.registry.ConfigurationElement.createExecutableExtension(ConfigurationElement.java:243)
at org.eclipse.core.internal.registry.ConfigurationElementHandle.createExecutableExtension(ConfigurationElementHandle.java:51)
at org.eclipse.ui.internal.WorkbenchPlugin$1.run(WorkbenchPlugin.java:267)
at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:70)
at org.eclipse.ui.internal.WorkbenchPlugin.createExtension(WorkbenchPlugin.java:263)
at org.eclipse.ui.internal.PluginAction.createDelegate(PluginAction.java:122)
at org.eclipse.ui.internal.PluginAction.runWithEvent(PluginAction.java:223)
at org.eclipse.ui.internal.WWinPluginAction.runWithEvent(WWinPluginAction.java:229)
at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection(ActionContributionItem.java:583)
at org.eclipse.jface.action.ActionContributionItem.access$2(ActionContributionItem.java:500)
at org.eclipse.jface.action.ActionContributionItem$5.handleEvent(ActionContributionItem.java:411)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1003)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3823)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3422)
at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2384)
at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2348)
at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2200)
at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:495)
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:288)
at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:490)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
at Application.start(Application.java:33)
at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:193)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:386)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:549)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:504)
at org.eclipse.equinox.launcher.Main.run(Main.java:1236)
at org.eclipse.equinox.launcher.Main.main(Main.java:1212)
Caused by: java.lang.ClassNotFoundException: com.jasperassistant.designer.viewer.ViewerComposite
at org.eclipse.osgi.framework.internal.core.BundleLoader.findClassInternal(BundleLoader.java:483)
at org.eclipse.osgi.framework.internal.core.BundleLoader.findClass(BundleLoader.java:399)
at org.eclipse.osgi.framework.internal.core.BundleLoader.findClass(BundleLoader.java:387)
at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.loadClass(DefaultClassLoader.java:87)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
... 67 more
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
It looks like it is not finding a jasperassistant package. Perhaps there is a problem in your dependencies. In my application, I bundled all the .jar files necessary for JasperReports (JasperReports, swtJasperViewer, etc.) into a separate plug-in with necessary components visible to my main application plug-in. I set up my viewpart to that multiple reports can be opened and then it is isimply a matter of creating the report and opening it via swtJasperViewer. I'd be happy to send you the code. You can e-mail me back channel at MichaelMSchmidt@msn.com.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I have the same problem, and I found out that it is quite common. Unfortunately I did not succeed with the drafted solutions which were either to register plugins as buddies or tweak the class loader. Probably I miss some details.
Michael, would you please share relevant parts of your code. Did you do one of the two things I mentioned above?
Thanks,
Marco
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Michael, how did you put the required packages into the dependencies plug-in, just by adding the jars to the build path or even by putting the source code there?
/m
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I tried to create a .zip file with the code but there doesn't seem to be any way to attach it, so I'll try to do the explanation in-line.
First, create a new plug-in to contain the .jar files. I created a "libraries" directory within the new plug-in and put the libraries there. Here is the manifest.mf for the library plug-in
In your main plug-in, add the library plug-in too the dependencies in your .product file. It should also appear in the "Required Bundles" section of the manifest.mf.
I stack reports in a view in my perspective. Here is the Perspective code that includes this.
packageus.mschmidt.akinoowin;importorg.eclipse.ui.IFolderLayout;importorg.eclipse.ui.IPageLayout;importorg.eclipse.ui.IPerspectiveFactory;importus.mschmidt.akinoowin.views.ReportView;importus.mschmidt.akinoowin.views.TasksView;publicclassPerspectiveimplementsIPerspectiveFactory{publicstaticfinalStringPERSPECTIVE_ID="us.mschmidt.akinoowin.perspective";publicvoidcreateInitialLayout(IPageLayoutlayout){layout.addStandaloneView(TasksView.VIEW_ID,false,IPageLayout.LEFT,0.25f,layout.getEditorArea());layout.getViewLayout(TasksView.VIEW_ID).setCloseable(false);layout.getViewLayout(TasksView.VIEW_ID).setMoveable(false);finalIFolderLayoutfolder=layout.createFolder("reports",IPageLayout.BOTTOM,0.80f,layout.getEditorArea());folder.addPlaceholder(ReportView.ID_VIEW+":*");}/***OverridetoprovideusefulinformationwhentheclasstoStringmethodis*called.**@returntheinformationString*@seejava.lang.Object#toString()*/@OverridepublicfinalStringtoString(){return"us.mschmidt.akinoowin.Perspective is the application's perspective";}}
Here is the viewer that uses swtJasperViewer to display the report.
packageus.mschmidt.akinoowin.views;importnet.sf.jasperreports.engine.JasperPrint;importorg.eclipse.swt.SWT;importorg.eclipse.swt.layout.GridData;importorg.eclipse.swt.layout.GridLayout;importorg.eclipse.swt.widgets.Composite;importorg.eclipse.ui.part.ViewPart;importcom.jasperassistant.designer.viewer.ViewerComposite;publicclassReportViewextendsViewPart{publicstaticfinalStringID_VIEW="us.mschmidt.akinoowin.views.ReportView";//UsingtheSWTJasperViewerprivateViewerCompositeviewerComposite;/***Createcontentsoftheviewpart*@paramparent*/@OverridepublicvoidcreatePartControl(finalCompositeparent){finalCompositecontainer=newComposite(parent,SWT.NONE);finalGridLayoutlayout=newGridLayout();container.setLayout(layout);viewerComposite=newViewerComposite(container,SWT.BORDER);viewerComposite.setLayoutData(newGridData(GridData.FILL,GridData.FILL,true,true));}/***Requiredmethod,notusedhere.*/@OverridepublicvoidsetFocus(){//Setthefocus}/***SetstheJasperPrintobjectforthisReportViewinstance.**@paramprintObjecttheJasperPrintobject*/publicvoidsetJasperDocument(finalJasperPrintprintObject){viewerComposite.getReportViewer().setDocument(printObject);}/***Overridetoprovideusefulinformationwhentheclasstostring()methodis*called.**@returnthedescriptiveinformation*@seejava.lang.Object#toString()*/@OverridepublicStringtoString(){return"akamai.dbreports.ReportView implements the JasperReports viewer";}}
Finally, I create the report in a thread using the Jobs implementation. Here is one of the implementations that shows how to do the classloader switching.
packageus.mschmidt.akinoowin.dbutilities;importjava.io.File;importjava.sql.Connection;importjava.util.Map;importnet.sf.jasperreports.engine.JRException;importnet.sf.jasperreports.engine.JasperCompileManager;importnet.sf.jasperreports.engine.JasperFillManager;importnet.sf.jasperreports.engine.JasperPrint;importorg.eclipse.core.runtime.IProgressMonitor;importorg.eclipse.core.runtime.IStatus;importorg.eclipse.core.runtime.Status;importorg.eclipse.core.runtime.jobs.Job;importorg.eclipse.swt.widgets.Display;importorg.eclipse.ui.IWorkbenchPage;importorg.eclipse.ui.PartInitException;importorg.eclipse.ui.PlatformUI;importus.mschmidt.akinoowin.views.ReportView;importus.mschmidt.akinoowin.constants.XmlConstants;importus.mschmidt.akinoowin.constants.ApplicationConstants;importus.mschmidt.akinoowin.Application;importus.mschmidt.akinoowin.ApplicationActionBarAdvisor;importus.mschmidt.akinoowin.extras.ApplicationLogger;/***GeneratesJasperReportsinahelperthread.*/publicclassReportListJobextendsJob{privatefinalStringfileName;protectedfinalStringreportName;privatefinalStringjrFile;privatefinalMap<String,String>parms;privateStringerrMsg;privateJasperPrintjPrint;privatebooleanranOK;/***Theclassconstructor.**@paramjobNamethenameofthisjobinstance*@paramnameValthereportname*@paramfileValthe.jasperfileforthisreport*@paramparmValsthemapofparameters*/publicReportListJob(finalStringjobName,finalStringnameVal,finalStringfileVal,finalMap<String,String>parmVals){super(jobName);reportName=nameVal;fileName=fileVal;jrFile=XmlConstants.REPORTS_DIR+fileName;parms=parmVals;}/***Thejobrunnable.**@parammonitorthejobprogressmonitor*@returnthejobIStatus*/@OverrideprotectedIStatusrun(finalIProgressMonitormonitor){Connectionconn=null;jPrint=null;ranOK=true;errMsg=null;//Beginthetaskmonitormonitor.beginTask("Report "+reportName,7*ApplicationConstants.JOB_STEP);//Classloaderswappingisrequired,sobackupthedefaultclassloaderfinalThreadthread=Thread.currentThread();finalClassLoadereclipseLoader=thread.getContextClassLoader();monitor.worked(ApplicationConstants.JOB_STEP);try{//Beginthejobmonitormonitor.worked(ApplicationConstants.JOB_STEP);//makesureJasperreportfileexistfinalFilef=newFile(jrFile);if(!f.isFile()){errMsg="Cannot find Jasper file";ranOK=false;ApplicationLogger.logInfo("ReportList error: Unable to find Jasper file "+jrFile);returnStatus.CANCEL_STATUS;}//AcquireadatabaselockApplication.getConnectionManager().acquireLock();monitor.worked(ApplicationConstants.JOB_STEP);//Connectingtothedatabaseconn=Application.getConnectionManager().getConnection();if(null==conn){ApplicationLogger.logInfo(Application.getConnectionManager().getMessage());ApplicationLogger.logInfo("Report job unable to acquire database connection");ranOK=false;errMsg="ReportList error: No database connection";returnStatus.CANCEL_STATUS;}monitor.worked(ApplicationConstants.JOB_STEP);//Loadcustomclassloaderthread.setContextClassLoader(JasperCompileManager.class.getClassLoader());monitor.worked(ApplicationConstants.JOB_STEP);//Fillthereportwithdatafrom//thedatabaseusingthepassedparameters.jPrint=JasperFillManager.fillReport(jrFile,parms,conn);monitor.worked(ApplicationConstants.JOB_STEP);}catch(finalJRExceptione){errMsg="JasperFill error";ranOK=false;ApplicationLogger.logError("ReportList JR error"+e.getMessage(),e.getCause());}finally{//ClosethedatabaseconnectionandreleasethelockApplication.getConnectionManager().closeConnection();Application.getConnectionManager().releaseLock();monitor.worked(ApplicationConstants.JOB_STEP);//Replacecustomclassloaderwiththeoriginalclassloader.thread.setContextClassLoader(eclipseLoader);monitor.worked(ApplicationConstants.JOB_STEP);//Endthemonitormonitor.done();//MakesureaJasperPrintobjectwascreatedif(null==jPrint){ranOK=false;if(null==errMsg){errMsg="JasperPrint object not created";ApplicationLogger.logInfo("ReportList error: JasperPrint object not created");}}//DisplayresultsshowResults();}returnStatus.OK_STATUS;}/***Outputresultstoaviewuponcompletionoftask.**@paramjptheJasperPrintobject*@parambbooleantrueifjobran,falseiferrorsoccurred*/protectedfinalvoidshowResults(){Display.getDefault().asyncExec(newRunnable(){publicvoidrun(){if(!ranOK){if(null==errMsg){errMsg="Unable to create report";}ApplicationActionBarAdvisor.postMessage(errMsg,true);return;}try{finalReportViewrv=(ReportView)PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().showView(ReportView.ID_VIEW,reportName,IWorkbenchPage.VIEW_VISIBLE);rv.setJasperDocument(jPrint);}catch(finalPartInitExceptione){ApplicationLogger.logError("ReportList View error "+e.getMessage(),e.getCause());}}});}}
Hopefull, that's everything folks will need.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I immediately tried it. I got unresolvable types, and I had to add the following to my plug-in's build.properties:
jars.extra.classpath = platform:/plugin/org.foo.bar.jasperReports/lib/commons-collections-3.1.jar,\
platform:/plugin/org.foo.bar.jasperReports/lib/commons-beanutils-1.7.0.jar,\
platform:/plugin/org.foo.bar.jasperReports/lib/commons-digester-2.0.jar,\
platform:/plugin/org.foo.bar.jasperReports/lib/commons-logging-1.0.jar,\
platform:/plugin/org.foo.bar.jasperReports/lib/iText-2.1.7.jar,\
platform:/plugin/org.foo.bar.jasperReports/lib/jasperreports-3.7.3.jar,\
platform:/plugin/org.foo.bar.jasperReports/lib/swtjasperviewer-1.2.0.jar
The type net.sf.jasperreports.engine.JasperPrint cannot be resolved. It is indirectly referenced from required .class files ReportGen.java
The project was not built since its build path is incomplete. Cannot find the class file for net.sf.jasperreports.engine.JasperPrint. Fix the build path then try building this project
I think this brings the whole thing about separate plug-in and dependency to absurdity.
There's something wrong in your implementation, but I'm not sure what. Here are some ideas to start with.
1. The necessary .jar files (referenced in the manifest.mf and build.properties files) must be copied to your libraries plug-in (let's call it JasperLibs). You might need to do a "Refresh" on JasperLibs to make sure the copied .jar files register with the workspace. Make sure the manifest.mf export packages is like my example - this exposes the necessary methods to your main plug-in.
2. The JasperLibs plug-in must be referenced in your main plug-in .product file and as a required bundle in its manifest.mf.
3. You absolutely do not have to include the JasperLibs .jar files in your main plug-in build.properties file.
4. In my sample code, ignore references to ris_tagger.jar. That is a custom .jar file that I created for my specific application.
I encourage you to keep trying and I will try to help you out. It is worthwhile to have the Jasper libraries in a separate plug-in from a code maintenance perspective - updates are easier to manage.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
1. and 3. Stating the plug-in dependency from main to dependency plg-in was not enough. I had to add the jars.extra.classpath in the main plg-in's build.properties. Otherwise I could not avoid the the type not resolved errors. I no clue why.
2. I do not have an application. The plug-in are currently intended for direct deployment onto the platform. I don't have a product either yet, just the plug-ins.
Actually I do not even understand how your approach could work. You request the ClassLoader from a class (JasperCompileManager) which cannot be addressed from the current ClassLoader. How can this work???
/m
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hello,
I am new to eclipse RCP plugins, and I am adding a ViewPart extension which includes a Jasper report. The report should be displayed when an action from a menu is generated.
However, I get these errors when I click on the menu.
Please, any ideas why these are generated?
Thanks.
________________________________________________
java.lang.NoClassDefFoundError: com/jasperassistant/designer/viewer/ViewerComposite
at java.lang.Class.getDeclaredConstructors0(Native Method)
at java.lang.Class.privateGetDeclaredConstructors(Unknown Source)
at java.lang.Class.getConstructor0(Unknown Source)
at java.lang.Class.newInstance0(Unknown Source)
at java.lang.Class.newInstance(Unknown Source)
at org.eclipse.core.internal.registry.osgi.RegistryStrategyOSGI.createExecutableExtension(RegistryStrategyOSGI.java:170)
at org.eclipse.core.internal.registry.ExtensionRegistry.createExecutableExtension(ExtensionRegistry.java:867)
at org.eclipse.core.internal.registry.ConfigurationElement.createExecutableExtension(ConfigurationElement.java:243)
at org.eclipse.core.internal.registry.ConfigurationElementHandle.createExecutableExtension(ConfigurationElementHandle.java:51)
at org.eclipse.ui.internal.WorkbenchPlugin$1.run(WorkbenchPlugin.java:267)
at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:70)
at org.eclipse.ui.internal.WorkbenchPlugin.createExtension(WorkbenchPlugin.java:263)
at org.eclipse.ui.internal.registry.ViewDescriptor.createView(ViewDescriptor.java:63)
at org.eclipse.ui.internal.ViewReference.createPartHelper(ViewReference.java:328)
at org.eclipse.ui.internal.ViewReference.createPart(ViewReference.java:230)
at org.eclipse.ui.internal.WorkbenchPartReference.getPart(WorkbenchPartReference.java:594)
at org.eclipse.ui.internal.Perspective.showView(Perspective.java:2131)
at org.eclipse.ui.internal.WorkbenchPage.busyShowView(WorkbenchPage.java:1062)
at org.eclipse.ui.internal.WorkbenchPage$19.run(WorkbenchPage.java:3773)
at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:70)
at org.eclipse.ui.internal.WorkbenchPage.showView(WorkbenchPage.java:3770)
at org.eclipse.ui.internal.WorkbenchPage.showView(WorkbenchPage.java:3746)
at report.jasper.ReportAction2.<init>(ReportAction2.java:25)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at java.lang.Class.newInstance0(Unknown Source)
at java.lang.Class.newInstance(Unknown Source)
at org.eclipse.core.internal.registry.osgi.RegistryStrategyOSGI.createExecutableExtension(RegistryStrategyOSGI.java:170)
at org.eclipse.core.internal.registry.ExtensionRegistry.createExecutableExtension(ExtensionRegistry.java:867)
at org.eclipse.core.internal.registry.ConfigurationElement.createExecutableExtension(ConfigurationElement.java:243)
at org.eclipse.core.internal.registry.ConfigurationElementHandle.createExecutableExtension(ConfigurationElementHandle.java:51)
at org.eclipse.ui.internal.WorkbenchPlugin$1.run(WorkbenchPlugin.java:267)
at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:70)
at org.eclipse.ui.internal.WorkbenchPlugin.createExtension(WorkbenchPlugin.java:263)
at org.eclipse.ui.internal.PluginAction.createDelegate(PluginAction.java:122)
at org.eclipse.ui.internal.PluginAction.runWithEvent(PluginAction.java:223)
at org.eclipse.ui.internal.WWinPluginAction.runWithEvent(WWinPluginAction.java:229)
at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection(ActionContributionItem.java:583)
at org.eclipse.jface.action.ActionContributionItem.access$2(ActionContributionItem.java:500)
at org.eclipse.jface.action.ActionContributionItem$5.handleEvent(ActionContributionItem.java:411)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1003)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3823)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3422)
at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2384)
at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2348)
at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2200)
at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:495)
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:288)
at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:490)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
at Application.start(Application.java:33)
at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:193)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:386)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:549)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:504)
at org.eclipse.equinox.launcher.Main.run(Main.java:1236)
at org.eclipse.equinox.launcher.Main.main(Main.java:1212)
Caused by: java.lang.ClassNotFoundException: com.jasperassistant.designer.viewer.ViewerComposite
at org.eclipse.osgi.framework.internal.core.BundleLoader.findClassInternal(BundleLoader.java:483)
at org.eclipse.osgi.framework.internal.core.BundleLoader.findClass(BundleLoader.java:399)
at org.eclipse.osgi.framework.internal.core.BundleLoader.findClass(BundleLoader.java:387)
at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.loadClass(DefaultClassLoader.java:87)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
... 67 more
It looks like it is not finding a jasperassistant package. Perhaps there is a problem in your dependencies. In my application, I bundled all the .jar files necessary for JasperReports (JasperReports, swtJasperViewer, etc.) into a separate plug-in with necessary components visible to my main application plug-in. I set up my viewpart to that multiple reports can be opened and then it is isimply a matter of creating the report and opening it via swtJasperViewer. I'd be happy to send you the code. You can e-mail me back channel at MichaelMSchmidt@msn.com.
Hi,
I have the same problem, and I found out that it is quite common. Unfortunately I did not succeed with the drafted solutions which were either to register plugins as buddies or tweak the class loader. Probably I miss some details.
Michael, would you please share relevant parts of your code. Did you do one of the two things I mentioned above?
Thanks,
Marco
Michael, how did you put the required packages into the dependencies plug-in, just by adding the jars to the build path or even by putting the source code there?
/m
I tried to create a .zip file with the code but there doesn't seem to be any way to attach it, so I'll try to do the explanation in-line.
First, create a new plug-in to contain the .jar files. I created a "libraries" directory within the new plug-in and put the libraries there. Here is the manifest.mf for the library plug-in
Here is the build.properties for the library plug-in
In your main plug-in, add the library plug-in too the dependencies in your .product file. It should also appear in the "Required Bundles" section of the manifest.mf.
I stack reports in a view in my perspective. Here is the Perspective code that includes this.
Here is the viewer that uses swtJasperViewer to display the report.
Finally, I create the report in a thread using the Jobs implementation. Here is one of the implementations that shows how to do the classloader switching.
Hopefull, that's everything folks will need.
Michael,
Thanks a lot for your post.
I immediately tried it. I got unresolvable types, and I had to add the following to my plug-in's build.properties:
I think this brings the whole thing about separate plug-in and dependency to absurdity.
And then when I run it get the a similar error
already for the statement to change the classloader:
I do not run this code in a job but in a simple menu handler. But this should not make a difference. But what else might I be missing?
Your help very much appreciated.
Thanks,
Marco
There's something wrong in your implementation, but I'm not sure what. Here are some ideas to start with.
1. The necessary .jar files (referenced in the manifest.mf and build.properties files) must be copied to your libraries plug-in (let's call it JasperLibs). You might need to do a "Refresh" on JasperLibs to make sure the copied .jar files register with the workspace. Make sure the manifest.mf export packages is like my example - this exposes the necessary methods to your main plug-in.
2. The JasperLibs plug-in must be referenced in your main plug-in .product file and as a required bundle in its manifest.mf.
3. You absolutely do not have to include the JasperLibs .jar files in your main plug-in build.properties file.
4. In my sample code, ignore references to ris_tagger.jar. That is a custom .jar file that I created for my specific application.
I encourage you to keep trying and I will try to help you out. It is worthwhile to have the Jasper libraries in a separate plug-in from a code maintenance perspective - updates are easier to manage.
Michael,
1. and 3. Stating the plug-in dependency from main to dependency plg-in was not enough. I had to add the jars.extra.classpath in the main plg-in's build.properties. Otherwise I could not avoid the the type not resolved errors. I no clue why.
2. I do not have an application. The plug-in are currently intended for direct deployment onto the platform. I don't have a product either yet, just the plug-ins.
Actually I do not even understand how your approach could work. You request the ClassLoader from a class (JasperCompileManager) which cannot be addressed from the current ClassLoader. How can this work???
/m