We have a WebService that receives a name of a report and its parameters, and calls a JRPdfExporter.
Since the reports can be added at runtime by the users, we need a way to dynamically add the Jasper jar font file into the classpath, so that any new fonts added by the users can be added to Jasper classpath.
We are using this code to try and inject the new jar into the classpath but with no success
URLClassLoader sysloader = (URLClassLoader) ClassLoader.getSystemClassLoader();
Class sysclass = URLClassLoader.class;
try {
Method method = sysclass.getDeclaredMethod("addURL", new Class[]{URL.class});
method.setAccessible(true);
method.invoke(sysloader, new Object[] {u});
} catch (Throwable t) {
t.printStackTrace();
throw new IOException("Error, could not add URL to system classloader");
}
The error I'm getting is
net.sf.jasperreports.engine.JRRuntimeException: net.sf.jasperreports.engine.JRException: Input stream not found at : fonts/fontsfamily1415192514231.xml
Any ideas on how I can do this?
Or is there a better alternative?
我通过“简单地”在特定文件夹中搜索JAR字体文件,打开它们并解压缩所有必需的文件/文件夹来解决此问题。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.