jscience java,使用JScience解析mathml文档

博主尝试用JScience解析MathML文档未成功,给出代码并展示报错信息,如java.lang.NoClassDefFoundError等。还询问如何使用JSci.mathml包中的类及解析MathML文档的代码示例。解决方案提到检查JScience jar中相关类是否存在及是否使用多个类加载器。

I was trying to parse mathml document using JScience but was not succeed. Following is my piece of code.

import JSci.io.*;

import JSci.mathml.*;

.

.

public class ParsingMathML(){

try {

....

//inputFile is an xml file containing mathml code

InputSource file = new InputSource(new FileReader(inputFile));

MathMLParser parser = new MathMLParser();

parser.parse(file);

Object[] parseList = parser.translateToJSciObjects();

}catch (Exception e) {

e.printStackTrace();

}

}

I got error from here, so I could not do anything further. Following is the StackTrace:

Exception in thread "AWT-EventQueue-0" java.lang.NoClassDefFoundError: JSci/maths/fields/Ring$Member

at JSci.io.MathMLParser.translateToJSciObjects(Unknown Source)

at JSci.io.MathMLParser.translateToJSciObjects(Unknown Source)

at mathML.ProcessMathML.processFile(ParsingMathML.java:109)

at mathML.ProcessMathML.actionPerformed(ParsingMathML.java:72)

at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)

at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)

at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)

at javax.swing.DefaultButtonModel.setPressed(Unknown Source)

at javax.swing.AbstractButton.doClick(Unknown Source)

at javax.swing.plaf.basic.BasicMenuItemUI.doClick(Unknown Source)

at javax.swing.plaf.basic.BasicMenuItemUI$Handler.mouseReleased(Unknown Source)

at java.awt.Component.processMouseEvent(Unknown Source)

at javax.swing.JComponent.processMouseEvent(Unknown Source)

at java.awt.Component.processEvent(Unknown Source)

at java.awt.Container.processEvent(Unknown Source)

at java.awt.Component.dispatchEventImpl(Unknown Source)

at java.awt.Container.dispatchEventImpl(Unknown Source)

at java.awt.Component.dispatchEvent(Unknown Source)

at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)

at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)

at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)

at java.awt.Container.dispatchEventImpl(Unknown Source)

at java.awt.Window.dispatchEventImpl(Unknown Source)

at java.awt.Component.dispatchEvent(Unknown Source)

at java.awt.EventQueue.dispatchEvent(Unknown Source)

at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)

at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)

at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)

at java.awt.EventDispatchThread.pumpEvents(Unknown Source)

at java.awt.EventDispatchThread.pumpEvents(Unknown Source)

at java.awt.EventDispatchThread.run(Unknown Source)

Caused by: java.lang.ClassNotFoundException: JSci.maths.fields.Ring$Member

at java.net.URLClassLoader$1.run(Unknown Source)

at java.security.AccessController.doPrivileged(Native Method)

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)

at java.lang.ClassLoader.loadClassInternal(Unknown Source)

... 31 more

Also, does any one have any idea how to use MathMLApplyElementImpl, MathMLDocumentImpl or any other classes from JSci.mathml package?

It will be great if you can provide some example of code on how to parse mathml document.

Any idea will be highly appreciated.

Thanks

解决方案

Cocnerning your precise bug, it seems the class JSci.maths.fields.Ring$Member does not exists, which throws a ClassNotFoundException in the method JSci.io.MathMLParser.translateToJSciObjects.

Lets go see this source code.

In MathMLParser, the most notable usage of Ring.Member is as a return value. But it can be found at numerous locations.

And, since Ring.Member is in JSci.maths.fields, which seems to be in the same JAR than MathMLParser, I guess your problem is far more complicated than a simple ClassNotFoundException.

First, can you open the JScience jar to ensure that JSci.maths.fields.Ring$Member does exists ?

If not the case, do you use multiple class loaders in the same application ? (things like OSGi)

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值