2012-03-05 63 views
0

我使用Tomcat上的聲納和使用Ant使用Java項目的目錄錯誤。錯誤聲納:java.lang.IllegalArgumentException異常:參數「目錄」是不是在聲納

當過我運行命令提示符聲納我收到以下錯誤。

java.lang.IllegalArgumentException: Parameter 'directory' is not a directory 

在以前的項目其工作正常,但是當我配置一個新的項目我得到這個錯誤..

<sonar:sonar key="dk.logica:pensab" version="1.0" xmlns:sonar="antlib:org.sonar.ant"> 

     <sources> 
      <path location="${jpa.base.dir}/src" /> 

      <path location="${ws.base.dir}/config/xsd" /> 
      <fileset dir="${ws.base.dir}/src" > 
     <exclude name="**/BuildErrorCode.java"/> 
    </fileset> 

     </sources> 

      <property key="sonar.projectName" value="Pensab" /> 
     <!-- <property key="sonar.dynamicAnalysis" value="reuseReports" /> 
      <property key="sonar.surefire.reportsPath" value="ZTest/cobertura/xmlreport" /> 
      <property key="sonar.cobertura.reportPath" value="ZTest/cobertura/coveragereport/coverage.xml" /> --> 
      <property key="sonar.java.source" value="1.6" /> 
      <property key="sonar.java.target" value="1.6" /> 

      <property key="java.specification.version" value="1.6" /> 
      <property key="java.runtime.version" value="1.6" /> 
      <property key="java.vm.version" value="1.6" /> 
      <property key="ant.java.version" value="1.6" /> 



      <tests> 
      <path location="${ws.base.dir}/src" /> 
      </tests> 

      <binaries> 
      <path refid="allclass" /> 

      <path location="${ws.base.dir}/config/xsd" /> 

      </binaries> 

      <libraries> 
      <path refid="alljars" /> 
      <path location="${ws.base.dir}/config/xsd" /> 

      </libraries> 

     </sonar:sonar> 
     </target> 

完全錯誤

sonar: 
[sonar:sonar] Apache Ant version 1.8.1 compiled on April 30 2010 
[sonar:sonar] Sonar Ant Task version: 1.0 
[sonar:sonar] Loaded from: file:/D:/JavaWorld/ContinuousIntegration/Provider /workspace/WS/sonar-ant-task-1.0.jar 
[sonar:sonar] Sonar work directory: D:\JavaWorld\ContinuousIntegration\Provider\workspace\WS\.sonar 
[sonar:sonar] Sonar server: http://localhost:8080/sonar/ 
[sonar:sonar] Sonar version: 2.8 
[sonar:sonar] [INFO] Database dialect class org.sonar.jpa.dialect.Derby 
[sonar:sonar] [INFO] Initializing Hibernate 
[sonar:sonar] [WARN] Warning parsing XML: XML InputStream(2) schema_reference.4: Failed to read schema document 'http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd', because 1) could not find the docum 
[sonar:sonar] [WARN] Warning parsing XML: XML InputStream(3) schema_reference.4: Failed to read schema document 'http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd', because 1) could not find the docum 
[sonar:sonar] [WARN] Warning parsing XML: XML InputStream(4) schema_reference.4: Failed to read schema document 'http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd', because 1) could not find the docum 
[sonar:sonar] [WARN] Warning parsing XML: XML InputStream(5) schema_reference.4: Failed to read schema document 'http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd', because 1) could not find the docum 
[sonar:sonar] [WARN] Warning parsing XML: XML InputStream(6) schema_reference.4: Failed to read schema document 'http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd', because 1) could not find the docum 
[sonar:sonar] [WARN] Warning parsing XML: XML InputStream(7) schema_reference.4: Failed to read schema document 'http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd', because 1) could not find the docum 
[sonar:sonar] [WARN] Warning parsing XML: XML InputStream(8) schema_reference.4: Failed to read schema document 'http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd', because 1) could not find the docum 
[sonar:sonar] [WARN] Warning parsing XML: XML InputStream(9) schema_reference.4: Failed to read schema document 'http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd', because 1) could not find the docum 
[sonar:sonar] [WARN] Warning parsing XML: XML InputStream(10) schema_reference.4: Failed to read schema document 'http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd', because 1) could not find the docu 
[sonar:sonar] [WARN] Warning parsing XML: XML InputStream(11) schema_reference.4: Failed to read schema document 'http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd', because 1) could not find the docu 
[sonar:sonar] [WARN] Warning parsing XML: XML InputStream(12) schema_reference.4: Failed to read schema document 'http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd', because 1) could not find the docu 
[sonar:sonar] [WARN] Warning parsing XML: XML InputStream(13) schema_reference.4: Failed to read schema document 'http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd', because 1) could not find the docu 
[sonar:sonar] [WARN] Warning parsing XML: XML InputStream(14) schema_reference.4: Failed to read schema document 'http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd', because 1) could not find the docu 
[sonar:sonar] [WARN] Warning parsing XML: XML InputStream(15) schema_reference.4: Failed to read schema document 'http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd', because 1) could not find the docu 
[sonar:sonar] [WARN] Warning parsing XML: XML InputStream(16) schema_reference.4: Failed to read schema document 'http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd', because 1) could not find the docu 
[sonar:sonar] [WARN] Warning parsing XML: XML InputStream(17) schema_reference.4: Failed to read schema document 'http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd', because 1) could not find the docu 
[sonar:sonar] [WARN] Warning parsing XML: XML InputStream(18) schema_reference.4: Failed to read schema document 'http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd', because 1) could not find the docu 
[sonar:sonar] [WARN] Warning parsing XML: XML InputStream(19) schema_reference.4: Failed to read schema document 'http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd', because 1) could not find the docu 
[sonar:sonar] [WARN] Warning parsing XML: XML InputStream(20) schema_reference.4: Failed to read schema document 'http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd', because 1) could not find the docu 
[sonar:sonar] [WARN] Warning parsing XML: XML InputStream(21) schema_reference.4: Failed to read schema document 'http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd', because 1) could not find the docu 
[sonar:sonar] [WARN] Warning parsing XML: XML InputStream(22) schema_reference.4: Failed to read schema document 'http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd', because 1) could not find the docu 
[sonar:sonar] [WARN] Warning parsing XML: XML InputStream(23) schema_reference.4: Failed to read schema document 'http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd', because 1) could not find the docu 
[sonar:sonar] [WARN] Warning parsing XML: XML InputStream(24) schema_reference.4: Failed to read schema document 'http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd', because 1) could not find the docu 
[sonar:sonar] [WARN] Warning parsing XML: XML InputStream(25) schema_reference.4: Failed to read schema document 'http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd', because 1) could not find the docu 
[sonar:sonar] [WARN] Warning parsing XML: XML InputStream(26) schema_reference.4: Failed to read schema document 'http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd', because 1) could not find the docu 
[sonar:sonar] [WARN] Warning parsing XML: XML InputStream(27) schema_reference.4: Failed to read schema document 'http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd', because 1) could not find the docu 
[sonar:sonar] [WARN] Warning parsing XML: XML InputStream(28) schema_reference.4: Failed to read schema document 'http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd', because 1) could not find the docu 
[sonar:sonar] [WARN] Warning parsing XML: XML InputStream(29) schema_reference.4: Failed to read schema document 'http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd', because 1) could not find the docu 
[sonar:sonar] [WARN] Warning parsing XML: XML InputStream(31) schema_reference.4: Failed to read schema document 'http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd', because 1) could not find the docu 
[sonar:sonar] [WARN] Warning parsing XML: XML InputStream(34) schema_reference.4: Failed to read schema document 'http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd', because 1) could not find the docu 
[sonar:sonar] [WARN] Warning parsing XML: XML InputStream(39) schema_reference.4: Failed to read schema document 'http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd', because 1) could not find the docu 
[sonar:sonar] [INFO] Execution environment: Ant Apache Ant version 1.8.1 compiled on April 30 2010 
[sonar:sonar] [INFO] ------------- Analyzing MyProject 
[sonar:sonar] [INFO] Selected quality profile : [name=MyProj,language=java] 
[sonar:sonar] [INFO] Compare over 5 days (2012-03-04) 
[sonar:sonar] [INFO] Compare over 30 days (2012-02-08) 
[sonar:sonar] [INFO] Configure maven plugins... 
[sonar:sonar] [INFO] Sensor AsynchronousMeasuresSensor... 
[sonar:sonar] [INFO] Sensor AsynchronousMeasuresSensor done: 1609 ms 
[sonar:sonar] [INFO] Sensor JavaSourceImporter... 
[sonar:sonar] [INFO] Sensor JavaSourceImporter done: 2547 ms 
[sonar:sonar] [INFO] Sensor SquidSensor... 

BUILD FAILED 
D:\JavaWorld\ContinuousIntegration\Provider\workspace\WS\sonar-build.xml:80: java.lang.IllegalArgumentException: Parameter 'directory' is not a directory 
    at org.apache.commons.io.FileUtils.listFiles(FileUtils.java:358) 
    at org.apache.commons.io.FileUtils.listFiles(FileUtils.java:443) 
    at  org.sonar.plugins.squid.SquidSensor.hasProjectBytecodeFiles(SquidSensor.java:109) 
    at org.sonar.plugins.squid.SquidSensor.getMainBytecodeFiles(SquidSensor.java:95) 
    at org.sonar.plugins.squid.SquidSensor.analyzeMainSources(SquidSensor.java:78) 
    at org.sonar.plugins.squid.SquidSensor.analyse(SquidSensor.java:62) 
    at org.sonar.batch.phases.SensorsExecutor.execute(SensorsExecutor.java:58) 
    at org.sonar.batch.phases.Phases.execute(Phases.java:80) 
    at org.sonar.batch.ProjectBatch.execute(ProjectBatch.java:59) 
    at org.sonar.batch.Batch.analyzeModule(Batch.java:164) 
    at org.sonar.batch.Batch.analyzeModules(Batch.java:82) 
    at org.sonar.batch.Batch.execute(Batch.java:62) 
    at org.sonar.ant.Launcher.executeBatch(Launcher.java:121) 
    at org.sonar.ant.Launcher.execute(Launcher.java:60) 
    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 org.sonar.ant.SonarTask.delegateExecution(SonarTask.java:167) 
    at org.sonar.ant.SonarTask.execute(SonarTask.java:151) 
    at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:291) 
    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 org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106) 
    at org.apache.tools.ant.Task.perform(Task.java:348) 
    at org.apache.tools.ant.Target.execute(Target.java:390) 
    at org.apache.tools.ant.Target.performTasks(Target.java:411) 
    at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1397) 
    at org.apache.tools.ant.Project.executeTarget(Project.java:1366) 
    at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41) 
    at org.apache.tools.ant.Project.executeTargets(Project.java:1249) 
    at org.apache.tools.ant.Main.runBuild(Main.java:801) 
    at org.apache.tools.ant.Main.startAnt(Main.java:218) 
    at org.apache.tools.ant.launch.Launcher.run(Launcher.java:280) 
    at org.apache.tools.ant.launch.Launcher.main(Launcher.java:109) 

任何人都建議我一個解決方案?

+0

參數'directory'指向哪裏。 – oers 2012-03-05 13:27:45

+0

聲納中沒有任何稱爲目錄的屬性! – Rajmahendra 2012-03-06 11:51:26

+0

請添加螞蟻目標,你用來調用聲納分析 – oers 2012-03-06 11:53:22

回答

0

您正在使用舊版本的螞蟻任務(如果您可以更新聲吶服務器,則應該更新螞蟻任務,否則請使用1.0)。

但你的問題就出在這裏(不會被插件的新版本的固定):

<fileset dir="${ws.base.dir}/src" > 
    <exclude name="**/BuildErrorCode.java"/> 
</fileset> 

將把Java文件列表到<source> ... </source>

這不會是目錄(因爲它們是文件)並導致該錯誤。

doc說,對來源:

<!-- source directories (required) --> 
    <sources> 
    <path location="..." /> 
    </sources> 

你不能把文件按文件集在那裏。只有目錄。

+0

所以我可以使用多個 ...,我怎麼能避免一些不必要的文件在一個src? – Rajmahendra 2012-03-12 09:58:23

+0

@Raj你可以有多個來源,但他們必須是目錄。您可以在服務器配置中排除特殊文件或通過[sonar.exclusion屬性](http://docs.codehaus.org/display/SONAR/Advanced+parameters) – oers 2012-03-12 10:27:46

0

我最近移動sonarqube二進制文件目錄後,得到了同樣的錯誤。必須從活動監視器中終止所有java進程並運行./sonar.sh start來解決問題。