想使用 ant 实现 jacoco 的离线插桩并生成报告, ant instruments 插桩成功,就是在执行 ant dump 时,一直报错,如下:
Note: further occurrences of HTTP header parsing errors will be logged at DEBUG level.
java.lang.IllegalArgumentException: Invalid character found in method name. HTTP method names must be tokens
at org.apache.coyote.http11.Http11InputBuffer.parseRequestLine(Http11InputBuffer.java:451)
at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:667)
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:802)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1455)
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:745)
求大神指点迷津!!拜谢~~~(我没有在 jvm 修改参数,想知道离线插桩的处理方法)
下面是我的 build.xml 的内容:
<property name="src.dir" location="./src/main/java" />
<property name="result.dir" location="./target" />
<!-- classPath -->
<property name="result.classes.dir" location="${result.dir}/classes" />
<property name="result.classes.instr.dir" location="${result.dir}/classes-instr" />
<property name="result.report.dir" location="${result.dir}/site/jacoco" />
<property name="result.exec.file" location="${result.dir}/jacoco.exec" />
<!--Jacoco的安装路径-->
<property name="jacocoantPath" value="/home/glzhu/jacoco/jacocoant.jar"/>
<!-- Step 1: Import JaCoCo Ant tasks -->
<taskdef uri="antlib:org.jacoco.ant" resource="org/jacoco/ant/antlib.xml">
<classpath path="${jacocoantPath}" />
</taskdef>
<target name="clean">
<delete dir="${result.dir}" />
</target>
<target name="compile">
<mkdir dir="${result.classes.dir}" />
<javac srcdir="${src.dir}" destdir="${result.classes.dir}" debug="true" includeantruntime="false" />
</target>
<target name="instrument" depends="compile">
<!-- Step 2: Instrument class files -->
<jacoco:instrument destdir="${result.classes.instr.dir}">
<fileset dir="${result.classes.dir}" />
</jacoco:instrument>
</target>
<!--最终生成.exec文件的路径,Jacoco就是根据这个文件生成最终的报告的-->
<property name="jacocoexecPath" value="/home/xx/jacoco/ant/jacoco.exec"/>
<!--生成覆盖率报告的路径-->
<property name="reportfolderPath" value="/home/xx/jacoco/ant/report/"/>
<!--远程tomcat服务的ip地址-->
<property name="server_ip" value="127.0.0.1"/>
<!--前面配置的远程tomcat服务打开的端口,要跟上面配置的一样-->
<property name="server_port" value="8089"/>
<!--源代码路径可以包含多个源代码-->
<property name="webSrcpath" value="/home/glzhu/workspace/SpringMVC-Demo/src/main/java" />
<property name="businessSrcpath" value="/home/glzhu/workspace/SpringMVC-Demo/src/test/java"/>
<!--.class文件路径可以包含多个-->
<property name="webClasspath" value="/home/glzhu/workspace/SpringMVC-Demo-master/target/classes"/>
<property name="businessClasspath" value="/home/glzhu/workspace/SpringMVC-Demo/target/test-classes"/>
<target name="dump">
<jacoco:dump address="${server_ip}" reset="false" destfile="${jacocoexecPath}" port="${server_port}" append="true" />
</target>