Actually, a better fix just involves setting the CLASSPATH variable in
bash. So:

1. First put the following in the script, almost at the end of the file,
just before the line that starts with "fop_exec_command":

   echo $LOCALCLASSPATH
   exit 0

 If you don't write access to the script, copy it to a place you do, and
then use this script.

2. Run the script with

fop > path.txt

3. Open up path.txt, and fix the start of the line. Change

C:/ava

to

C:/cygwin/java

Your fix may be different. Look for the pattern that is truncated, and fix
that.

4. Open up .bashrc and put the following in

export CLASSPATH=<fixed text from path.txt>

Of course, paste in your fixed text for the <fixed text from path.txt>

Get rid of the echo and exit commands in the fop script.

>From the shell, type bash to invoke the new variable. (You'll only have to
do this once; every time you open up a cygwin bash shell from then on, the
variable will be there.) Now you can run fop in the usual way.

Note that it is my understanding that setting a universal classpath like
this can cause problems if you run other java applications, since it will
overwrite those classpaths. If you suddenly find that your other java
applications don't run correctly, then instead of putting the classpath in
.basrc, change the fop script itself. In the same place as the exit 0
statement was, put

LOCALCLASSPATH=<fixed text from path.txt>

I hope that helps anyone else stumbling across this problem.

In the mean time, I'll try to see if I can't get the bug fixed with the
cygpath command.

Paul

>

On Fri, Mar 16, 2012 at 8:52 AM, Paul Tremblay <[email protected]>wrote:

> I figured it out. The start of the classpath (LOCALCLASSPATH) is:
>
> C:/ava/fop-20111107/lib...
>
> It should be
>
> C:/cygwin/java/fop-20111107/lib...
>
> Changing the text at the start of the path fixes the error. In my case, I
> inserted these lines in the script:
>
> echo $LOCALCLASSPATH
> exit 0
>
> then ran:
>
> fop > path.txt
>
> I fixed the text in path.txt, then copied the text to the fop script, and
> assigned it to LOCALCLASSPATH. Of course, I got rid of the two lines (echo
> and exit), and the script runs again.
>
> Paul
>
>
> On Thu, Mar 15, 2012 at 7:02 PM, Paul Tremblay <[email protected]>wrote:
>
>> I had an unexpected problem running fop at work today. I run fop under
>> windows using cygwin and have used it for months with no problem. I
>> installed something else on cygwin, and when I ran FOP today (using the
>> bash script), I got a no classfound error.
>>
>> Exception in thread "main" java.lang.**NoClassDefFoundError:
>> org/apache/xmlgraphics/image/**loader/ImageContext
>>    at java.lang.ClassLoader.**defineClass1(Native Method)
>>    at java.lang.ClassLoader.**defineClassCond(Unknown Source)
>>   [etc.]
>>
>> I am using version:
>>
>> FOP Version svn-trunk
>>
>> I opened the FOP script and it seems that the problem lies here:
>>
>>  FOP_HOME=`cygpath --$format "$FOP_HOME"`
>>  LCP_TEMP=`cygpath --path --unix "$LOCALCLASSPATH"`
>>  LOCALCLASSPATH=`cygpath --path --$format "$LCP_TEMP"`
>>  if [ -n "$CLASSPATH" ] ; then
>>    CP_TEMP=`cygpath --path --unix "$CLASSPATH"`
>>    CLASSPATH=`cygpath --path --$format "$CP_TEMP"`
>>  fi
>>  CYGHOME=`cygpath --$format "$HOME"`
>>
>> The cygpath is actually truncating the LOCALCLASSPATH name because it is
>> too long. If I insert
>>
>> echo $LOCALCLASSPATH
>>
>> I get something like this:
>>
>> C:/ava/fop-20111024/lib/**xmlgraphics-commons-1.5svn.jar
>>   ^^^
>>
>> Note how the C:/ava should be C:/java.
>>
>> I tested out the cypath command on its own, and sure enough, it truncates
>> the first letter if the path name is too long.
>>
>> However, even if I insert a sed command to change the LOCALCLASSPATH back
>> to
>>
>> C:java/[rest of path name]
>>
>> I still get the same error.
>>
>> I also tried pasting the full classpath name back into the script and
>> setting the LOCALCLASSPATH name to it, but this didn't work either.
>>
>> How should I set the classpath under cygwin? The cygwin path to the first
>> jar is:
>>
>> /cgywin/java/fop-20111024/lib/**xmlgraphics-commons-1.5svn.jar
>>
>> I need a quick fix for work, and I believe I can copy the file to
>> /cygwin/java/fop-20111024, and then run
>>
>> java -jar -fo file.fo -pdf file.pdf
>>
>> In fact, I did this already, and the file got converted with no error
>> messages. I just didn't have time to look at the resulting PDF.
>>
>> Thanks!
>>
>> Paul
>>
>>
>

Reply via email to