Java Net.sf.jasperreports.engine.util.JRStyledTextParser 上的 JasperReports NoClassDefFoundError 异常
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3628302/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
JasperReports NoClassDefFoundError exception on net.sf.jasperreports.engine.util.JRStyledTextParser
提问by Esteve Camps
When trying to export on WebLogic 11g, it throws NoClassDefFound exception. I checked the application WAR and jasperreports-3.7.4.jar is included in WEB-INF/lib folder. What is the error?
尝试在 WebLogic 11g 上导出时,会引发 NoClassDefFound 异常。我检查了应用程序 WAR,jasperreports-3.7.4.jar 包含在 WEB-INF/lib 文件夹中。错误是什么?
StackTrace
堆栈跟踪
java.lang.NoClassDefFoundError: net/sf/jasperreports/engine/util/JRStyledTextParser at net.sf.jasperreports.engine.fill.JRBaseFiller.(JRBaseFiller.java:181) at net.sf.jasperreports.engine.fill.JRVerticalFiller.(JRVerticalFiller.java:76) at net.sf.jasperreports.engine.fill.JRVerticalFiller.(JRVerticalFiller.java:86) at net.sf.jasperreports.engine.fill.JRVerticalFiller.(JRVerticalFiller.java:56) at net.sf.jasperreports.engine.fill.JRFiller.createFiller(JRFiller.java:142) at net.sf.jasperreports.engine.fill.JRFiller.fillReport(JRFiller.java:78) at net.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillManager.java:624) at org.springframework.web.servlet.view.jasperreports.AbstractJasperReportsView.fillReport(AbstractJasperReportsView.java:676) at
java.lang.NoClassDefFoundError: net/sf/jasperreports/engine/util/JRStyledTextParser at net.sf.jasperreports.engine.fill.JRBaseFiller.(JRBaseFiller.java:181) at net.sf.jasperreports.engine.fill.JRVerticalFiller。 (JRVerticalFiller.java:76) at net.sf.jasperreports.engine.fill.JRVerticalFiller.(JRVerticalFiller.java:86) at net.sf.jasperreports.engine.fill.JRVerticalFiller.(JRVerticalFiller.java:56) at net. sf.jasperreports.engine.fill.JRFiller.createFiller(JRFiller.java:142) 在 net.sf.jasperreports.engine.fill.JRFiller.fillReport(JRFiller.java:78) 在 net.sf.jasperreports.engine.JasperFillManager。 fillReport(JasperFillManager.java:624) 在 org.springframework.web.servlet.view.jasperreports.AbstractJasperReportsView.fillReport(AbstractJasperReportsView.java:676) 在
采纳答案by Esteve Camps
Finally, I've got it working. I detected the root Exception, which was thrown before NoClassDefFoundError:net/sf/jasperreports/engine/util/JRStyledTextParser :
最后,我让它工作了。我检测到在 NoClassDefFoundError:net/sf/jasperreports/engine/util/JRStyledTextParser 之前抛出的根异常:
java.lang.NoClassDefFoundError: sun/awt/X11GraphicsEnvironment
The Sun AWT classes on Unix and Linux have a dependence on the X Window System. When you use these classes, they expect to load X client libraries and be able to talk to an X display server. This makes sense if your client has a GUI; unfortunately, it's required even if your client uses AWT but does not have a GUI (which is my case, generating a report from a web application)
Unix 和 Linux 上的 Sun AWT 类依赖于 X Window 系统。当您使用这些类时,它们希望加载 X 客户端库并能够与 X 显示服务器通信。如果您的客户端有 GUI,这是有道理的;不幸的是,即使您的客户端使用 AWT 但没有 GUI(这就是我的情况,从 Web 应用程序生成报告)也是必需的
The way to bypass this, is setting a system property java.awt.headless=true
on system startup.
绕过这个的方法是java.awt.headless=true
在系统启动时设置系统属性。
回答by Lorenzo
Text Parsing Exception means the font not have been recognized. I spent an whole day trying to understand why, then finally I fix this problem using text SansSerif. On Linux only a few font can be parsed. Hoping has helped, best regards
文本解析异常意味着字体未被识别。我花了一整天试图理解为什么,最后我使用文本 SansSerif 解决了这个问题。在 Linux 上只能解析少数字体。希望有所帮助,最好的问候
回答by Tony A
We had similar issue. we resolved it by using the jasper java flow jar file. the
我们有类似的问题。我们通过使用 jasper java flow jar 文件解决了它。这
java.awt.headless=true
didn't work for us.
对我们不起作用。
回答by rudygodoy
I experienced the same issue and we've solved it by installing the xorg fonts packages along with the ttf fonts.
我遇到了同样的问题,我们通过安装 xorg 字体包和 ttf 字体解决了这个问题。
回答by drinovc
You get the same error if there is no enough space. I had the same error and it was because there was 0KB free space on server's hard drive.
如果没有足够的空间,你会得到同样的错误。我遇到了同样的错误,这是因为服务器硬盘上有 0KB 可用空间。
回答by Ankit Kachchhi
I had the same issue and it was resolved by reducing the /tmp space. It was 100% (/tmp folder). I reduced it to 86% and restarted the server and the noclassdefinitionerror was gone and issue was resolved.
我遇到了同样的问题,并通过减少 /tmp 空间解决了这个问题。它是 100%(/tmp 文件夹)。我将其降低到 86% 并重新启动服务器,noclassdefinitionerror 消失了,问题也解决了。
回答by Randhish kumar
Faced this issue multiple times and I have got the solution. This error comes due to lack of memory space on disk... You can try below things to solve : (i) Make enough space in tmp folder (ii) Delete some unnecessary files on the disk to make some space.
多次面对这个问题,我已经得到了解决方案。这个错误是由于磁盘上的内存空间不足...您可以尝试以下方法来解决:(i) 在 tmp 文件夹中留出足够的空间 (ii) 删除磁盘上一些不需要的文件以腾出一些空间。
Good luck..Hope.. it should solve your issue
祝你好运..希望..它应该可以解决你的问题
回答by vsingh
Once you have this problem, googling will bring you here. For me the problem was Jdk 11.2.
一旦你遇到这个问题,谷歌搜索就会把你带到这里。对我来说,问题是 Jdk 11.2。
Caused by: java.lang.reflect.InvocationTargetException
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:490)
at java.desktop/sun.font.FontManagerFactory.run(FontManagerFactory.java:84)
... 85 more
Caused by: java.lang.NullPointerException
at java.desktop/sun.awt.FontConfiguration.getVersion(FontConfiguration.java:1262)
at java.desktop/sun.awt.FontConfiguration.readFontConfigFile(FontConfiguration.java:225)
at java.desktop/sun.awt.FontConfiguration.init(FontConfiguration.java:107)
at java.desktop/sun.awt.X11FontManager.createFontConfiguration(X11FontManager.java:719)
at java.desktop/sun.font.SunFontManager.run(SunFontManager.java:367)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at java.desktop/sun.font.SunFontManager.<init>(SunFontManager.java:312)
at java.desktop/sun.awt.FcFontManager.<init>(FcFontManager.java:35)
at java.desktop/sun.awt.X11FontManager.<init>(X11FontManager.java:56)
... 90 more
java.lang.InternalError: java.lang.reflect.InvocationTargetException
at java.desktop/sun.font.FontManagerFactory.run(FontManagerFactory.java:86)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at java.desktop/sun.font.FontManagerFactory.getInstance(FontManagerFactory.java:74)
at java.desktop/sun.java2d.SunGraphicsEnvironment.getFontManagerForSGE(SunGraphicsEnvironment.java:189)
at java.desktop/sun.java2d.SunGraphicsEnvironment.getAvailableFontFamilyNames(SunGraphicsEnvironment.java:223)
at java.desktop/sun.java2d.SunGraphicsEnvironment.getAvailableFontFamilyNames(SunGraphicsEnvironment.java:251)
at java.desktop/sun.java2d.HeadlessGraphicsEnvironment.getAvailableFontFamilyNames(HeadlessGraphicsEnvironment.java:75)
at net.sf.jasperreports.engine.util.JRStyledTextParser.<clinit>(JRStyledTextParser.java:94)
at net.sf.jasperreports.engine.fill.JRBaseFiller.<init>(JRBaseFiller.java:110)
at net.sf.jasperreports.engine.fill.JRVerticalFiller.<init>(JRVerticalFiller.java:69)
at net.sf.jasperreports.engine.fill.JRVerticalFiller.<init>(JRVerticalFiller.java:57)
at net.sf.jasperreports.engine.fill.JRFiller.createBandReportFiller(JRFiller.java:200)
at net.sf.jasperreports.engine.fill.JRFiller.createReportFiller(JRFiller.java:215)
at net.sf.jasperreports.engine.fill.JRFiller.fill(JRFiller.java:115)
at net.sf.jasperreports.engine.JasperFillManager.fill(JasperFillManager.java:667)
Solutions tried
尝试过的解决方案
- Ran locally with JDK 11.02. No problems. Because the problems happens on linux 64 systems
- Ran on server -Djava-awt.headeless=true as suggested by some users . Problem still remains.
- 使用 JDK 11.02 在本地运行。没问题。因为问题发生在 linux 64 系统上
- 按照某些用户的建议,在服务器 -Djava-awt.headeless=true 上运行。问题仍然存在。
Reason this problem occurs is because support of certain fonts have been removed
出现此问题的原因是已删除对某些字体的支持
From Oracle release notes https://www.oracle.com/technetwork/java/javase/11-relnote-issues-5012449.html#Removed
来自 Oracle 发行说明 https://www.oracle.com/technetwork/java/javase/11-relnote-issues-5012449.html#Removed
Removal of Lucida Fonts from Oracle JDK Oracle JDK no longer ships any fonts and relies entirely on fonts installed on the operating system.
This means that fonts in the Bigelow & Holmes Lucida family (Lucida Sans, Lucida Bright, and Lucida Typewriter) are no longer available to applications from the JDK.
If applications rely on fonts shipped in the JDK, they may need to be updated.
If system adminstrators are running Java server applications that rely on fonts shipped in the JDK rather than on system font packages, then the applications may fail to run until the system font packages are installed.
从 Oracle JDK 中删除 Lucida 字体 Oracle JDK 不再提供任何字体,并且完全依赖于安装在操作系统上的字体。
这意味着 Bigelow & Holmes Lucida 系列(Lucida Sans、Lucida Bright 和 Lucida Typewriter)中的字体不再可用于 JDK 的应用程序。
如果应用程序依赖于 JDK 中提供的字体,则它们可能需要更新。
如果系统管理员运行的 Java 服务器应用程序依赖于 JDK 中提供的字体而不是系统字体包,则应用程序可能无法运行,直到安装系统字体包。
Go back to previous version of JDK or you can try upgrading Jasper.
回到以前的 JDK 版本,或者您可以尝试升级 Jasper。
回答by AntimoV
for my case, jasperreports 6.8.0, worked the change of project dependency xml-apis from version
就我而言,jasperreports 6.8.0 改变了项目依赖项 xml-apis 从版本
<dependency>
<groupId>xml-apis</groupId>
<artifactId>xml-apis</artifactId>
<version>2.0.2</version>
</dependency>
to
到
<dependency>
<groupId>xml-apis</groupId>
<artifactId>xml-apis</artifactId>
<version>1.4.01</version>
</dependency>
as proposed in jaspersoft community forum https://community.jaspersoft.com/questions/825173/could-not-initialize-class-netsfjasperreportsengineutiljrstyledtextparser
正如在 jaspersoft 社区论坛中提出的https://community.jaspersoft.com/questions/825173/could-not-initialize-class-netsfjasperreportsengineutiljrstyledtextparser