0
我們有一個WebService接收報告的名稱及其參數,並調用JRPdfExporter。由於用戶可以在運行時添加報告,因此我們需要一種將Jasper jar字體文件動態添加到類路徑中的方法,以便用戶添加的任何新字體都可以添加到Jasper類路徑中。將JasperReports字體文件動態注入web應用程序
我們正在使用此代碼,試圖注入新的jar到classpath中,但沒有成功
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");
}
我得到的錯誤是
net.sf.jasperreports.engine.JRRuntimeException: net.sf.jasperreports.engine.JRException: Input stream not found at : fonts/fontsfamily1415192514231.xml
我如何能任何想法做這個?
或者還有更好的選擇嗎?