Error when running reports: Could not initialize class net.sf.jasperreports.engine.util.JRStyledTextParser

Issue description

When trying to run any report on a server, the following error is thrown:

Table of Contents 
java.lang.NoClassDefFoundError: Could not initialize class net.sf.jasperreports.engine.util.JRStyledTextParser 
Error Trace 
 
com.jaspersoft.jasperserver.api.JSException: java.lang.NoClassDefFoundError: Could not initialize class net.sf.jasperreports.engine.util.JRStyledTextParser at 
com.jaspersoft.jasperserver.api.engine.jasperreports.service.impl.EngineServiceImpl.fillReport(EngineServiceImpl.java:628) at 
com.jaspersoft.jasperserver.api.engine.jasperreports.service.impl.EngineServiceImpl.executeReportUnitRequest(EngineServiceImpl.java:1953) at 
com.jaspersoft.jasperserver.api.engine.jasperreports.domain.impl.ReportUnitRequest.execute(ReportUnitRequest.java:67) at 
com.jaspersoft.jasperserver.api.engine.jasperreports.service.impl.EngineServiceImpl.execute(EngineServiceImpl.java:505) at 
sun.reflect.GeneratedMethodAccessor822.invoke(Unknown Source) at 
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at 
java.lang.reflect.Method.invoke(Method.java:498) at 
org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:317) at 
org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:183) at 
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150) at 
org.springframework.aop.aspectj.MethodInvocationProceedingJoinPoint.proceed(MethodInvocationProceedingJoinPoint.java:80) at 
com.jaspersoft.ji.license.LicenseCheckAspect.runReport(LicenseCheckAspect.java:139) at 
sun.reflect.GeneratedMethodAccessor821.invoke(Unknown Source) at 
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at 
java.lang.reflect.Method.invoke(Method.java:498)

Troubleshooting

This error is normally associated with a JVM not being started on a Linux machine in AWT headless mode. JasperReports Server doesn’t provide a virtual X frame buffer on Linux. To prevent Java from trying to connect to an X-Server for image processing in JRS, please modify your application server's startup script to include the following JAVA_OPTS

-Djava.awt.headless=true 

make sure to restart the server after this modification before testing the report again.

The other possible causes of this error re:

  • one or more jar files are missing from Jasperreports Server installation for some reason

  • one or more default system fonts are not accessible in this environment

I'd start by checking if all jars are present in the <js-webapp>/WEB-INF/libs folder by comparing the contents of it with the same folder in a working environment.

If that doesn't help, here is a stackoverflow.com thread where people were having the same error and provide a couple of solutions that worked:


Ref. case #00068653

Feedback