e.g : richard@birkenhead /cygdrive/c/Documents and Settings/richard/IdeaProjects/Apach e FOP $ ./fop -awt examples/fo/basic/readme.fo produces the following: cygpath: error converting "FOP/lib/*.jar:Settings/richard/IdeaProjects/Apache:an d:/cygdrive/c/Documents:/cygdrive/c/Documents and Settings/richard/IdeaProjects/ Apache FOP/build/fop.jar:/cygdrive/c/Documents and Settings/richard/IdeaProjects /Apache FOP/build/fop-sandbox.jar:/cygdrive/c/Documents and Settings/richard/Ide aProjects/Apache FOP/build/fop-hyph.jar:/cygdrive/f/geolog/trunk/geolog/src" - U nknown error 4294967295 Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/fop/cli/Ma in This affects the current trunk. Related bugs are: 40583 Under Cygwin, fop bash script CLASSPATH problem http://issues.apache.org/bugzilla/show_bug.cgi?id=40583 21070 ClassPath with spaces cause undefined class errors http://issues.apache.org/bugzilla/show_bug.cgi?id=21070
The problem may be due to this part: DIRLIBS=${FOP_HOME}/lib/*.jar for i in ${DIRLIBS} I have no idea how to solve it, even on Linux. ${FOP_HOME}/lib/*.jar simply is not expanded when it contains one or more spaces, even when quoted or when the spaces are escaped. The for loop is even worse. Even if DIRLIBS would be properly set, it seems impossible to obtain a correct word splitting in the for loop when each separate path element contains spaces. Bug 40583 is not really related. It addresses another problem, one which is specific for Cygwin.
To avoid splitting arguments on spaces, set IFS to newline at the beginning of the script like so: export IFS=$'\n' Please try this and report your findings.
Spaces are not the whole of the problem: The following works: richard@birkenhead /cygdrive/f/dir with spaces/fop-head/xml-fop $ ./fop -awt ./examples/fo/basic/simple.fo > foo 2>&1 The following doesn't: richard@birkenhead /cygdrive/f/dir with spaces/fop-head/xml-fop $ cd ../ richard@birkenhead /cygdrive/f/dir with spaces/fop-head $ mv xml-fop xml\ fop richard@birkenhead /cygdrive/f/dir with spaces/fop-head $ cd xml\ fop/ richard@birkenhead /cygdrive/f/dir with spaces/fop-head/xml fop $ !./f ./fop -awt ./examples/fo/basic/simple.fo > foo 2>&1 richard@birkenhead /cygdrive/f/dir with spaces/fop-head/xml fop $ cat ./foo cygpath: error converting "fop/lib/*.jar:spaces/fop-head/xml:with:/cygdrive/f/di r:/cygdrive/f/dir with spaces/fop-head/xml fop/build/fop.jar:/cygdrive/f/dir wit h spaces/fop-head/xml fop/build/fop-sandbox.jar:/cygdrive/f/dir with spaces/fop- head/xml fop/build/fop-hyph.jar:/cygdrive/f/geolog/trunk/geolog/src" - Unknown e rror 4294967295 java.lang.NoClassDefFoundError: org/apache/fop/cli/Main Exception in thread "main" richard@birkenhead /cygdrive/f/dir with spaces/fop-head/xml fop $
export IFS=$'\n' Adding this just after the opening comments fixes the problem under Linux and Cygwin.
Applied the fix in the form: export IFS=" " because I feared that $'\n' is specific for bash. Thanks for the suggestion and the testing. See revision 551972.
http://svn.apache.org/viewvc?view=rev&revision=551972 breaks the 0.94 fop script on Solaris where /bin/sh is a plain-vanilla Bourne shell. The assigment should be written as: IFS=" " export IFS
Fixed in revision 587204. I removed the export statement because it is not needed.
*** Bug 43704 has been marked as a duplicate of this bug. ***
The IFS assignment has to be removed altogether. In Bourne shell it means that fop -xml foo.xml -xsl foo.xsl -pdf foo.pdf is interpreted as fop "-xml foo.xml -xsl foo.xsl -pdf foo.pdf" which produces for basically all commandlines: java.lang.IllegalArgumentException: Error creating InputHandler object. at org.apache.fop.cli.CommandLineOptions.createInputHandler (CommandLineOptions.java:818) at org.apache.fop.cli.CommandLineOptions.parse (CommandLineOptions.java:165) at org.apache.fop.cli.Main.startFOP(Main.java:154) at org.apache.fop.cli.Main.main(Main.java:197) Workaround (provided bash is installed): invoke fop script explicitly as bash script instead of implicit #!/bin/sh $ bash fop -xml foo.xml -xsl foo.xsl -pdf foo.pdf
(In reply to comment #9) > The IFS assignment has to be removed altogether. In Bourne shell it means that > > fop -xml foo.xml -xsl foo.xsl -pdf foo.pdf > > is interpreted as > > fop "-xml foo.xml -xsl foo.xsl -pdf foo.pdf" Can you explain? I do not see such a thing happen: $ /fop/fop --execdebug -xml foo.xml -xsl foo.xsl -pdf foo.pdf exec "/usr/lib/jvm/java-1.5.0-sun/bin/java" -classpath "/fop/lib/xmlgraphics-commons-1.3svn.jar:/fop/lib/xml-apis-1.3.02.jar:/fop/lib/xercesImpl-2.7.1.jar:/fop/lib/xalan-2.7.0.jar:/fop/lib/servlet-2.2.jar:/fop/lib/serializer-2.7.0.jar:/fop/lib/fop-hyph.jar:/fop/lib/commons-logging-1.0.4.jar:/fop/lib/commons-io-1.3.1.jar:/fop/lib/batik-all-1.6.jar:/fop/lib/avalon-framework-4.2.0.jar:/fop/build/fop.jar:/fop/build/fop-sandbox.jar:/fop/build/fop-hyph.jar" org.apache.fop.cli.Main "-xml" "foo.xml" "-xsl" "foo.xsl" "-pdf" "foo.pdf"
Try OLD_IFS=$IFS IFS=" " find ${FOP}/lib -name -name '*.jar'|while read jarfile do if [ -z "$LOCALCLASSPATH" ] ; then LOCALCLASSPATH="$jarfile" else LOCALCLASSPATH="$jarfile"${pathSepChar}$LOCALCLASSPATH fi done IFS=$OLD_IFS I don't know how the CLASSPATH reacts to spaces. If there's a problem, the assignments to LOCALCALSSPATH will have to have the spaces escaped.
(In reply to comment #11) > Try > > OLD_IFS=$IFS > IFS=" > " > find ${FOP}/lib -name -name '*.jar'|while read jarfile > do > if [ -z "$LOCALCLASSPATH" ] ; then > LOCALCLASSPATH="$jarfile" > else > LOCALCLASSPATH="$jarfile"${pathSepChar}$LOCALCLASSPATH > fi > done > IFS=$OLD_IFS > find "${FOP}/lib" -name '*.jar'|while read jarfile do if [ -z "$LOCALCLASSPATH" ] ; then LOCALCLASSPATH=$jarfile else LOCALCLASSPATH=$jarfile${pathSepChar}$LOCALCLASSPATH fi done would be almost perfect, and avoid the need for the change of IFS, except that the call to find places the whole while loop in a subshell, and updates of LOCALCLASSPATH are lost when it returns.
I forgot that everything in the line would be assigned to the variable, and I forgot that the pipeline would be executed in a subshell. So how about JARPATH=$(SEP="";find ${FOP}/lib -name '*.jar'|\ while read jarfile;do echo -n $SEP"$jarfile"; SEP=${pathSepChar}; done) if [ -z "$LOCALCLASSPATH" ] ; then LOCALCLASSPATH="$JARPATH" else LOCALCLASSPATH="$JARPATH"${pathSepChar}$LOCALCLASSPATH fi
(In reply to comment #13) > So how about > > JARPATH=$(SEP="";find ${FOP}/lib -name '*.jar'|\ > while read jarfile;do echo -n $SEP"$jarfile"; SEP=${pathSepChar}; done) > > if [ -z "$LOCALCLASSPATH" ] ; then > LOCALCLASSPATH="$JARPATH" > else > LOCALCLASSPATH="$JARPATH"${pathSepChar}$LOCALCLASSPATH > fi > Excellent. But keep it simple and use =`...` instead of =$(...) (is this a bashism?). Then the following should replace the libs section in the fop script: # add in the dependency .jar files, which reside in $FOP_HOME/lib if [ -z "$LOCALCLASSPATH" ] ; then SEP="" else SEP="${pathSepChar}" fi LOCALCLASSPATH=${LOCALCLASSPATH}`find "${FOP_HOME}/lib" -name '*.jar' \ | while read jarfile do echo -n "$SEP$jarfile" SEP="${pathSepChar}" done` Note, however, that the complaint with which this bug was reopened, has never been validated; see comments #9 and #10. So one may argue that this solution is not sufficiently better to warrant being committed. I think it is, because it removes the fiddling with IFS and the parsing of a list of libs.
$(...) is posix-preferred, I believe.
if this problem still exists in current trunk (FOP1.0 or later), then submit a new bug
batch transition resolved+wontfix to closed+wontfix
batch transition resolved+wontfix to closed+wontfix; if you believe this remains a bug and can demonstrate it with appropriate input FO file and output PDF file (as applicable), then you may reopen