0

I have jar archive build with Ant 1.9.1 When I launch class from it I get the following exception:

Caused by Java exception: java.lang.NoSuchMethodError: com.gargoylesoftware.htmlunit.html.HtmlCheckBoxInput.setChecked(Z)V
        at com.blablabla.kats.drivers.CheckBox.check(CheckBox.java:57)
        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 com.blablabla.kats.utils.Operation.doInvoke(Operation.java:142)
        at com.blablabla.kats.utils.Operation.invokeMethod(Operation.java:117)
        at com.blablabla.kats.model.handles.ElementOperationHandle.invokeOn(ElementOperationHandle.java:33)
        at com.blablabla.kats.model.statements.DirectAction.execute(DirectAction.java:45)
        at com.blablabla.kats.model.StatementSequence.executeStatement(StatementSequence.java:74)
        at com.blablabla.kats.model.StatementSequence.doExecute(StatementSequence.java:50)
        at com.blablabla.kats.model.Procedure.call(Procedure.java:46)
        at com.blablabla.kats.model.statements.Invocation.execute(Invocation.java:48)
        at com.blablabla.kats.model.StatementSequence.executeStatement(StatementSequence.java:74)
        at com.blablabla.kats.model.StatementSequence.doExecute(StatementSequence.java:50)
        at com.blablabla.kats.model.TestCase.execute(TestCase.java:41)
        at com.blablabla.kats.model.TestSuite.execute(TestSuite.java:45)
        at com.blablabla.kats.model.TestProgram.execute(TestProgram.java:40)
        at com.blablabla.kats.Main.main(Main.java:158)

When I compile "com.blablabla.kats.drivers.CheckBox" class by javac and replace corresponding file in jar all works fine. I use htmlunit 2.12

java -version
java version "1.6.0_45"
Java(TM) SE Runtime Environment (build 1.6.0_45-b06)
Java HotSpot(TM) 64-Bit Server VM (build 20.45-b01, mixed mode)

corresponding Ant task:

<path id="classpath.libraries">
    <fileset dir="${basedir}/lib">
      <include name="*.jar"/>
    </fileset>
  </path>


     <target name="compile">
        <javac srcdir="${basedir}/src/java" destdir="classes"  debug="true" source="1.5" target="1.5">
          <classpath refid="classpath.libraries" />
        </javac>
      </target>

${basedir}/lib contains a lot of jars.
The main are kats.jar - my project, containing com.blablabla.kats.drivers.CheckBox
htmlunit-2.12.jar - where com.gargoylesoftware.htmlunit.html.HtmlCheckBoxInput.setChecked(Z) is.

Why it can happen?

4

2 回答 2

0

我发现我没有删除旧的编译类。当我清理编译的类时一切正常。

于 2013-06-18T02:14:22.507 回答
0

我看到的唯一区别是,您在 ant 脚本中使用 1.5,而查看您使用 java6 运行它的 java 版本。我不确定这是否会产生很大的不同,因为它应该向后兼容,但仍然试一试。在 ant build.xml 中将此版本更改为 1.6

于 2013-06-17T09:24:50.440 回答