简体   繁体   English

java.lang.RuntimeException:java.lang.ClassNotFoundException: <org.objectweb.asm.ClassWriter.getCommonSuperClass(Unknown Source)>

[英]java.lang.RuntimeException: java.lang.ClassNotFoundException: <org.objectweb.asm.ClassWriter.getCommonSuperClass(Unknown Source)>

I get following exception with new cobertura (2.0.2..) . 我使用新的cobertura(2.0.2 ..)获得以下异常。 I guess it is some how related to new object creation immediately in a new block. 我想这与新块中的新对象创建有关。

WARN   instrumentClass, Unable to instrument file c:\apps\ijprojects\TrickyInstrument\out\production\TrickyInstrument\InstrumentationFailsOnFirstNewClassInTryBlock.class
java.lang.RuntimeException: java.lang.ClassNotFoundException: DataAccess
        at org.objectweb.asm.ClassWriter.getCommonSuperClass(Unknown Source)
        at org.objectweb.asm.ClassWriter.a(Unknown Source)
        at org.objectweb.asm.Frame.a(Unknown Source)
        at org.objectweb.asm.Frame.a(Unknown Source)
        at org.objectweb.asm.MethodWriter.visitMaxs(Unknown Source)
        at org.objectweb.asm.MethodVisitor.visitMaxs(Unknown Source)
        at org.objectweb.asm.util.CheckMethodAdapter.visitMaxs(Unknown Source)
        at org.objectweb.asm.MethodVisitor.visitMaxs(Unknown Source)
        at org.objectweb.asm.commons.LocalVariablesSorter.visitMaxs(Unknown Source)
        at org.objectweb.asm.tree.MethodNode.accept(Unknown Source)
        at org.objectweb.asm.util.CheckMethodAdapter$1.visitEnd(Unknown Source)
        at org.objectweb.asm.MethodVisitor.visitEnd(Unknown Source)
        at org.objectweb.asm.util.CheckMethodAdapter.visitEnd(Unknown Source)
        at org.objectweb.asm.ClassReader.b(Unknown Source)
        at org.objectweb.asm.ClassReader.accept(Unknown Source)
        at org.objectweb.asm.ClassReader.accept(Unknown Source)
        at net.sourceforge.cobertura.instrument.CoberturaInstrumenter.instrumentClass(CoberturaInstrumenter.java:204)
        at net.sourceforge.cobertura.instrument.CoberturaInstrumenter.instrumentClass(CoberturaInstrumenter.java:121)
        at net.sourceforge.cobertura.instrument.CoberturaInstrumenter.addInstrumentationToSingleClass(CoberturaInstrumenter.java:233)
        at net.sourceforge.cobertura.instrument.Main.addInstrumentationToSingleClass(Main.java:274)
        at net.sourceforge.cobertura.instrument.Main.addInstrumentation(Main.java:283)
        at net.sourceforge.cobertura.instrument.Main.addInstrumentation(Main.java:292)
        at net.sourceforge.cobertura.instrument.Main.parseArguments(Main.java:373)
        at net.sourceforge.cobertura.instrument.Main.main(Main.java:395)
8 Jul, 2013 2:05:07 PM net.sourceforge.cobertura.coveragedata.CoverageDataFileHandler saveCoverageData
INFO: Cobertura: Saved information on 2 classes.

The following is the code related to above exception. 以下是与上述异常相关的代码。

public class InstrumentationFailsOnFirstNewClassInTryBlock {


    public void saveToDatabase() {
        //
        try {
//            boolean b=false;
//            if ( b) {
//                System.out.println("no action");
//            }
            DataAccess da = new DataAccess();
            System.out.println("nothing");

        } catch (Exception e) {


        }
    }
}
  class DataAccess {
    public DataAccess() {
        //To change body of created methods use File | Settings | File Templates.
    }
}

If I un-comment the code block some dummy statements , then instrumentation works fine. 如果我取消注释代码阻止一些虚拟语句,那么检测工作正常。 Has any one seen this? 有谁见过这个? Any potential fixes? 任何潜在的修复?

Edit: Error occurs with java6 and java7. 编辑:java6和java7发生错误。

Original problem was due to a Cobertura defect. 原始问题是由于Cobertura缺陷造成的。 It is not fixed. 它不是固定的。 Cobertura now supports an additional argument for auxillary classpath. Cobertura现在支持辅助类路径的另一个参数 . This will be used to resolve any classes required for instrumentation. 这将用于解决检测所需的任何类。

cobertura-ant task documentation cobertura-ant任务文档

Adding auxClasspath 添加auxClasspath

auxClasspath argument is designed to remove the ClassNotFoundException during instrumentation. auxClasspath参数旨在在检测期间删除ClassNotFoundException。 See https://github.com/cobertura/cobertura/wiki/FAQ#classnotfoundexception-during-instrumentation for more information on this argument 有关此参数的更多信息,请参阅https://github.com/cobertura/cobertura/wiki/FAQ#classnotfoundexception-during-instrumentation

I had a similar issue, and it may be a bug, see: https://github.com/cobertura/cobertura/issues/49 我有一个类似的问题,它可能是一个错误,请参阅: https//github.com/cobertura/cobertura/issues/49

Your test case may be useful to debug the issue... 您的测试用例可能对调试问题很有用......

From https://github.com/cobertura/cobertura/wiki/FAQ#classnotfoundexception-during-instrumentation : 来自https://github.com/cobertura/cobertura/wiki/FAQ#classnotfoundexception-during-instrumentation

"This is because during instrumentation in cobertura 2.0, we use ASM to rebuild the .class files. We rebuild the stackmap which is a requirement to be compatible with java 7 and anything after. This does not mean that we recompile the code, however ASM requires that we provide the binaries of the other classes just in case it needs to look up any super methods. To fix this we use an argument called auxClasspath." “这是因为在cobertura 2.0的测试过程中,我们使用ASM来重建.class文件。我们重建了stackmap,这是与java 7兼容的要求。这并不意味着我们重新编译代码,但是ASM要求我们提供其他类的二进制文件以防它需要查找任何超级方法。为了解决这个问题,我们使用一个名为auxClasspath的参数。“

Adding the following code to your ant file (build.xml) should resolve the issue. 将以下代码添加到ant文件(build.xml)应解决此问题。

<path id="cobertura.auxpath">
<pathelement location="${bin}"/>
    </path>

    <target name="instrument_coverage" depends="init_coverage"
        description="Instruments source code for coverage measurement">
        <cobertura-instrument datafile="${coverage.datafile}">
            <fileset refid="coverage-files"/>
        <auxClasspath>
              <path refid="cobertura.auxpath" />
            </auxClasspath>
        </cobertura-instrument>
    </target>

This worked for me. 这对我有用。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 hadoop,java.lang.RuntimeException:java.lang.ClassNotFoundException错误 - hadoop, java.lang.RuntimeException: java.lang.ClassNotFoundException error 有关hadoop的问题“java.lang.RuntimeException:java.lang.ClassNotFoundException:” - Question on hadoop “java.lang.RuntimeException: java.lang.ClassNotFoundException: ” 查看Jasper报告的异常“java.lang.NoSuchMethodError:org.objectweb.asm.ClassWriter” - Exception “java.lang.NoSuchMethodError: org.objectweb.asm.ClassWriter” on Viewing Jasper Report 错误:java.lang.NoSuchMethodError:org.objectweb.asm.ClassWriter。<init>(I)V - Error : java.lang.NoSuchMethodError: org.objectweb.asm.ClassWriter.<init>(I)V 调用init方法失败; 嵌套的异常是java.lang.NoSuchMethodError:org.objectweb.asm.ClassWriter。 <init> - Invocation of init method failed; nested exception is java.lang.NoSuchMethodError: org.objectweb.asm.ClassWriter.<init> java.lang.RuntimeException: org.apache.nutch.plugin.PluginRuntimeException: java.lang.ClassNotFoundException 当用 nutch 解析时 - java.lang.RuntimeException: org.apache.nutch.plugin.PluginRuntimeException: java.lang.ClassNotFoundException when parsing with nutch How solve java.lang.RuntimeException: java.lang.ClassNotFoundException: org.apache.hadoop.fs.LocalFileSystem in aws lambda? - How solve java.lang.RuntimeException: java.lang.ClassNotFoundException: org.apache.hadoop.fs.LocalFileSystem in aws lambda? java.lang.RuntimeException:java.lang.ClassNotFoundException:com.coremedia.iso.boxes.mdat.MediaDataBox - java.lang.RuntimeException: java.lang.ClassNotFoundException: com.coremedia.iso.boxes.mdat.MediaDataBox java.lang.RuntimeException:无法实例化应用程序,java.lang.ClassNotFoundException: - java.lang.RuntimeException: Unable to instantiate application, java.lang.ClassNotFoundException: java.lang.RuntimeException:尝试在Elastic MapReduce上运行Jar作业时出现java.lang.ClassNotFoundException - java.lang.RuntimeException: java.lang.ClassNotFoundException when trying to run Jar job on Elastic MapReduce
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM