com.sun.xml.internal.bind.v2.runtime.IllegalAnnotationsException:IllegalAnnotationExceptions的3个计数

时间:2013-12-09 22:33:33

标签: java jaxb

当我将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>

在上述标签分解器中,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;
}

1 个答案:

答案 0 :(得分:0)

您遇到的异常听起来像是导致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的实例,或者您当时是否获得例外?