Apache Fop 1.1, how to get it running?



  • C:\Program Files\Apache Fop>fop
    Unable to start FOP:
    java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.apache.fop.cli.Main.startFOPWithDynamicClasspath(Main.java:136)
    at org.apache.fop.cli.Main.main(Main.java:210)
    Caused by: java.lang.NoClassDefFoundError: org/apache/xmlgraphics/image/loader/I
    mageContext
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClass(Unknown Source)
    at java.security.SecureClassLoader.defineClass(Unknown Source)
    at java.net.URLClassLoader.defineClass(Unknown Source)
    at java.net.URLClassLoader.access$100(Unknown Source)
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at org.apache.fop.cli.CommandLineOptions.<init>(CommandLineOptions.java:
    124)
    at org.apache.fop.cli.Main.startFOP(Main.java:160)
    ... 6 more
    Caused by: java.lang.ClassNotFoundException: org.apache.xmlgraphics.image.loader
    .ImageContext
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    ... 19 more

    C:\Program Files\Apache Fop>
    

    I'm guessing from this post I found while googling the error it has something to do with a "local class path", whatever the hell that is? Does anybody know how to find the "local class path" in Windows, and/or how to set FOP to use the correct one?

    Natch, there's zero about this on FOP's webpage under "known issues" or "release notes", so no help there. Googling the problem also brought up this post, but I think he's actually try to compile the FOP, I'm merely trying to run it. (I also tried running FOP as admin; made no different to the error displayed.)



  • Tried poking it with the CLASSPATH environment variable yet? That should fit any definition of "local class path" out there...



  • Assuming you mean a Windows environment variable and not something specific to Java, I don't seem to have one at all... is that something you're expected to do manually, or is that something the Java installer fucked up on?

    I can add it manually I guess.


  • I survived the hour long Uno hand

    Here's the basics of CLASSPATH:

    It's basically a Java-specific PATH, in a separate variable because Java.

    From your link, LOCALCLASSPATH seems to be a cygwin thing? That's not something that I'm familiar with as a Java developer.



  • You don't need to set an environment variable for this (unless you want to break all your Java applications that is).



  • I have no idea, the guy in that post is using CYGWIN, I am not. The answer to his problem might be completely irrelevant to mine.

    To check whether CLASSPATH is set on Microsoft Windows NT/2000/XP, execute the following:

    C:> echo %CLASSPATH%

    If CLASSPATH is not set you will get a CLASSPATH: Undefined variable error (Solaris or Linux) or simply %CLASSPATH% (Microsoft Windows NT/2000/XP).

    I will?

    C:\Program Files\Apache Fop>echo %classpath%
    %classpath%
    
    C:\Program Files\Apache Fop>echo %CLASSPATH%
    %CLASSPATH%
    
    C:\Program Files\Apache Fop>
    

    Good thing this documentation isn't full of lies. EDIT: Oh, no, it's right. They just confusingly put the output for Solaris and Linux before the output for Windows, even though the instructions for Windows come before the-- nevermind, nobody can write or communicate anything in the Java world ever.

    Sorry enough griping. I need solid advice, what the heck do I do? I can set CLASSPATH but what do I set it to?



  • @Yamikuronue said:

    It's basically a Java-specific PATH, in a separate variable because Java.

    Really? Windows is fine if you have files in the path?

    Or have you overlooked that classpath can contain paths to jar files?


  • I survived the hour long Uno hand

    Same concept, different execution. Let's not detail Blakey's thread, at least not in Coding Help.


  • FoxDev

    Actually, scratch all of that, it's not actually relevant 😊



  • I think I see the problem, the FOP getting started page says:

    Apache™ FOP. The FOP distribution includes all libraries that you will need to run a basic FOP installation. These can be found in the [fop-root]/lib directory. These libraries include the following:

    This seems to be a blatant lie, as the .zip file I downloaded from their mirror does not include a /lib directory at all. So I guess I need to just go manually download all of those .dlls or whatever they are?



  • @blakeyrat said:

    I can add it manually I guess.

    That's the idea -- if nothing else, use the set command at the command prompt for that instead of setting it for every Java program

    @Eldelshell said:

    You don't need to set an environment variable for this (unless you want to break all your Java applications that is).

    I'm asking him to manually inject it into his current command prompt for testing's sake :)

    @blakeyrat said:

    I can set CLASSPATH but what do I set it to?

    It should be set to the lib directory (probably by fop.bat or whatever you're actually running at the command prompt) -- but:

    @blakeyrat said:

    This seems to be a blatant lie, as the .zip file I downloaded from their mirror does not include a /lib directory at all. So I guess I need to just go manually download all of those .dlls or whatever they are?

    JARs, yes. Broken package is broken.



  • Judging from the error, the lib its complaining about missing is xmlgraphics-commons-2.0.jar, which is in the xmlgraphics-commons-2.0/build directory of this zip.



  • For Christ's sake. I have no idea what went wrong, but it turns out the libraries are in the .zip downloaded from FOP's site, and they are in the unzipped folder that Windows Explorer made when unzipping, but somehow they didn't get copied into Program Files when I copied the rest of the program.

    Hm. Overzealous anti-virus perhaps? Either way I think I have it solved.


  • ♿ (Parody)

    @blakeyrat said:

    This seems to be a blatant lie, as the .zip file I downloaded from their mirror does not include a /lib directory at all. So I guess I need to just go manually download all of those .dlls or whatever they are?

    Their download stuff is...weird. Going to the archive page, I found:

    That definitely has a lib dir.



  • @blakeyrat said:

    Overzealous anti-virus perhaps?

    And this is why letting third parties screw with filesystem APIs in a near-arbitrary manner is a bad idea...

    Glad this was solved quickly, though.



  • @boomzilla said:

    That definitely has a lib dir.

    I bet some of the mirrors have it and some do not, and since you get a random one each time it's like a landmine.

    Because I dug that first .zip out of my recycling and it has no lib folder in it.


  • FoxDev

    @boomzilla said:

    Their download stuff is...weird.

    It's pretty standard fair in Open Source Land; a lot of projects simply refuse to accept Windows exists.

    Though that's probably thanks in no small part to Richard 'Proprietry-Code-Is-Evil-So-I-Will-FORCE-Everyone-To-Share-Through-A-Complex-And-Restrictive-License-Named-After-An-Antelope' Stallman.


  • FoxDev

    @blakeyrat said:

    I bet some of the mirrors have it and some do not

    Rather defeating the point of being a 'mirror' 😆



  • Well here's the possibilities:

    1. That mirror has a different copy of the .zip than everybody else, which lacks a lib directory
    2. That mirror has a .zip with some kind of flaw that prevents the lib directory from unzipping
    3. The anti-virus here at work is doing very very weird shit
    4. I'm going insane. Because I swear to fucking CHRIST I hit control-A to select all files before copying into Program Files, and at that time there was no lib somehow.

  • FoxDev

    @blakeyrat said:

    4) I'm going insane

    …must…resist…


  • ♿ (Parody)

    @RaceProUK said:

    It's pretty standard fair in Open Source Land; a lot of projects simply refuse to accept Windows exists.

    What's really the problem here is that it's java, and most people will get everything via maven and never bother with a direct download. So setting up nice manual download stuff isn't worth a lot of effort.



  • Ok for my own sanity's sake I unzipped both downloads again and both have the libs folder and I am now officially insane.

    I guess I must have somehow flubbed and deselected it between hitting control-A and hitting control-C? I have no idea how that could be possible.



  • @boomzilla said:

    What's really the problem here is that it's java, and most people will get everything via maven and never bother with a direct download. So setting up nice manual download stuff isn't worth a lot of effort.

    My understanding is that Maven is more like Nuget in C# world, for dependencies on programs. FOP is an actual stand-alone application; there's no reason they should expect anybody to get it from Maven instead of their website.


  • ♿ (Parody)

    Oh, I see. Yeah...who knows.



  • BTW we're using this "FOP script" or whatever the hell you call it to convert a XML schema into C# classes. Honestly, at this point, I don't think the time "savings" are worth the annoyance-- it's like 15 fields max, I could have done it manually long before now.

    EDIT: Oh hey it successfully ran. Yay. I get a cookie.



  • 🍪


  • Discourse touched me in a no-no place

    @aliceif said:

    🍪

    <click><click><click>

    Damnit!




  • Garbage Person

    Linky? I have a Schema the size of a medium continent that needs to be classified. (bonus if it hooks up serialization to/from the xml)


  • Discourse touched me in a no-no place

    @Weng said:

    I have a Schema the size of a medium continent that needs to be classified.

    I'd classify that as “too bloody big”. HTH.



  • FOP just runs the translation of XML into "something else". All its own examples are PDF translation.

    The C# .fo script is in our repo, so I can't share it out. No clue if its in-house or open source.


  • Garbage Person

    Aww, damn.



  • Sorry I just checked, the .xslt that FOP uses was written specifically for this company. I can't share it at all.

    You might try Googling-up one, though.


  • Garbage Person

    Figures.

    And yes, there's a reason I don't just use xsd.exe - I just can't recall what it is at the moment. I've looked at it in the past. I think it vomits on some particularly derpgasmic design decisions the jackfucks that developed this schema decided were good.

    It's probably that they've got sub-elements and attributes that overlap.

    i.e.

    <thing property="foo"/>
    and <thing><property>foo</property></thing> are equivalent.
    <thing property="foo"><property>foo</property></thing> results in undefined behavior but is still schema-valid.

    I guess I could just go through and rip out all the idiot duplication and run that through, but that resembles work too much.


  • Fake News

    I do wonder what madman chose to go with XSL:FO instead of sticking to XSLT... I could see the use of FO elements if you really want documentation, but even then you could make a second XSLT file to spit out HTML...


  • FoxDev

    XSL-FO has its uses. Having said that, the only time I've ever used it was auto-generating legally-binding documents. Which of course have to be PERFECT, otherwise lawyers get involved, and it all goes down the shitter faster than… well, shit.


Log in to reply