NoClassDefFoundError: org/apache/fop/apps/FopFactory
Hi All, I'm running a JApplet on an Eclipse IDE on Windows 7 OS. The code is intended to turn a zipped xml file into a PDF document. When the program executes the line: code FopFactory fopFactory = FopFactory.newInstance(); code I get the following error message: --- Exception in thread AWT-EventQueue-2 java.lang.NoClassDefFoundError: org/apache/fop/apps/FopFactory at com.momaf.tiermuis.applet.health.StatementGeneratorApplet.genereateClientPDF(Unknown Source) at com.momaf.tiermuis.applet.health.StatementGeneratorApplet.access$1200(Unknown Source) at com.momaf.tiermuis.applet.health.StatementGeneratorApplet$4.actionPerformed(Unknown Source) at javax.swing.AbstractButton.fireActionPerformed(Unknown Source) at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source) at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source) at javax.swing.DefaultButtonModel.setPressed(Unknown Source) at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source) at java.awt.Component.processMouseEvent(Unknown Source) at javax.swing.JComponent.processMouseEvent(Unknown Source) at java.awt.Component.processEvent(Unknown Source) at java.awt.Container.processEvent(Unknown Source) at java.awt.Component.dispatchEventImpl(Unknown Source) at java.awt.Container.dispatchEventImpl(Unknown Source) at java.awt.Component.dispatchEvent(Unknown Source) at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source) at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source) at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source) at java.awt.Container.dispatchEventImpl(Unknown Source) at java.awt.Component.dispatchEvent(Unknown Source) at java.awt.EventQueue.dispatchEventImpl(Unknown Source) at java.awt.EventQueue.access$000(Unknown Source) at java.awt.EventQueue$1.run(Unknown Source) at java.awt.EventQueue$1.run(Unknown Source) at java.security.AccessController.doPrivileged(Native Method) at java.security.AccessControlContext$1.doIntersectionPrivilege(Unknown Source) at java.security.AccessControlContext$1.doIntersectionPrivilege(Unknown Source) at java.awt.EventQueue$2.run(Unknown Source) at java.awt.EventQueue$2.run(Unknown Source) at java.security.AccessController.doPrivileged(Native Method) at java.security.AccessControlContext$1.doIntersectionPrivilege(Unknown Source) at java.awt.EventQueue.dispatchEvent(Unknown Source) at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source) at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source) at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source) at java.awt.EventDispatchThread.pumpEvents(Unknown Source) at java.awt.EventDispatchThread.pumpEvents(Unknown Source) at java.awt.EventDispatchThread.run(Unknown Source) Caused by: java.lang.ClassNotFoundException: org.apache.fop.apps.FopFactory at sun.plugin2.applet.Applet2ClassLoader.findClass(Unknown Source) at sun.plugin2.applet.Plugin2ClassLoader.loadClass0(Unknown Source) at sun.plugin2.applet.Plugin2ClassLoader.loadClass(Unknown Source) at sun.plugin2.applet.Plugin2ClassLoader.loadClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) ... 38 more ___ Anyone? Any ideas? Your assistance is appreciated. Regards, Kamohelo
Re: Configure fonts for FOP
Hi Fernando, If you open the example in conf/fop.xconf, you'll see an example has been created (but commented out) for Arial. That is where you need to declare the font. I personally don't use the auto-detect feature, so I won't be able to help you there. But I'd suggest that you create a definition in the config file for each font individually, like the example for arial, the embed-url property let's FOP know the URL of the font file. That way if a specific font doesn't work, you can easily analyse why. As for taking TTF files from a Windows box to a Linux box, that should work fine. I don't know if that's breaking any licensing issues or the legality, but TTFs are platform independent. You may however have issues if there are any spaces in the directory or file names. Hope that helps Mehdi On 28 July 2011 12:40, Fernando Israel fernando.isr...@kognoz.com wrote: Hi Mehdi, Thank you very much for your response. It is helping me a lot. I've seen the document on fonts you suggest but your input helps me to interpret it better. So what you suggest is that I just stick all the necessary font files TTF or TTC in a directory and direct FOP to use these fonts via the configuration file using the directory element to specify that directory. Good !. Since I am only using the PDF renderer I will have an entry in the config file for it only. I will stick there the directory element with the name of the directory where I put all the necessary fonts. 1. What should I do with the auto-detect element ?. I would like to force FOP to use only the fonts in the specified directory so shall I remove the auto-detect ? 2. Using this approach will the fonts be embbeded automatically in the target (a PDF) ? 3. For testing purposes, can I take the TTF files from a Windows OS and stick them on directory on a Linux box where the server (with FOP) runs ?. Will that work ?. Thanks again for your help ! Regards, Fernando On Thu, Jul 28, 2011 at 3:45 AM, mehdi houshmand med1...@gmail.com wrote: Hi Fernando, I'll address each question individually: On 27 July 2011 23:29, Fernando Israel fernando.isr...@kognoz.com wrote: Hi All, I know this is a recurring issue but going through the documentation and forum listings I am still no clear but I hope I know what to ask. /snip The questions I have (and pardon my ignorance but fonts is not my subject) are: 1. What type of font files do I have to package ? TTF, TTC .. ?. If you're producing PDF you can use either TTF or TTC. 2. Once I create the jar file if I put it in the same directory as fop.jar I guess FOP will find it, right ?. http://xmlgraphics.apache.org/fop/1.0/fonts.html should help you configure the fonts appropriately. The font metrics files are deprecated, so no need for that, but you will have to configure the fop.xconf to let FOP know the directory of the font file. 3. If I go this route, do I have to tell FOP anything else (for instance in the configuration file) ? See the link above. 4. Does FOP always looks first in the classpath for fonts ? No, if FOP isn't explicitly given the font configuration, it looks in the System fonts, which are, as the name suggests, OS dependent. I don't think putting the font in the classpath makes the slightest bit of difference, FOP still won't have a font-name and so no way to link the font to a font-family in the FO. Hope that helps, there is also an example config file in fop directory/conf/fop.xconf, which should help you get started Mehdi - To unsubscribe, e-mail: fop-users-unsubscr...@xmlgraphics.apache.org For additional commands, e-mail: fop-users-h...@xmlgraphics.apache.org - To unsubscribe, e-mail: fop-users-unsubscr...@xmlgraphics.apache.org For additional commands, e-mail: fop-users-h...@xmlgraphics.apache.org
RE: What am I missing (loading custom font to embed)?
Thank you for your interest. It had some problem reading the font in the fop class. I gave up trying to debug it and fixed the error by reloading the project from a previous state. -Original Message- From: Chris Bowditch [mailto:bowditch_ch...@hotmail.com] Sent: Monday, July 25, 2011 8:43 AM To: fop-users@xmlgraphics.apache.org Subject: Re: What am I missing (loading custom font to embed)? On 20/07/2011 21:27, Eric Douglas wrote: This was working before but I changed something in my project, I'm not sure what, now it crashes on the last line of this bit. Crashes you say. What is the stack trace? *public**static**final*FopFactory/myFopFactory/= FopFactory./newInstance/(); TTFFontLoader myTTFLoader; CustomFont myCustomFont; FOUserAgent myUserAgent; myUserAgent =/myFopFactory/.newFOUserAgent(); FontResolver fontResolver =*new*DefaultFontResolver(myUserAgent); InputStream is; String fontFileURI; loadFontFileName = LTYPEB.TTF; is = getClass().getResourceAsStream(/resources/+ loadFontFileName); fontFileURI = DataURLUtil./createDataURL/(is,*null*); myTTFLoader =*new*TTFFontLoader(fontFileURI, fontResolver); myCustomFont = myTTFLoader.getFont(); - To unsubscribe, e-mail: fop-users-unsubscr...@xmlgraphics.apache.org For additional commands, e-mail: fop-users-h...@xmlgraphics.apache.org - To unsubscribe, e-mail: fop-users-unsubscr...@xmlgraphics.apache.org For additional commands, e-mail: fop-users-h...@xmlgraphics.apache.org
Re: Configure fonts for FOP
Hi Mehdi, I have followed your instructions and it works like a charm. Thank you ! I have taken the auto-detect out of the configuration and it picks the fonts from the directory specified so I guess it is doing what I expect which is only to include the fonts in the configured directory. Regarding the embedding of the fonts with the PDF, I've checked and the fonts are there with the target. Since I haven't told FOP anything about embedding the fonts, all it has is a directory with TTF files, I assume that the default behaviour is to embbed the fonts - it has the TTF files so it can do that I believe. Can you confirm this is the case ?. Thank you very much for your help !!! Regards, Fernando On Fri, Jul 29, 2011 at 7:59 AM, mehdi houshmand med1...@gmail.com wrote: Hi Fernando, If you open the example in conf/fop.xconf, you'll see an example has been created (but commented out) for Arial. That is where you need to declare the font. I personally don't use the auto-detect feature, so I won't be able to help you there. But I'd suggest that you create a definition in the config file for each font individually, like the example for arial, the embed-url property let's FOP know the URL of the font file. That way if a specific font doesn't work, you can easily analyse why. As for taking TTF files from a Windows box to a Linux box, that should work fine. I don't know if that's breaking any licensing issues or the legality, but TTFs are platform independent. You may however have issues if there are any spaces in the directory or file names. Hope that helps Mehdi On 28 July 2011 12:40, Fernando Israel fernando.isr...@kognoz.com wrote: Hi Mehdi, Thank you very much for your response. It is helping me a lot. I've seen the document on fonts you suggest but your input helps me to interpret it better. So what you suggest is that I just stick all the necessary font files TTF or TTC in a directory and direct FOP to use these fonts via the configuration file using the directory element to specify that directory. Good !. Since I am only using the PDF renderer I will have an entry in the config file for it only. I will stick there the directory element with the name of the directory where I put all the necessary fonts. 1. What should I do with the auto-detect element ?. I would like to force FOP to use only the fonts in the specified directory so shall I remove the auto-detect ? 2. Using this approach will the fonts be embbeded automatically in the target (a PDF) ? 3. For testing purposes, can I take the TTF files from a Windows OS and stick them on directory on a Linux box where the server (with FOP) runs ?. Will that work ?. Thanks again for your help ! Regards, Fernando On Thu, Jul 28, 2011 at 3:45 AM, mehdi houshmand med1...@gmail.com wrote: Hi Fernando, I'll address each question individually: On 27 July 2011 23:29, Fernando Israel fernando.isr...@kognoz.com wrote: Hi All, I know this is a recurring issue but going through the documentation and forum listings I am still no clear but I hope I know what to ask. /snip The questions I have (and pardon my ignorance but fonts is not my subject) are: 1. What type of font files do I have to package ? TTF, TTC .. ?. If you're producing PDF you can use either TTF or TTC. 2. Once I create the jar file if I put it in the same directory as fop.jar I guess FOP will find it, right ?. http://xmlgraphics.apache.org/fop/1.0/fonts.html should help you configure the fonts appropriately. The font metrics files are deprecated, so no need for that, but you will have to configure the fop.xconf to let FOP know the directory of the font file. 3. If I go this route, do I have to tell FOP anything else (for instance in the configuration file) ? See the link above. 4. Does FOP always looks first in the classpath for fonts ? No, if FOP isn't explicitly given the font configuration, it looks in the System fonts, which are, as the name suggests, OS dependent. I don't think putting the font in the classpath makes the slightest bit of difference, FOP still won't have a font-name and so no way to link the font to a font-family in the FO. Hope that helps, there is also an example config file in fop directory/conf/fop.xconf, which should help you get started Mehdi - To unsubscribe, e-mail: fop-users-unsubscr...@xmlgraphics.apache.org For additional commands, e-mail: fop-users-h...@xmlgraphics.apache.org - To unsubscribe, e-mail: fop-users-unsubscr...@xmlgraphics.apache.org For additional commands, e-mail: fop-users-h...@xmlgraphics.apache.org