-1

I am working on a Grails application which generates pdf and doc files. I am using jasper report and iReport to export reports in pdf and doc formats. When I try to download pdf, the following internal server error occurs:

Class: java.lang.NoClassDefFoundError
Message: Could not initialize class net.sf.jasperreports.engine.util.JRStyledTextParser.

What could be the possible reason, I am unable to figure out. I found some similar questions on stackoverflow but none of them resolved my issue.

Trying to resolve the issue from last day but not get any success.Any one please give some suggestion/solution I have lots of hope from this place.

ABC
  • 4,263
  • 10
  • 45
  • 72

4 Answers4

1

Class: java.lang.NoClassDefFoundError Message

As per the javadocs:

Thrown if the Java Virtual Machine or a ClassLoader instance tries to load in the definition of a class (as part of a normal method call or as part of creating a new instance using the new expression) and no definition of the class could be found.

It means that classes in not found during the execution. So you need to have the jar containing this class on your classpath while running your program.

In your case, I believe you are missing the jasperreports jar on the classpath as net.sf.jasperreports.engine.util.JRStyledTextParser, is conatinined in jasperreports.jar

Juned Ahsan
  • 67,789
  • 12
  • 98
  • 136
1

Basically the issue:

Class: java.lang.NoClassDefFoundError
Message: Could not initialize class net.sf.jasperreports.engine.util.JRStyledTextParser.

occured due to many factors as listed in answers.In my application problem occured due to corrupted fonts.My issue is resolved when I added jar(s) of the legitimate fonts(which my application uses) on my machine.

ABC
  • 4,263
  • 10
  • 45
  • 72
0

Can you check if you have the required jasperreports jar in the classpath? If not, adding the jar to the classpath should resolve your issue.

farmbytes
  • 81
  • 4
0
Class: java.lang.NoClassDefFoundError

basically means:

Everything was okay at compilation/packaging, but at runtime the class(class definition) could not be found.

This can happen when you compile your code against correct dependencies but at run time some of them are missing from classpath. For some troubleshooting you can look here

Community
  • 1
  • 1
rocketboy
  • 9,573
  • 2
  • 34
  • 36