Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Null pointer exception for figures #2

Open
B5045438 opened this issue Jun 20, 2018 · 20 comments
Open

Null pointer exception for figures #2

B5045438 opened this issue Jun 20, 2018 · 20 comments

Comments

@B5045438
Copy link

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 B5045438 changed the title Null pointer exception for harvard references Null pointer exception for figures Jun 20, 2018
@B5045438
Copy link
Author

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

@Vitaliy-1
Copy link
Owner

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

@Vitaliy-1
Copy link
Owner

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
Copy link
Author

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
Copy link
Owner

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

@Vitaliy-1
Copy link
Owner

Ok, I will look at the file

@B5045438
Copy link
Author

B5045438 commented Jun 22, 2018

Any specific instructions on how to build it using ant?

@B5045438
Copy link
Author

@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
Copy link
Owner

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
Copy link
Owner

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
Copy link
Author

@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
Copy link
Owner

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

@Vitaliy-1
Copy link
Owner

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
Copy link
Author

B5045438 commented Jul 3, 2018

@Vitaliy-1
image

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

@Vitaliy-1
Copy link
Owner

Not sure. And what you are trying to do?

@Vitaliy-1
Copy link
Owner

Vitaliy-1 commented Jul 3, 2018

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
Copy link
Author

B5045438 commented Jul 4, 2018

@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
Copy link
Owner

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

@B5045438
Copy link
Author

B5045438 commented Jul 4, 2018

@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
Copy link
Owner

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants