I got below error when I run junit test in the ant. The test class needs call web service API.
Can someone help to resolve it?
<error message="javax.xml.transform.TransformerFactory.setFeature(Ljava/lang/String;Z)V" type="java.lang.AbstractMethodError">java.lang.AbstractMethodError: javax.xml.transform.TransformerFactory.setFeature(Ljava/lang/String;Z)V
at com.sun.xml.ws.util.xml.XmlUtil.newTransformerFactory(XmlUtil.java:392)
at com.sun.xml.ws.util.xml.XmlUtil.newTransformerFactory(XmlUtil.java:400)
at com.sun.xml.ws.util.xml.XmlUtil.<clinit>(XmlUtil.java:233)
at com.sun.xml.ws.client.WSServiceDelegate.createCatalogResolver(WSServiceDelegate.java:377)
at com.sun.xml.ws.client.WSServiceDelegate.parseWSDL(WSServiceDelegate.java:363)
at com.sun.xml.ws.client.WSServiceDelegate.<init>(WSServiceDelegate.java:321)
at com.sun.xml.ws.client.WSServiceDelegate.<init>(WSServiceDelegate.java:230)
at com.sun.xml.ws.client.WSServiceDelegate.<init>(WSServiceDelegate.java:211)
at com.sun.xml.ws.client.WSServiceDelegate.<init>(WSServiceDelegate.java:207)
at com.sun.xml.ws.spi.ProviderImpl.createServiceDelegate(ProviderImpl.java:114)
at javax.xml.ws.Service.<init>(Service.java:77)
at com.citi.isg.amg.ws.client.AccountManagerWs.<init>(AccountManagerWs.java:42)
at ... ...
I just found the root cause by myself.
Per Oracle Documentation , The java.lang.AbstractMethodError is thrown when an application tries to call an abstract method. Normally, this error is caught by the compiler; this error can only occur at run time if the definition of some class has incompatibly changed since the currently executing method was last compiled.
Seems I have not specified the implementation for the abstract class javax.xml.transform.TransformerFactory in the rt.jar.
Adding below inside Junit
<sysproperty key="javax.xml.transform.TransformerFactory"
value="com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl"/>
make it works.
So the final Junit task looks like below:
<junit showoutput="true" printsummary="yes" fork="true" forkmode="once">
<classpath refid="junit.runtime.classpath" />
<sysproperty key="javax.xml.transform.TransformerFactory"
value="com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl"/>
<batchtest haltonfailure="no" todir="${test.result.dir}">
<fileset dir="${test.src.dir}">
<include name="**/*Test.java" />
</fileset>
<formatter type="xml" />
</batchtest>
</junit>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.