Jump to content
  • Jaspersoft Studio fails to access Spring classes properly


    pawel.miler
    Assigned User anonymous
    CategoryBug report
    PriorityUrgent
    ReproducibilityAlways
    ResolutionFixed
    SeverityBlock
    StatusResolved
    Versionv5.1.0

    Environment:

    O/S: Win7 32Bit

    IDE: Eclipse 3.7SR2 32Bit

    Java: JRE 7u17 (confirmed on JDK 1.6.0_31 )

    Plugins: Jaspersoft Studio 5.1.0

     

    Workspace set up with Dummy code to reproduce Bug included.

     

    Workspace:

    references:

    - jasperreports 5.0.4

    - spring framework 3.0.5

     

    Problem:

    Getting ClassNotFoundException when previewing a report with Jaspersoft Studio plugin with selected custom DataSourceProvider which uses a GenericXmlApplicationContext from Spring Framework package:

     

    net.sf.jasperreports.engine.JRException: java.lang.NoClassDefFoundError: org/springframework/asm/ClassVisitor

    at com.jaspersoft.studio.editor.preview.view.control.ReportControler.fillReport(ReportControler.java:453)

    at com.jaspersoft.studio.editor.preview.view.control.ReportControler.access$14(ReportControler.java:428)

    at com.jaspersoft.studio.editor.preview.view.control.ReportControler$3.run(ReportControler.java:337)

    at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54)

    Caused by: java.lang.NoClassDefFoundError: org/springframework/asm/ClassVisitor

    at org.springframework.context.support.GenericApplicationContext.(GenericApplicationContext.java:103)

    at org.springframework.context.support.GenericXmlApplicationContext.(GenericXmlApplicationContext.java:49)

    at context.DummyContext.(DummyContext.java:5)

    at provider.DummyDataSourceProvider.create(DummyDataSourceProvider.java:15)

    at net.sf.jasperreports.data.provider.DataSourceProviderDataAdapterService.contributeParameters(DataSourceProviderDataAdapterService.java:115)

    at net.sf.jasperreports.engine.fill.JRFillDataset.contributeParameters(JRFillDataset.java:996)

    at net.sf.jasperreports.engine.fill.JRFillDataset.setParameterValues(JRFillDataset.java:622)

    at net.sf.jasperreports.engine.fill.JRBaseFiller.setParameters(JRBaseFiller.java:1257)

    at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:877)

    at net.sf.jasperreports.engine.fill.BaseFillHandle$ReportFiller.run(BaseFillHandle.java:120)

    at java.lang.Thread.run(Unknown Source)

    Caused by: java.lang.ClassNotFoundException: org.springframework.asm.ClassVisitor

    at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:513)

    at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:429)

    at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:417)

    at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.loadClass(DefaultClassLoader.java:107)

    at java.lang.ClassLoader.loadClass(Unknown Source)

    ... 11 more


    Attachments: dummy_workspace.zip

    User Feedback

    Recommended Comments

    Changed Assigned User from - to @User_306070


    As far as I can see, the problem is, that not all basic spring jars are included into the plugin (for example org.springframework-asm-3.0.5.jar, where the "ClassVisitor" class, which is causing the exception, resides, is not in the distribution package of your plugin). Our custom DataSourceProvider is referencing classes, being already loaded by Jaspersoft-Plugin (like GenericApplicationContext, which seems to be already used by your plugin, but apparently with other constructor) so the plugin class loader is used, and requiered classes are not found.Looking at the code of org.springframework.context.support.GenericApplicationContext we can see two constructors:one is used by Jaspersoft Plugin, which is not requiring any "asm.jar" - classes : public GenericApplicationContext(DefaultListableBeanFactory beanFactory) { Assert.notNull(beanFactory, "BeanFactory must not be null"); this.beanFactory = beanFactory; }And one is used by our code, which requeres classes from asm (so LocalVariableTableParameterNameDiscoverer depends on org.springframework.asm classes) : public GenericApplicationContext() { this.beanFactory = new DefaultListableBeanFactory(); this.beanFactory.setParameterNameDiscoverer(new LocalVariableTableParameterNameDiscoverer()); this.beanFactory.setAutowireCandidateResolver(new QualifierAnnotationAutowireCandidateResolver()); }It seems, that if your code is using spring, it is better to include all basic components into the distribution (I can imagine same problems also with other jars, not just from "asm" package)
    Link to comment
    Share on other sites

    Changed Resolution from Open to Fixed

    Changed Status from New to Resolved


    I added all spring jars for version 3.0.5, now we don't have any errorit's not necessary to have spring and jr library inside the projectfor JRLibrary go to Java Build Path -> Library, click on Add Library, select JasperReports Library
    Link to comment
    Share on other sites


×
×
  • Create New...