0

I am working on a docx-pdf convert task, which should be called from an Ant script. As the basis I use the docx4j libraries. In one of its classes is a getResource call, which tries to access the org/docx4j/convert/out/pdf/viaXSLFO/docx2fo.xslt file, which is stored inside the docx4j JAR.

I wrote the main class and when I start it from the IDE it works fine. Build is also done with Ant and is without error.

The problem is, that when I start to test, it can't access the file mentioned above (the docx2fo.xslt). My taskdef is as it follows:

<taskdef name="docxToPdf" classname="com.tools.docxtopdf.DocxToPdf">
    <classpath>
        <fileset file="./docxToPdf.jar" />
        <fileset dir="../lib">
            <include name="*.jar"/>
        </fileset>
    </classpath>
</taskdef>

The project structure is

root
|- bin
|- lib
|--- library jars (a lot of them)
|- src
|- test
|--- build.xml
|--- docxToPdf.jar
|--- test.docx
|- build.xml

And the error is:

ERROR org.docx4j.utils.ResourceUtils .getResource line 40 - Couldn't get resource: org/docx4j/convert/out/pdf/viaXSLFO/docx2fo.xslt

I tried to move the given file into the docxToPdf.jar, also into the test folder. Several classpath and taskdef definition, but nothing seems to work.

Java 1.7, eclipse, Ant 1.8.4

I would appreciate any help. Thanks!

Mensfeld
  • 101
  • 1
  • 7
  • run ant with -debug option. It will probably indicate a classpath problem. (look for dropping from classpath message) – Jayan Sep 19 '13 at 16:14
  • I can see in the output that classes are being loaded from the same JAR file and package, so it should be found. It seems like if the class loader had no access to the files other than the class files. – Mensfeld Sep 20 '13 at 07:27
  • I found this bug: https://netbeans.org/bugzilla/show_bug.cgi?id=157004 so it seems, it won't work. – Mensfeld Sep 20 '13 at 08:01

0 Answers0