1

大家好,下午好,

我对 Xstream jar 有疑问。我正在编写独立的后台进程,它将 XML 转换为对象。它使用 jdk1.6.0_35 在我的 Eclipse 中工作我创建了 jar 文件并使用 jdk1.6.27 部署在服务器中它不起作用。

错误是

java.lang.NoClassDefFoundError: Could not initialize class net.sf.cglib.proxy.Enhancer
    at com.thoughtworks.xstream.converters.reflection.CGLIBEnhancedConverter.canConvert(CGLIBEnhancedConverter.java:67)
    at com.thoughtworks.xstream.core.DefaultConverterLookup.lookupConverterForType(DefaultConverterLookup.java:60)
    at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:65)
    at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:59)
    at com.thoughtworks.xstream.core.TreeUnmarshaller.start(TreeUnmarshaller.java:142)
    at com.thoughtworks.xstream.core.AbstractTreeMarshallingStrategy.unmarshal(AbstractTreeMarshallingStrategy.java:33)
    at com.thoughtworks.xstream.XStream.unmarshal(XStream.java:931)
    at com.thoughtworks.xstream.XStream.unmarshal(XStream.java:917)
    at com.thoughtworks.xstream.XStream.fromXML(XStream.java:861)
    at com.thoughtworks.xstream.XStream.fromXML(XStream.java:853)

我的上课路径

<classpathentry kind="var" path="M2_REPO/commons-collections/commons-collections/3.2/commons-collections-3.2.jar"/>
    <classpathentry kind="var" path="M2_REPO/log4j/log4j/1.2.9/log4j-1.2.9.jar"/>
    <classpathentry kind="var" path="M2_REPO/hibernate-entitymanager/ejb3-persistence/3.0/ejb3-persistence-3.0.jar"/>
    <classpathentry kind="var" path="M2_REPO/org/hibernate/hibernate-annotations/3.3.0.ga/hibernate-annotations-3.3.0.ga.jar"/>
    <classpathentry kind="var" path="M2_REPO/org/hibernate/hibernate-commons-annotations/3.3.0.ga/hibernate-commons-annotations-3.3.0.ga.jar"/>
    <classpathentry kind="var" path="M2_REPO/org/hibernate/hibernate-core/3.3.2.GA/hibernate-core-3.3.2.GA.jar"/>
    <classpathentry kind="var" path="M2_REPO/commons-net/commons-net/3.3/commons-net-3.3.jar"/>
    <classpathentry kind="var" path="M2_REPO/commons-jxpath/commons-jxpath/1.3/commons-jxpath-1.3.jar"/>
    <classpathentry kind="var" path="M2_REPO/commons-lang/commons-lang/2.3/commons-lang-2.3.jar"/>
    <classpathentry kind="var" path="M2_REPO/javax/mail/mail/1.4/mail-1.4.jar"/>
    <classpathentry kind="var" path="M2_REPO/com/snowbound/Snow/1.0/Snow-1.0.jar"/>
    <classpathentry kind="var" path="M2_REPO/com/snowbound/snowbndcommon/1.0/snowbndcommon-1.0.jar"/>
    <classpathentry kind="var" path="M2_REPO/junit/junit/3.8.1/junit-3.8.1.jar"/>
    <classpathentry kind="var" path="M2_REPO/dom4j/dom4j/1.6.1/dom4j-1.6.1.jar"/>
    <classpathentry kind="var" path="M2_REPO/org/slf4j/slf4j-simple/1.5.8/slf4j-simple-1.5.8.jar"/>
    <classpathentry kind="var" path="M2_REPO/org/slf4j/slf4j-api/1.5.8/slf4j-api-1.5.8.jar"/>
    <classpathentry kind="var" path="M2_REPO/javax/transaction/jta/1.1/jta-1.1.jar"/>
    <classpathentry kind="var" path="M2_REPO/javassist/javassist/3.6.0.GA/javassist-3.6.0.GA.jar"/>
    <classpathentry kind="var" path="M2_REPO/jaxen/jaxen/1.1.1/jaxen-1.1.1.jar"/>
    <classpathentry kind="var" path="M2_REPO/com/ibm/as400/jt400/5.4.0.2/jt400-5.4.0.2.jar"/>
    <classpathentry kind="var" path="M2_REPO/javax/activation/activation/1.1/activation-1.1.jar"/>
    <classpathentry kind="var" path="M2_REPO/org/apache/poi/poi/3.8-beta3/poi-3.8-beta3.jar"/>
    <classpathentry kind="var" path="M2_REPO/org/apache/poi/poi-ooxml/3.8-beta3/poi-ooxml-3.8-beta3.jar"/>
    <classpathentry kind="var" path="M2_REPO/org/apache/commons/commons-compress/1.0/commons-compress-1.0.jar"/>
    <classpathentry kind="var" path="M2_REPO/org/apache/poi/poi-scratchpad/3.8-beta3/poi-scratchpad-3.8-beta3.jar"/>
    <classpathentry kind="var" path="M2_REPO/org/apache/poi/poi-ooxml-schemas/3.8-beta3/poi-ooxml-schemas-3.8-beta3.jar"/>
    <classpathentry kind="var" path="M2_REPO/xml-apis/xml-apis/1.0.b2/xml-apis-1.0.b2.jar"/>
    <classpathentry kind="var" path="M2_REPO/asm/asm/3.1/asm-3.1.jar"/>
    <classpathentry kind="var" path="M2_REPO/com/drewnoakes/metadata-extractor/2.4.0-beta-1/metadata-extractor-2.4.0-beta-1.jar"/>
    <classpathentry kind="var" path="M2_REPO/org/apache/xmlbeans/xmlbeans/2.4.0/xmlbeans-2.4.0.jar"/>
    <classpathentry kind="var" path="M2_REPO/org/ccil/cowan/tagsoup/tagsoup/1.2/tagsoup-1.2.jar"/>
    <classpathentry kind="var" path="M2_REPO/org/apache/tika/tika-parsers/0.9/tika-parsers-0.9.jar" sourcepath="/tika-parsers-0.9_SourceDocument"/>
    <classpathentry kind="var" path="M2_REPO/org/apache/tika/tika-core/0.9/tika-core-0.9.jar" sourcepath="/tika_0.9_sourceFolder"/>
    <classpathentry kind="var" path="M2_REPO/org/apache/pdfbox/fontbox/1.6.0/fontbox-1.6.0.jar"/>
    <classpathentry kind="var" path="M2_REPO/org/apache/pdfbox/jempbox/1.6.0/jempbox-1.6.0.jar"/>
    <classpathentry kind="var" path="M2_REPO/org/apache/pdfbox/pdfbox/1.6.0/pdfbox-1.6.0.jar" sourcepath="/pdfbox-1.6.0-sourcedoc"/>
    <classpathentry kind="var" path="M2_REPO/opensymphony/oscache/2.2/oscache-2.2.jar"/>
    <classpathentry kind="var" path="M2_REPO/commons-logging/commons-logging/1.1/commons-logging-1.1.jar"/>
    <classpathentry kind="var" path="M2_REPO/antlr/antlr/2.7.7/antlr-2.7.7.jar"/>
    <classpathentry kind="var" path="M2_REPO/org/hibernate/hibernate3/3.3.1/hibernate3-3.3.1.jar"/>
    <classpathentry kind="var" path="M2_REPO/com/nationwide/scs/efile/alerter/1.1/alerter-1.1.jar" sourcepath="/Alert_SRC"/>
    <classpathentry kind="var" path="M2_REPO/org/bouncycastle/bcprov-jdk16/1.45/bcprov-jdk16-1.45.jar"/>
    <classpathentry kind="var" path="M2_REPO/org/bouncycastle/bcmail-jdk16/1.45/bcmail-jdk16-1.45.jar"/>
    <classpathentry kind="var" path="M2_REPO/com/itextpdf/iText/5.0.2/iText-5.0.2.jar" sourcepath="/iText_5.0.2_Source_Folder"/>
    <classpathentry kind="var" path="M2_REPO/org/bouncycastle/bctsp-jdk16/1.45/bctsp-jdk16-1.45.jar"/>
    <classpathentry kind="var" path="M2_REPO/stax/stax/1.2.0/stax-1.2.0.jar"/>
    <classpathentry kind="var" path="M2_REPO/com/oracle/ojdbc6/11/ojdbc6-11.jar"/>
    <classpathentry kind="var" path="M2_REPO/com/jcraft/jsch/0.1.38/jsch-0.1.38.jar"/>
    <classpathentry kind="var" path="M2_REPO/org/apache/poi/poi-excelant/3.8-beta3/poi-excelant-3.8-beta3.jar"/>
    <classpathentry kind="var" path="M2_REPO/com/thoughtworks/xstream/xstream/1.3/xstream-1.3.jar"/>
    <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/jdk1.6.0_35"/>

可能是什么问题?提前致谢。

我已将我的 JDK 复制到服务器并尝试了相同的结果。

XStream xstream1 = new XStream(new StaxDriver()); 

//I tried both Stax and DOM Drivers same result 

XStream xstream1 = new XStream(new DomDriver()); //Same result. 

xstream1.alias("custom01", ConversionXstreamHelper.class);
//binding between xml elements and class and variables, 
................ 
ConversionXstreamHelper helper = (ConversionXstreamHelper)xstream1.fromXML(line);
4

1 回答 1

0

我能够解决这个问题。Xstream 与 CGLIB 有问题,我已将 CGLIB-NODEP jar 文件添加到我的 maven 构建并构建 Jar,它的工作

我正在使用 XStream 1.3 jar 和 cglib-nodep2.1_3.jar 文件。

谢谢,

CVSR 萨尔玛

于 2013-09-27T15:52:16.863 回答