【问题标题】:com.sun.xml.internal.bind.v2.runtime.IllegalAnnotationsException: 3 counts of IllegalAnnotationExceptionscom.sun.xml.internal.bind.v2.runtime.IllegalAnnotationsException:3 个 IllegalAnnotationExceptions 计数
【发布时间】:2013-12-11 00:38:34
【问题描述】:

当我将 Java 版本从 1.7 更改为 1.6 时出现以下错误

Error while loading configuration file: 
com.sun.xml.internal.bind.v2.runtime.IllegalAnnotationsException: 3 counts of IllegalAnnotationExceptions
weka.core.Instances does not have a no-arg default constructor.
this problem is related to the following location:
    at weka.core.Instances
    at public java.util.ArrayList lpcforsos.baseLearner.DecompositionBasedLearner.getDecomposedDatasets()
    at lpcforsos.baseLearner.DecompositionBasedLearner
    at public lpcforsos.baseLearner.DecompositionBasedLearner lpcforsos.configuration.Configuration.getLearnerEnvironment()
    at lpcforsos.configuration.Configuration
lpcforsos.dataStructure.ExtInstances does not have a no-arg default constructor.
this problem is related to the following location:
    at lpcforsos.dataStructure.ExtInstances
    at public lpcforsos.dataStructure.ExtInstances lpcforsos.baseLearner.DecompositionBasedLearner.getTrainingSet()
    at lpcforsos.baseLearner.DecompositionBasedLearner
    at public lpcforsos.baseLearner.DecompositionBasedLearner lpcforsos.configuration.Configuration.getLearnerEnvironment()
    at lpcforsos.configuration.Configuration
lpcforsos.evaluation.Result does not have a no-arg default constructor.
this problem is related to the following location:
    at lpcforsos.evaluation.Result
    at protected lpcforsos.evaluation.Result lpcforsos.structuredPrediction.StructuredPredictor.results
    at lpcforsos.structuredPrediction.StructuredPredictor
    at lpcforsos.structuredPrediction.PairwiseCoupling
    at public lpcforsos.structuredPrediction.PairwiseCoupling lpcforsos.configuration.Configuration.getPairwiseCoupling()
    at lpcforsos.configuration.Configuration

at com.sun.xml.internal.bind.v2.runtime.IllegalAnnotationsException$Builder.check(IllegalAnnotationsException.java:91)
at com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl.getTypeInfoSet(JAXBContextImpl.java:436)
at com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl.<init>(JAXBContextImpl.java:277)
at com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl$JAXBContextBuilder.build(JAXBContextImpl.java:1100)
at com.sun.xml.internal.bind.v2.ContextFactory.createContext(ContextFactory.java:143)
at com.sun.xml.internal.bind.v2.ContextFactory.createContext(ContextFactory.java:110)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:202)
at javax.xml.bind.ContextFinder.find(ContextFinder.java:376)
at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:574)
at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:522)
at lpcforsos.configuration.Configuration.loadConfig(Configuration.java:387)
at lpcforsos.evaluation.Evaluation.main(Evaluation.java:68)

我的XML如下

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<decomposer xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="topicRankingDecomposer">
</decomposer>   
<learnerEnvironment xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="wekaBaseLearner">
</learnerEnvironment>
<structuredPredictor xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="wuLingWeng2">
</structuredPredictor>
<essentials>
</essentials>
</configuration>

以上标签中decomposer、learnerEnvironment和structuredPredictor都是抽象类 他们每个人都有3个或更多的具体类。 解组 xml 时,将相应的具体类对象分配给抽象类变量。

我没有使用任何注释,当我使用 Java 1.7 时它工作得非常完美。现在,当我尝试使用 JDK 1.6 时,出现上述错误。

public class Configuration {

private Decomposer decomposer;
// Subtypes of Decomposer
private ReinforcementLearningDecomposer reinforcementLearningDecomposer;
private OneAgainstAllDecomposer oneAgainstAllDecomposer;
private TopicRankingDecomposer topicRankingDecomposer;
private PairwiseDecomposer pairwiseDecomposer;

private DecompositionBasedLearner learnerEnvironment;
// Subtypes of BaseLearner
private WekaBaseLearner wekaBaseLearner;
private SeCoBaseLearner seCoBaseLearner;
// Predictor Instance

private StructuredPredictor structuredPredictor;
// Subtypes of Predictor
private PairwiseCoupling pairwiseCoupling;
private WuLingWeng2 wuLingWeng2;
private Voting voting;
private WeightedVoting weightedVoting;

// Other essential fields
private Essentials essentials;
}

【问题讨论】:

    标签: java jaxb


    【解决方案1】:

    您遇到的异常听起来像是导致 JAXB 出现问题的实际问题。以下是其中之一,以下是否属实?

    lpcforsos.evaluation.Result does not have a no-arg default constructor.
    this problem is related to the following location:
        at lpcforsos.evaluation.Result
        at protected lpcforsos.evaluation.Result lpcforsos.structuredPrediction.StructuredPredictor.results
        at lpcforsos.structuredPrediction.StructuredPredictor
        at lpcforsos.structuredPrediction.PairwiseCoupling
        at public lpcforsos.structuredPrediction.PairwiseCoupling lpcforsos.configuration.Configuration.getPairwiseCoupling()
        at lpcforsos.configuration.Configuration
    

    您在 JDK 1.7 中使用的 JAXB impl 可能会延迟处理元数据,而 JDK 1.6 impl 不会。您是否能够在 JDK 1.7 中解组 lpcforsos.evaluation.Result 的实例,或者您当时是否遇到异常?

    【讨论】:

    • 实际上我使用的类是框架的一部分,除了编组/解组之外,它确实实现了逻辑。并且上述所有三个字段都不是从 xml 中检索到的(是受保护的成员,并且有 getter 和 setter)。并且结果字段根本没有从 xml 中解组(因为我不想这样做)。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-06-13
    • 1970-01-01
    • 2020-01-20
    • 1970-01-01
    相关资源
    最近更新 更多