Jump to content
Changes to the Jaspersoft community edition download ×

load scriptlet-class in a package

Recommended Posts

By: k.Dammeier - rubia

load scriptlet-class in a package

2003-11-19 02:32



I want to load a scriptlet-class.

This scriptlet-class in the same package as the class which wants to need it for filling the report.

The package is in a jar-file.


I tried a lot of things, but the class is not loaded correctly.


( in a project without packages and jars, only with the scriptlet-class and the other class, I don't need to load the scriptlet-class.)


Can anybody help?


thanks a lot!





By: Fred Welland - fwelland

RE: load scriptlet-class in a package

2003-11-19 07:06

/** orginally sent to mail list; sorry for the dup **/


I actually had lots of class loading issues related to scriptlets and Jasper

0.5. In my case, my Jasper stuff was embedded in a WebApp, and the report and

scriptlet were uploaded via a browser and run by my AppServer (iPlanet 6).


I tinkered some with this and found that much of the class loading for JR

appears to be handled by dori.jasper.engine.util.JRClassLoader.


I am not a classloader guru , but it is not clear to me that this class loader

extension follows the java1.2 classloader delegation pattern the way that it

should (or at least the way I think it should). This may be my ignorance in

the area; rather that a fault in the class.


In the end, I modified JRClassLoader. If you trace thru the 'fill' of a

report, you'll find that ultimately the static method JRClassLoader.

loadClassForName() is invoked on the name specified via your Jasper XML file's

scriptletClass value. It appears that if this class is *not* in the the

CLASSPATH (the runtime classpath) then you will get class not found issues.


So what I did was to add a 'last' chance load block to this method. If the

defualt/normal class loading code fails to load the scriptlet class, my version

of JRClassLoader.loadClassForName() will try one final time with a

URLClassloader to load the class. In my case, the URLClassloader simply used

the file: protocol to load classes from a directory on my appserver where my

servlet puts the uploaded scriptlets.


This has worked for me/my web app very well; perhaps a similar technique will

help you.


FWIW: I was very reluctant to modify jasper code. My preference was to change

this behavior via extension or something, but I don't know that this is

possible the way Jasper uses the JRClassloader: it specifically, creates a

JRClassloader during fill time. Now if it used a factory approach for creating

a classloader (and the JRClassloader was abstract or the like); then it would

be easier to customize the creation of objects that behave like a JRClassloader

but have additional classloading symantics.













By: Teodor Danciu - teodord

RE: load scriptlet-class in a package

2003-11-29 00:42




You need to fully qualify the class name in the scriptletClass attribute like this:




Have you already done so?

The JAR file is in the classpath, right?


What is the error you get and what version of JasperReports are you using?


Thank you,


Link to comment
Share on other sites

  • Replies 0
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Create New...