steven_klein Posted December 16, 2016 Share Posted December 16, 2016 Hello,i am using jasperreports-6.3.1.jar together with jasperreports-fonts-6.3.1Using in my Report the Font "DejaVu Serif".On Windows 10 with JDK 1.8.0_111 everything runs fine.But on my Linux Server (Synology NAS RS815+ DSM 6.0.2-8451 Update 6) with no head (is headless so no X11 connections and no fonts installed or something like that. I do not know it better.)i got following error since there was some OS update and updates to JAVA JRE (1.8.0_101):>../volume1/Jasper$ java -jar -Djava.awt.headless=true job.jar Fontconfig error: Cannot load default config fileException in thread "main" net.sf.jasperreports.engine.JRRuntimeException: Error initializing graphic environment. at net.sf.jasperreports.engine.util.JRGraphEnvInitializer.initializeGraphEnv(JRGraphEnvInitializer.java:63) at net.sf.jasperreports.engine.fill.BaseReportFiller.<init>(BaseReportFiller.java:122) at net.sf.jasperreports.engine.fill.JRBaseFiller.<init>(JRBaseFiller.java:246) 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:159) at net.sf.jasperreports.engine.JasperFillManager.fillToFile(JasperFillManager.java:159) at net.sf.jasperreports.engine.JasperFillManager.fillReportToFile(JasperFillManager.java:692) at me.diskstation.team42.jobs.amazon.MainAnalyser.createReport(MainAnalyser.java:129) at me.diskstation.team42.jobs.amazon.MainAnalyser.main(MainAnalyser.java:100)Caused by: java.lang.NullPointerException at sun.awt.FontConfiguration.getVersion(FontConfiguration.java:1264) at sun.awt.FontConfiguration.readFontConfigFile(FontConfiguration.java:219) at sun.awt.FontConfiguration.init(FontConfiguration.java:107) at sun.awt.X11FontManager.createFontConfiguration(X11FontManager.java:774) at sun.font.SunFontManager$2.run(SunFontManager.java:431) at java.security.AccessController.doPrivileged(Native Method) at sun.font.SunFontManager.<init>(SunFontManager.java:376) at sun.awt.FcFontManager.<init>(FcFontManager.java:35) at sun.awt.X11FontManager.<init>(X11FontManager.java:57) at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) at java.lang.reflect.Constructor.newInstance(Constructor.java:423) at java.lang.Class.newInstance(Class.java:442) at sun.font.FontManagerFactory$1.run(FontManagerFactory.java:83) at java.security.AccessController.doPrivileged(Native Method) at sun.font.FontManagerFactory.getInstance(FontManagerFactory.java:74) at sun.java2d.SunGraphicsEnvironment.getFontManagerForSGE(SunGraphicsEnvironment.java:201) at sun.java2d.SunGraphicsEnvironment.getAvailableFontFamilyNames(SunGraphicsEnvironment.java:235) at sun.java2d.SunGraphicsEnvironment.getAvailableFontFamilyNames(SunGraphicsEnvironment.java:263) at sun.java2d.HeadlessGraphicsEnvironment.getAvailableFontFamilyNames(HeadlessGraphicsEnvironment.java:94) at net.sf.jasperreports.engine.util.JRGraphEnvInitializer.initializeGraphEnv(JRGraphEnvInitializer.java:57) ... 11 more Please help!THANKS! Link to comment Share on other sites More sharing options...
hozawa Posted December 16, 2016 Share Posted December 16, 2016 Did you set up font extensions? This usually happens if font jar file is not in the classpath.http://community.jaspersoft.com/wiki/custom-font-font-extension Link to comment Share on other sites More sharing options...
steven_klein Posted December 17, 2016 Author Share Posted December 17, 2016 The font jar file is in the classpath as Library.<?xml version="1.0" encoding="UTF-8"?><classpath><classpathentry kind="src" path=""/><classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>...<classpathentry kind="lib" path=".../Amazon XML Jobs/libs/jasperreports-fonts-6.3.1.jar"/>...<classpathentry kind="output" path="bin"/></classpath> When i export my project to runnable Jar-File it contains the fonts. I can execute it in console under windows or in Tomcat via Webservice both runs fine.But when i try it on Linux with no fonts installed it will not work. Why he looks for a default config file in a folder like "usr/share/fonts/...." or "usr/share/fonts/truetype" ?It is not there so dont look into it. How can i tell him not to search the OS for fonts? THANKS! Link to comment Share on other sites More sharing options...
hozawa Posted December 17, 2016 Share Posted December 17, 2016 It's trying to find the font because it can't find it in jvm. You'll have to setup jasperreports font extension or set up the font in your jvm. Link to comment Share on other sites More sharing options...
steven_klein Posted December 18, 2016 Author Share Posted December 18, 2016 Hello hozawa,thank you for your hint. I tried it with my own extension and had a little progress in troubleshooting! But i am still struggling.Now i did following:1. I followed the instructions of http://community.jaspersoft.com/wiki/custom-font-font-extension and used that font.2. Replaced all occourences of fontName="*" in my "report.jrxml" with fontName="MyFontExtension" and compiled a new report.jasper file3. Added the new jasper-file to my eclipse Project and hit run.And got an error wich i was expecting. So far so good. He looks for my font extension!Exception in thread "main" net.sf.jasperreports.engine.util.JRFontNotFoundException: Font "MyFontExtension" is not available to the JVM. See the Javadoc for more details.at net.sf.jasperreports.engine.fonts.FontUtil.checkAwtFont(FontUtil.java:652)... 4. Added the MyFonExtension.jar exported with Jaspersoft Studio to my eclipse project as external library and hit run again.And it works on windows the pdf-file has the correct font! 5. Exported the project to runnable Jar and got 2 warnings. And i think this is the problem... but still not got the trick. On Unix he now trys to find a font twice and fails. No exception but the pdf remains empty. The locations of the jasperreports_extension.properties are: MyFontExtension.jarjasperreports-6.3.1.jar Any idea? THANKS! Link to comment Share on other sites More sharing options...
hozawa Posted December 19, 2016 Share Posted December 19, 2016 jasperreports_extension.properties should have been generated. If you edit this file manually, you have to set net.sf.jasperreports.extension.simple.font.families to a unique key or you'll get duplicate error.e.g.net.sf.jasperreports.extension.simple.font.families.ireportfamily1482121183005=fonts/fontsfamily1482121183005.xml Link to comment Share on other sites More sharing options...
steven_klein Posted December 19, 2016 Author Share Posted December 19, 2016 Yes they are generated. I did not modify them. Could it be that the project export function is messing something up?in "MyFonExtension" it says:net.sf.jasperreports.extension.registry.factory.fonts=net.sf.jasperreports.engine.fonts.SimpleFontExtensionsRegistryFactorynet.sf.jasperreports.extension.simple.font.families.ireportfamily1481974224157=fonts/fontsfamily1481974224157.xml And in the API-JAR jasperreports-6.3.1.jar i am using it says: net.sf.jasperreports.extension.registry.factory.simple.font.families=net.sf.jasperreports.engine.fonts.SimpleFontExtensionsRegistryFactorynet.sf.jasperreports.extension.simple.font.families.default=net/sf/jasperreports/fonts/jasperreports-fonts.xml Link to comment Share on other sites More sharing options...
hozawa Posted December 20, 2016 Share Posted December 20, 2016 JasperReports 6.2.0 had a bug with font extensions but 6.3.1 should be alright. I'm using it on Ubuntu with Java8 and able to use font extensions.Another thing I did with 6.2.0 (the one with a bug) was to manually add the fonts to jasperreports-font.jar instead of using font-extensions. Link to comment Share on other sites More sharing options...
steven_klein Posted January 6, 2017 Author Share Posted January 6, 2017 I installed Ubuntu on VirtualBox and installed tomcat7 with "sudo apt-get tomcat7".I deployed my application and everything works fine. I think it is something wrong with the other linux installation or because it is headless.And is there a fonconfig.Linux.bfc or something like that missing? Link to comment Share on other sites More sharing options...
Solution steven_klein Posted January 18, 2017 Author Solution Share Posted January 18, 2017 [sOLVED]It is running on all Java Versions again!Java 7u79Java 7u80Java 8u111Java 8u112It seems to be a Synology specific issue of its tool "Java Manager" i deinstalled Java and reinstalled with no effect. But as i used the update function and downgraded to jdk-7u79-linux-i586.tar.gz it works again with all versions! No matter if jdk-7u79-linux-i586.tar.gz or jdk-7u79-linux-x64.tar.gz is installed.Thanks! Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now