Vitaliy-1 / DOCX2JATS

Java project, aimed to facilitate DOCX to JATS XML transformation for scientific articles
GNU General Public License v3.0
26 stars 8 forks source link

Null pointer exception for figures #2

Open B5045438 opened 6 years ago

B5045438 commented 6 years ago

The program stops conversion and throws a null pointer exception when using a Harvard references.

Full trace:

BUILD SUCCESSFUL Total time: 4 seconds

reference list has been found

Exception in thread "main" java.lang.NullPointerException at doc.transformation.xml.transformerFigures.transformerFiguresImpl(transformerFigures.java:75) at doc.transformation.xml.docIngestion.ingestionAndTransform(docIngestion.java:122) at doc.transformation.xml.docIngestion.main(docIngestion.java:52)

B5045438 commented 6 years ago

After testing with another file turns out that the issue is not related to the references.

Vitaliy-1 commented 6 years ago

This could be because of many reasons. Can you show a problematic DOCX file?

Vitaliy-1 commented 6 years ago

It is a part of the code that responsible for figure comments. Do you know Java? You can simply put this part of code into the try-cache block: https://github.com/Vitaliy-1/DOCX2JATS/blob/master/src/doc/transformation/xml/transformerFigures.java#L72-L78

If it helps, do the commit. Tell me if this is problematic for you.

Keep in mind that I'm not planning to continue this project as for next several months will be writing a new parser on PHP that can be integrated to OJS. This current parser relies on a side project (TEIC Stylesheets) and on that transformation stage much data are lost. As I see from now, it is better to write all from the scratch.

B5045438 commented 6 years ago

Here a link to the article that is causing the issue: article.docx

Good to see that a integrated solution is on its way, but I need a stopgap for now.

For the java bit, Looks like any easy modification I can for the figure comments, but couldn't manage to build a new jar file using javac as I got a build exception:

./docIngestion.java:34: error: package org.apache.tools.ant does not exist import org.apache.tools.ant.BuildException;

Which build settings did you use?

Vitaliy-1 commented 6 years ago

This is apache ant library. It should be include into the project.

Vitaliy-1 commented 6 years ago

Ok, I will look at the file

B5045438 commented 6 years ago

Any specific instructions on how to build it using ant?

B5045438 commented 6 years ago

@Vitaliy-1 So I have been trying to run an ant build but I couldn't find the build.xml file in the directory. Should I make one myself, if so what dependencies should I use?

Vitaliy-1 commented 6 years ago

Don't recommend to do anything in the build.xml managing those dependencies there was a headache for me, as I don't know ant build well :) Basically, if you using eclipse, it recommends you what libraries you are missing: ant-launcher.jar, ant.jar, and saxon9he.jar. Did you include all 3 in your classpath?

Vitaliy-1 commented 6 years ago

https://github.com/Vitaliy-1/DOCX2JATS/blob/master/stylesheets/docx/build-from.xml Ideally. this project should be converted to maven project and point all dependencies there...

B5045438 commented 6 years ago

@Vitaliy-1 I placed them in eclipse and did get the missing warnings for ant-launcher.jar, ant.jar, and saxon9he.jar. From where do I include them?

Vitaliy-1 commented 6 years ago

They are all available through maven. For example: https://mvnrepository.com/artifact/net.sf.saxon/saxon9he/9.4.0.4

Vitaliy-1 commented 6 years ago

The also can be download manually. if you are not familiar with maven. Saxon, for example, is available here: https://sourceforge.net/projects/saxon/files/

B5045438 commented 6 years ago

@Vitaliy-1 image

It is asking for a pattern and a pattern name, what should I put in here?

Vitaliy-1 commented 6 years ago

Not sure. And what you are trying to do?

Vitaliy-1 commented 6 years ago

The main method is inside docIngestion class. If you want to run it from IDE (to check the code before making a jar file) you can specify your input and output file paths here: https://github.com/Vitaliy-1/DOCX2JATS/blob/master/src/doc/transformation/xml/docIngestion.java#L46 and here: https://github.com/Vitaliy-1/DOCX2JATS/blob/master/src/doc/transformation/xml/docIngestion.java#L50

B5045438 commented 6 years ago

@Vitaliy-1 I'm trying to build the project to get the jar file to run the program not run it from the IDE.

Vitaliy-1 commented 6 years ago

I've only done this before in Eclipse: https://www.cs.utexas.edu/~scottm/cs307/handouts/Eclipse%20Help/jarInEclipse.htm

B5045438 commented 6 years ago

@Vitaliy-1 Managed to get the jar, but there seems to be an issue with class path/definitions as it throws this when I try to run it:

Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/tools/ant/BuildException

Error: A JNI error has occurred, please check your installation and try again Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/tools/ant/BuildException at java.lang.Class.getDeclaredMethods0(Native Method) at java.lang.Class.privateGetDeclaredMethods(Unknown Source) at java.lang.Class.privateGetMethodRecursive(Unknown Source) at java.lang.Class.getMethod0(Unknown Source) at java.lang.Class.getMethod(Unknown Source) at sun.launcher.LauncherHelper.validateMainClass(Unknown Source) at sun.launcher.LauncherHelper.checkAndLoadMain(Unknown Source) Caused by: java.lang.ClassNotFoundException: org.apache.tools.ant.BuildException at java.net.URLClassLoader.findClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) ... 7 more

Vitaliy-1 commented 6 years ago

Java can't find ant library here. OK, I will rebuild the project as a Maven to ease the work with dependencies at the end of next week.