0

I am trying to convert MPP file to MS XML format using MPXJ library and Jpype

def convert(inputFile, outputFile):
   reader = ProjectReaderUtility.getProjectReader(inputFile)
   project = ProjectFile()
   project = reader.read(inputFile)
   writer = ProjectWriter
   writer = ProjectWriterUtility.getProjectWriter(outputFile)
   writer.write(project, outputFile)

This works fine if I try to convert to json format. However, there is always an error related to xml file. I get an error related to java xml library

java.io.IOException: java.io.IOException: javax.xml.bind.JAXBException: 
Implementation of JAXB-API has not been found on module path or classpath.
 with linked exception:
[java.lang.ClassNotFoundException: com.sun.xml.internal.bind.v2.ContextFactory]

Would anyone be able to assist in this issue. I am using Python 3.8 with jdk-15.0.2

  • What version of MPXJ are you working with? – Jon Iles Mar 03 '21 at 18:11
  • ... and as a followup to that, how do you configure JPype to pick up the MPXJ jar and its dependencies? – Jon Iles Mar 03 '21 at 18:17
  • I am using MXPJ version 9.0.0 For the configuration I have loaded the jar files import jpype import jpype.imports from jpype.types import * from collections import defaultdict import sys jpype.startJVM(jpype.getDefaultJVMPath(), "-ea") jpype.addClassPath("mpxj-9.0.0.jar") jpype.addClassPath("poi-5.0.0.jar") jpype.addClassPath("commons-math3-3.6.1.jar") jpype.addClassPath("commons-collections4-4.4.jar") jpype.addClassPath("jcl-over-slf4j-1.7.30.jar") jpype.addClassPath("slf4j-api-1.7.30.jar") jpype.addClassPath("SparseBitSet-1.2.jar") jpype.addClassPath("commons-codec-1.15.jar") – Hassan Emam Mar 03 '21 at 18:49
  • jpype.addClassPath("rtfparserkit-1.16.0.jar") jpype.addClassPath("jaxb-api-2.3.1.jar") – Hassan Emam Mar 03 '21 at 18:49
  • Java(TM) SE Runtime Environment (build 1.8.0_281-b09) Java HotSpot(TM) 64-Bit Server VM (build 25.281-b09, mixed mode) – Hassan Emam Mar 03 '21 at 22:17

1 Answers1

0

Well it was a wrong dependency as inspired by Jon Illes response. I was using jaxb-api which isn't the correct dependency. After checking the list of dependency, I learnt that the correct package required is jaxb-runtime. After downloading it the script works.

Thanks Jon for the prompt response and directing to the solution

  • Hi Hassan, I was inspired by your question to create a package for this, hopefully it'll make MPXJ easier to consume from Python. https://pypi.org/project/mpxj/ – Jon Iles Mar 07 '21 at 16:53
  • Hi Jon, That is brilliant and I would love to contribute (if there is a need for further development) to it as I have started an open source package myself to parse XER files only. It is still in very early stages but it does help. https://github.com/HassanEmam/PyP6Xer – Hassan Emam Mar 11 '21 at 18:58