做TA测试时候遇到的XmlAccessorType与AccessorType的问题和解决办法

在做TA的时候 遇到这样的一个exception:


java.lang.NoSuchMethodError: javax.xml.bind.annotation.XmlAccessorType.value()Ljavax/xml/bind/annotation/AccessType;
at com.sun.xml.bind.v2.model.impl.ClassInfoImpl.getAccessType(ClassInfoImpl.java:339)
at com.sun.xml.bind.v2.model.impl.ClassInfoImpl.getProperties(ClassInfoImpl.java:228)
at com.sun.xml.bind.v2.model.impl.RuntimeClassInfoImpl.getProperties(RuntimeClassInfoImpl.java:87)
at com.sun.xml.bind.v2.model.impl.ModelBuilder.getClassInfo(ModelBuilder.java:127)
at com.sun.xml.bind.v2.model.impl.RuntimeModelBuilder.getClassInfo(RuntimeModelBuilder.java:49)
at com.sun.xml.bind.v2.model.impl.RuntimeModelBuilder.getClassInfo(RuntimeModelBuilder.java:41)
at com.sun.xml.bind.v2.model.impl.ModelBuilder.getTypeInfo(ModelBuilder.java:189)
at com.sun.xml.bind.v2.model.impl.RegistryInfoImpl.<init>(RegistryInfoImpl.java:51)
at com.sun.xml.bind.v2.model.impl.ModelBuilder.addRegistry(ModelBuilder.java:232)
at com.sun.xml.bind.v2.model.impl.ModelBuilder.getTypeInfo(ModelBuilder.java:201)
at com.sun.xml.bind.v2.runtime.JAXBContextImpl.getTypeInfoSet(JAXBContextImpl.java:327)
at com.sun.xml.bind.v2.runtime.JAXBContextImpl.<init>(JAXBContextImpl.java:198)
at com.sun.xml.bind.v2.ContextFactory.createContext(ContextFactory.java:76)
at com.sun.xml.bind.v2.ContextFactory.createContext(ContextFactory.java:55)
at com.sun.xml.bind.v2.ContextFactory.createContext(ContextFactory.java:124)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at javax.xml.bind.ContextFinder.newInstance(Unknown Source)
at javax.xml.bind.ContextFinder.find(Unknown Source)
at javax.xml.bind.JAXBContext.newInstance(Unknown Source)
at javax.xml.bind.JAXBContext.newInstance(Unknown Source)
at javax.xml.bind.JAXBContext.newInstance(Unknown Source)
at com.ta.generic.tools.testDirector.TestDirectorClient.saveTestCaseResultsAs(TestDirectorClient.java:326)
at com.ta.specific.nbg.listeners.NbgSaveResultAsXml.afterAllTestCases(NbgSaveResultAsXml.java:70)
at com.ta.generic.testing.execution.MainExecutor.callListenersAfterProject(MainExecutor.java:489)
at com.ta.generic.testing.execution.MainExecutor.access$5(MainExecutor.java:478)
at com.ta.generic.testing.execution.MainExecutor$TestCaseExecutorThread.safeCall(MainExecutor.java:789)
at com.ta.generic.tools.utils.SafeCallable.call(SafeCallable.java:45)
at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)
at java.util.concurrent.FutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)


当时找了下原因,GOOGLE上面有http://blog.sina.com.cn/s/blog_5a71b7600100aikt.html 介绍了原因说的是1.5和1.6冲突的问题, 我检查了jaxb-impl.jar发现应该不是这个错误,然后检查了一段代码

JAXBContext ctx =
JAXBContext.newInstance(
"com.ta.generic.tools.testDirector.xmlModel");

Marshaller marshaler = ctx.createMarshaller();
FileWriter fileWriter = new FileWriter(p_filePath);

marshaler.marshal(resultSet, fileWriter);

发现有xml转化的过程, 就找到package:com.ta.generic.tools.testDirector.xmlModel下面的JAVA文件,里面有很多xsd文件解析出来的java文件, 基本都有类似的问题出现

protected String fileName;

public String getFILENAME()
{
return fileName;
}

public void setFILENAME(String value)
{
this.fileName = value;
}

用XJC解析XSD文件 得到的get,set方法有问题, 修改成下面的久可以了

protected String fileName;
public String getFileName()
{
return fileName;
}

public void setFileName(String value)
{
this.fileName = value;
}
展开阅读全文

没有更多推荐了,返回首页