java - Unexpected exception while filling JasperReports report - Could not initialize net.sf.jasperreports.engine.util.JRStyledTextParser (GWT) -
i building website gwt , want incorporate report generator in site using jasperreports. data report draws store in database in cloud, use instance , cloud sql connect database , retrieve/store data (basically user table). user supposed login credentials , pressing button "download" should able generated report in pdf form. have implemented rpc process.
the problem when jasperfillmanager.fillreport
method called fill report, following exception
severe: javax.servlet.servletcontext log: exception while dispatching incoming rpc call com.google.gwt.user.server.rpc.unexpectedexception: service method 'public abstract java.lang.string com.myproject.website.client.reportservice.createreport(java.lang.string,java.lang.string)' threw unexpected exception: java.lang.noclassdeffounderror: java.awt.font restricted class. please see google app engine developer's guide more details. @ com.google.gwt.user.server.rpc.rpc.encoderesponseforfailure(rpc.java:389) @ com.google.gwt.user.server.rpc.rpc.invokeandencoderesponse(rpc.java:579) @ com.google.gwt.user.server.rpc.remoteserviceservlet.processcall(remoteserviceservlet.java:208) @ com.google.gwt.user.server.rpc.remoteserviceservlet.processpost(remoteserviceservlet.java:248) @ com.google.gwt.user.server.rpc.abstractremoteserviceservlet.dopost(abstractremoteserviceservlet.java:62) @ javax.servlet.http.httpservlet.service(httpservlet.java:637) @ javax.servlet.http.httpservlet.service(httpservlet.java:717) @ org.mortbay.jetty.servlet.servletholder.handle(servletholder.java:511) @ org.mortbay.jetty.servlet.servlethandler$cachedchain.dofilter(servlethandler.java:1166) @ com.google.appengine.api.socket.dev.devsocketfilter.dofilter(devsocketfilter.java:74) @ org.mortbay.jetty.servlet.servlethandler$cachedchain.dofilter(servlethandler.java:1157) @ com.google.appengine.tools.development.responserewriterfilter.dofilter(responserewriterfilter.java:123) @ org.mortbay.jetty.servlet.servlethandler$cachedchain.dofilter(servlethandler.java:1157) @ com.google.appengine.tools.development.headerverificationfilter.dofilter(headerverificationfilter.java:34) @ org.mortbay.jetty.servlet.servlethandler$cachedchain.dofilter(servlethandler.java:1157) @ com.google.appengine.api.blobstore.dev.serveblobfilter.dofilter(serveblobfilter.java:61) @ org.mortbay.jetty.servlet.servlethandler$cachedchain.dofilter(servlethandler.java:1157) @ com.google.apphosting.utils.servlet.transactioncleanupfilter.dofilter(transactioncleanupfilter.java:43) @ org.mortbay.jetty.servlet.servlethandler$cachedchain.dofilter(servlethandler.java:1157) @ com.google.appengine.tools.development.staticfilefilter.dofilter(staticfilefilter.java:125) @ org.mortbay.jetty.servlet.servlethandler$cachedchain.dofilter(servlethandler.java:1157) @ com.google.appengine.tools.development.backendserversfilter.dofilter(backendserversfilter.java:97) @ org.mortbay.jetty.servlet.servlethandler$cachedchain.dofilter(servlethandler.java:1157) @ org.mortbay.jetty.servlet.servlethandler.handle(servlethandler.java:388) @ org.mortbay.jetty.security.securityhandler.handle(securityhandler.java:216) @ org.mortbay.jetty.servlet.sessionhandler.handle(sessionhandler.java:182) @ org.mortbay.jetty.handler.contexthandler.handle(contexthandler.java:765) @ org.mortbay.jetty.webapp.webappcontext.handle(webappcontext.java:418) @ com.google.appengine.tools.development.devappenginewebappcontext.handle(devappenginewebappcontext.java:94) @ org.mortbay.jetty.handler.handlerwrapper.handle(handlerwrapper.java:152) @ com.google.appengine.tools.development.jettycontainerservice$apiproxyhandler.handle(jettycontainerservice.java:383) @ org.mortbay.jetty.handler.handlerwrapper.handle(handlerwrapper.java:152) @ org.mortbay.jetty.server.handle(server.java:326) @ org.mortbay.jetty.httpconnection.handlerequest(httpconnection.java:542) @ org.mortbay.jetty.httpconnection$requesthandler.content(httpconnection.java:938) @ org.mortbay.jetty.httpparser.parsenext(httpparser.java:755) @ org.mortbay.jetty.httpparser.parseavailable(httpparser.java:218) @ org.mortbay.jetty.httpconnection.handle(httpconnection.java:404) @ org.mortbay.io.nio.selectchannelendpoint.run(selectchannelendpoint.java:409) @ org.mortbay.thread.queuedthreadpool$poolthread.run(queuedthreadpool.java:582) caused by: java.lang.noclassdeffounderror: java.awt.font restricted class. please see google app engine developer's guide more details. @ com.google.appengine.tools.development.agent.runtime.runtime.reject(runtime.java:51) @ net.sf.jasperreports.engine.fonts.simplefontface.<init>(simplefontface.java:100) @ net.sf.jasperreports.engine.fonts.simplefontface.<init>(simplefontface.java:128) @ net.sf.jasperreports.engine.fonts.simplefontface.getinstance(simplefontface.java:67) @ net.sf.jasperreports.engine.fonts.simplefontfamily.setnormal(simplefontfamily.java:99) @ net.sf.jasperreports.engine.fonts.simplefontextensionhelper.parsefontfamily(simplefontextensionhelper.java:261) @ net.sf.jasperreports.engine.fonts.simplefontextensionhelper.parsefontfamilies(simplefontextensionhelper.java:232) @ net.sf.jasperreports.engine.fonts.simplefontextensionhelper.loadfontfamilies(simplefontextensionhelper.java:193) @ net.sf.jasperreports.engine.fonts.simplefontextensionhelper.loadfontfamilies(simplefontextensionhelper.java:162) @ net.sf.jasperreports.engine.fonts.fontextensionsregistry.getextensions(fontextensionsregistry.java:56) @ net.sf.jasperreports.extensions.defaultextensionsregistry.getextensions(defaultextensionsregistry.java:110) @ net.sf.jasperreports.engine.util.jrstyledtextparser.<clinit>(jrstyledtextparser.java:83) @ java.lang.class.forname0(native method) @ java.lang.class.forname(unknown source) @ com.google.appengine.tools.development.agent.runtime.runtimehelper.checkrestricted(runtimehelper.java:70) @ com.google.appengine.tools.development.agent.runtime.runtime.checkrestricted(runtime.java:64) @ net.sf.jasperreports.engine.fill.jrbasefiller.<init>(jrbasefiller.java:121) @ net.sf.jasperreports.engine.fill.jrverticalfiller.<init>(jrverticalfiller.java:88) @ net.sf.jasperreports.engine.fill.jrverticalfiller.<init>(jrverticalfiller.java:103) @ net.sf.jasperreports.engine.fill.jrverticalfiller.<init>(jrverticalfiller.java:61) @ net.sf.jasperreports.engine.fill.jrfiller.createfiller(jrfiller.java:153) @ net.sf.jasperreports.engine.fill.jrfiller.fill(jrfiller.java:55) @ net.sf.jasperreports.engine.jasperfillmanager.fill(jasperfillmanager.java:446) @ net.sf.jasperreports.engine.jasperfillmanager.fill(jasperfillmanager.java:276) @ net.sf.jasperreports.engine.jasperfillmanager.fillreport(jasperfillmanager.java:745) @ com.myproject.website.server.reportserviceimpl.createreport(reportserviceimpl.java:65) @ sun.reflect.nativemethodaccessorimpl.invoke0(native method) @ sun.reflect.nativemethodaccessorimpl.invoke(unknown source) @ sun.reflect.delegatingmethodaccessorimpl.invoke(unknown source) @ java.lang.reflect.method.invoke(unknown source) @ com.google.appengine.tools.development.agent.runtime.runtime.invoke(runtime.java:115) @ com.google.gwt.user.server.rpc.rpc.invokeandencoderesponse(rpc.java:561) ... 38 more not generate report
if press download button again (without having changed anything) different exception
severe: javax.servlet.servletcontext log: exception while dispatching incoming rpc call com.google.gwt.user.server.rpc.unexpectedexception: service method 'public abstract java.lang.string com.myproject.website.client.reportservice.createreport(java.lang.string,java.lang.string)' threw unexpected exception: java.lang.noclassdeffounderror: not initialize class net.sf.jasperreports.engine.util.jrstyledtextparser @ com.google.gwt.user.server.rpc.rpc.encoderesponseforfailure(rpc.java:389) @ com.google.gwt.user.server.rpc.rpc.invokeandencoderesponse(rpc.java:579) @ com.google.gwt.user.server.rpc.remoteserviceservlet.processcall(remoteserviceservlet.java:208) @ com.google.gwt.user.server.rpc.remoteserviceservlet.processpost(remoteserviceservlet.java:248) @ com.google.gwt.user.server.rpc.abstractremoteserviceservlet.dopost(abstractremoteserviceservlet.java:62) @ javax.servlet.http.httpservlet.service(httpservlet.java:637) @ javax.servlet.http.httpservlet.service(httpservlet.java:717) @ org.mortbay.jetty.servlet.servletholder.handle(servletholder.java:511) @ org.mortbay.jetty.servlet.servlethandler$cachedchain.dofilter(servlethandler.java:1166) @ com.google.appengine.api.socket.dev.devsocketfilter.dofilter(devsocketfilter.java:74) @ org.mortbay.jetty.servlet.servlethandler$cachedchain.dofilter(servlethandler.java:1157) @ com.google.appengine.tools.development.responserewriterfilter.dofilter(responserewriterfilter.java:123) @ org.mortbay.jetty.servlet.servlethandler$cachedchain.dofilter(servlethandler.java:1157) @ com.google.appengine.tools.development.headerverificationfilter.dofilter(headerverificationfilter.java:34) @ org.mortbay.jetty.servlet.servlethandler$cachedchain.dofilter(servlethandler.java:1157) @ com.google.appengine.api.blobstore.dev.serveblobfilter.dofilter(serveblobfilter.java:61) @ org.mortbay.jetty.servlet.servlethandler$cachedchain.dofilter(servlethandler.java:1157) @ com.google.apphosting.utils.servlet.transactioncleanupfilter.dofilter(transactioncleanupfilter.java:43) @ org.mortbay.jetty.servlet.servlethandler$cachedchain.dofilter(servlethandler.java:1157) @ com.google.appengine.tools.development.staticfilefilter.dofilter(staticfilefilter.java:125) @ org.mortbay.jetty.servlet.servlethandler$cachedchain.dofilter(servlethandler.java:1157) @ com.google.appengine.tools.development.backendserversfilter.dofilter(backendserversfilter.java:97) @ org.mortbay.jetty.servlet.servlethandler$cachedchain.dofilter(servlethandler.java:1157) @ org.mortbay.jetty.servlet.servlethandler.handle(servlethandler.java:388) @ org.mortbay.jetty.security.securityhandler.handle(securityhandler.java:216) @ org.mortbay.jetty.servlet.sessionhandler.handle(sessionhandler.java:182) @ org.mortbay.jetty.handler.contexthandler.handle(contexthandler.java:765) @ org.mortbay.jetty.webapp.webappcontext.handle(webappcontext.java:418) @ com.google.appengine.tools.development.devappenginewebappcontext.handle(devappenginewebappcontext.java:94) @ org.mortbay.jetty.handler.handlerwrapper.handle(handlerwrapper.java:152) @ com.google.appengine.tools.development.jettycontainerservice$apiproxyhandler.handle(jettycontainerservice.java:383) @ org.mortbay.jetty.handler.handlerwrapper.handle(handlerwrapper.java:152) @ org.mortbay.jetty.server.handle(server.java:326) @ org.mortbay.jetty.httpconnection.handlerequest(httpconnection.java:542) @ org.mortbay.jetty.httpconnection$requesthandler.content(httpconnection.java:938) @ org.mortbay.jetty.httpparser.parsenext(httpparser.java:755) @ org.mortbay.jetty.httpparser.parseavailable(httpparser.java:218) @ org.mortbay.jetty.httpconnection.handle(httpconnection.java:404) @ org.mortbay.io.nio.selectchannelendpoint.run(selectchannelendpoint.java:409) @ org.mortbay.thread.queuedthreadpool$poolthread.run(queuedthreadpool.java:582) caused by: java.lang.noclassdeffounderror: not initialize class net.sf.jasperreports.engine.util.jrstyledtextparser @ java.lang.class.forname0(native method) @ java.lang.class.forname(unknown source) @ com.google.appengine.tools.development.agent.runtime.runtimehelper.checkrestricted(runtimehelper.java:70) @ com.google.appengine.tools.development.agent.runtime.runtime.checkrestricted(runtime.java:64) @ net.sf.jasperreports.engine.fill.jrbasefiller.<init>(jrbasefiller.java:121) @ net.sf.jasperreports.engine.fill.jrverticalfiller.<init>(jrverticalfiller.java:88) @ net.sf.jasperreports.engine.fill.jrverticalfiller.<init>(jrverticalfiller.java:103) @ net.sf.jasperreports.engine.fill.jrverticalfiller.<init>(jrverticalfiller.java:61) @ net.sf.jasperreports.engine.fill.jrfiller.createfiller(jrfiller.java:153) @ net.sf.jasperreports.engine.fill.jrfiller.fill(jrfiller.java:55) @ net.sf.jasperreports.engine.jasperfillmanager.fill(jasperfillmanager.java:446) @ net.sf.jasperreports.engine.jasperfillmanager.fill(jasperfillmanager.java:276) @ net.sf.jasperreports.engine.jasperfillmanager.fillreport(jasperfillmanager.java:745) @ com.myproject.website.server.reportserviceimpl.createreport(reportserviceimpl.java:65) @ sun.reflect.nativemethodaccessorimpl.invoke0(native method) @ sun.reflect.nativemethodaccessorimpl.invoke(unknown source) @ sun.reflect.delegatingmethodaccessorimpl.invoke(unknown source) @ java.lang.reflect.method.invoke(unknown source) @ com.google.appengine.tools.development.agent.runtime.runtime.invoke(runtime.java:115) @ com.google.gwt.user.server.rpc.rpc.invokeandencoderesponse(rpc.java:561) ... 38 more not generate report
after looking while in internet read on might missing library issue added libraries jasperreports distribution classpath of project. files in classpath (from jr distribution) are:
- commons-beanutils-1.8.0.jar
- commons-collections-2.1.1.jar
- commons-digester-2.1.jar
- commons-javaflow-20060411.jar
- commons-logging-1.1.1.jar
- itext-2.1.7.js1.jar
- jasperreports-5.0.0.jar
- jasperreports-fonts-5.0.0.jar
- jasperreports-javaflow-5.0.0.jar
yet, still same exception thrown...
any hint of should problem?
i post here code downloadreport function rpc methods
downloadreport method
void downloadreport(string username, string password){ // create report , reportservice.util.getinstance().createreport(username, password, new asynccallback<string>(){ @override public void onsuccess(string result){ // url of created report file returned text1.settext(result); } @override public void onfailure(throwable caught){ system.out.println("could not generate report"); } }); }
reportservice.java
package com.myproject.website.client; import com.google.gwt.core.client.gwt; import com.google.gwt.user.client.rpc.remoteservice; import com.google.gwt.user.client.rpc.remoteservicerelativepath; @remoteservicerelativepath("reportservice") public interface reportservice extends remoteservice { public static class util { private static reportserviceasync instance; public static reportserviceasync getinstance() { if (instance == null) { instance = gwt.create(reportservice.class); } return instance; } } string createreport(string name, string password); }
reportserviceimpl.java
package com.myproject.website.server; import java.sql.connection; import java.sql.drivermanager; import java.sql.preparedstatement; import java.sql.resultset; import java.sql.sqlexception; import com.google.appengine.api.rdbms.appenginedriver; import com.google.gwt.user.server.rpc.remoteserviceservlet; import com.myproject.website.client.reportservice; import java.io.file; import java.io.ioexception; import java.io.printwriter; import java.util.hashmap; import java.util.map; import net.sf.jasperreports.engine.jasperfillmanager; import net.sf.jasperreports.engine.jrexception; import net.sf.jasperreports.engine.jrruntimeexception; import net.sf.jasperreports.engine.jasperexportmanager; import net.sf.jasperreports.engine.jasperfillmanager; import net.sf.jasperreports.engine.jasperprint; import net.sf.jasperreports.engine.util.*; import net.sf.jasperreports.j2ee.servlets.basehttpservlet; @suppresswarnings("serial") public class reportserviceimpl extends remoteserviceservlet implements reportservice{ @override public string createreport(string name, string password) { string temp = null; connection c = null; map<string, object> rparamet = new hashmap<string, object>(); try { drivermanager.registerdriver(new appenginedriver()); c = drivermanager.getconnection("jdbc:google:rdbms://myproject:dbutest/dbtest"); rparamet.put("email", name); rparamet.put("password", password); rparamet.put("reporttitle", "test report"); string sourcefile = this.getservletcontext().getrealpath("web-inf") + "/testreport.jasper"; try { jasperprint reportprint = jasperfillmanager.fillreport(sourcefile, rparamet, c); jasperexportmanager.exportreporttopdffile(reportprint, "reporttest"); } catch (jrexception e) { // todo auto-generated catch block e.printstacktrace(); } } catch (sqlexception e) { e.printstacktrace(); } { if (c != null) try { c.close(); } catch (sqlexception ignore) { } } // more code added here getting report url return temp; } }
thanks in advance!
from first stack trace: java.lang.noclassdeffounderror: java.awt.font restricted class. please see google app engine developer's guide more details.
that guide refers https://developers.google.com/appengine/docs/java/jrewhitelist
so:
- either want make reports in app that'll deployed appengine, , have find library, jasperreports doesn't work in environment
- or don't intend run on appengine , misconfigured project
Comments
Post a Comment