jira.codehaus.org

  • Log In Access more options
    • Online Help
    • Keyboard Shortcuts
    • About JIRA
    • JIRA Credits
    • What?s New
  • Dashboards Access more options (Alt+d)
  • Projects Access more options (Alt+p)
  • Issues Access more options (Alt+i)
Signup
Sonar Plugins
  • Sonar Plugins
  • SONARPLUGINS-2559

Cannot load extra schemas

  • Log In
  • Views
    • XML
    • Word
    • Printable

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Fixed
  • Affects Version/s: XML-0.2
  • Fix Version/s: XML-1.0
  • Component/s: XML
  • Labels:
    None
  • Environment:
    Windows Server 2008 SR2
  • Number of attachments :
    0

Description

I try to specify an extra schema through sonar.xml.schemas but get the error below. The schema in question is spring-beans-3.1.xsd available at http://www.springframework.org/schema/beans/spring-beans-3.1.xsd.

09:13:46.718 ERROR o.s.p.xml.XmlSensor - Could not analyze the file D:\jenkins-workspaces\sandbox-master\bin\custom\xyz\zyx\test.xml
java.lang.NullPointerException: name
at java.util.zip.ZipFile.getEntry(ZipFile.java:299) ~[na:1.7.0_09]
at java.util.jar.JarFile.getEntry(JarFile.java:225) ~[na:1.7.0_09]
at java.util.jar.JarFile.getJarEntry(JarFile.java:208) ~[na:1.7.0_09]
at sun.misc.URLClassPath$JarLoader.getResource(URLClassPath.java:817) ~[na:1.7.0_09]
at sun.misc.URLClassPath$JarLoader.findResource(URLClassPath.java:795) ~[na:1.7.0_09]
at sun.misc.URLClassPath.findResource(URLClassPath.java:172) ~[na:1.7.0_09]
at java.net.URLClassLoader$2.run(URLClassLoader.java:551) ~[na:1.7.0_09]
at java.net.URLClassLoader$2.run(URLClassLoader.java:549) ~[na:1.7.0_09]
at java.security.AccessController.doPrivileged(Native Method) ~[na:1.7.0_09]
at java.net.URLClassLoader.findResource(URLClassLoader.java:548) ~[na:1.7.0_09]
at org.sonar.runner.BootstrapClassLoader.getResource(BootstrapClassLoader.java:112) ~[sonar-runner.jar:na]
at java.lang.ClassLoader.getResource(ClassLoader.java:1133) ~[na:1.7.0_09]
at java.lang.ClassLoader.getResource(ClassLoader.java:1133) ~[na:1.7.0_09]
at java.net.URLClassLoader.getResourceAsStream(URLClassLoader.java:227) ~[na:1.7.0_09]
at java.lang.Class.getResourceAsStream(Class.java:2047) ~[na:1.7.0_09]
at org.sonar.plugins.xml.schemas.SchemaResolver.getBuiltinSchemaByFileName(SchemaResolver.java:178) ~[na:na]
at org.sonar.plugins.xml.schemas.SchemaResolver.resolveResource(SchemaResolver.java:218) ~[na:na]
at org.apache.xerces.util.DOMEntityResolverWrapper.resolveEntity(Unknown Source) ~[xercesImpl-2.8.1.jar:na]
at org.apache.xerces.impl.XMLEntityManager.resolveEntity(Unknown Source) ~[xercesImpl-2.8.1.jar:na]
at org.apache.xerces.impl.xs.XMLSchemaLoader.resolveDocument(Unknown Source) ~[xercesImpl-2.8.1.jar:na]
at org.apache.xerces.impl.xs.traversers.XSDHandler.resolveSchema(Unknown Source) ~[xercesImpl-2.8.1.jar:na]
at org.apache.xerces.impl.xs.traversers.XSDHandler.constructTrees(Unknown Source) ~[xercesImpl-2.8.1.jar:na]
at org.apache.xerces.impl.xs.traversers.XSDHandler.parseSchema(Unknown Source) ~[xercesImpl-2.8.1.jar:na]
at org.apache.xerces.impl.xs.XMLSchemaLoader.loadSchema(Unknown Source) ~[xercesImpl-2.8.1.jar:na]
at org.apache.xerces.impl.xs.XMLSchemaLoader.loadGrammar(Unknown Source) ~[xercesImpl-2.8.1.jar:na]
at org.apache.xerces.impl.xs.XMLSchemaLoader.loadGrammar(Unknown Source) ~[xercesImpl-2.8.1.jar:na]
at org.apache.xerces.jaxp.validation.XMLSchemaFactory.newSchema(Unknown Source) ~[xercesImpl-2.8.1.jar:na]
at org.sonar.plugins.xml.checks.XmlSchemaCheck.createSchema(XmlSchemaCheck.java:136) ~[na:na]
at org.sonar.plugins.xml.checks.XmlSchemaCheck.validate(XmlSchemaCheck.java:235) ~[na:na]
at org.sonar.plugins.xml.checks.XmlSchemaCheck.validate(XmlSchemaCheck.java:228) ~[na:na]
at org.sonar.plugins.xml.checks.XmlSchemaCheck.validate(XmlSchemaCheck.java:260) ~[na:na]
at org.sonar.plugins.xml.XmlSensor.analyse(XmlSensor.java:72) ~[na:na]
at org.sonar.batch.phases.SensorsExecutor.execute(SensorsExecutor.java:64) [sonar-batch-3.3.2.jar:na]
at org.sonar.batch.phases.Phases.execute(Phases.java:97) [sonar-batch-3.3.2.jar:na]
at org.sonar.batch.bootstrap.ProjectModule.doStart(ProjectModule.java:128) [sonar-batch-3.3.2.jar:na]
at org.sonar.batch.bootstrap.Module.start(Module.java:83) [sonar-batch-3.3.2.jar:na]
at org.sonar.batch.bootstrap.BatchModule.analyze(BatchModule.java:114) [sonar-batch-3.3.2.jar:na]
at org.sonar.batch.bootstrap.BatchModule.analyze(BatchModule.java:109) [sonar-batch-3.3.2.jar:na]
at org.sonar.batch.bootstrap.BatchModule.doStart(BatchModule.java:104) [sonar-batch-3.3.2.jar:na]
at org.sonar.batch.bootstrap.Module.start(Module.java:83) [sonar-batch-3.3.2.jar:na]
at org.sonar.batch.bootstrap.BootstrapModule.doStart(BootstrapModule.java:121) [sonar-batch-3.3.2.jar:na]
at org.sonar.batch.bootstrap.Module.start(Module.java:83) [sonar-batch-3.3.2.jar:na]
at org.sonar.batch.Batch.execute(Batch.java:104) [sonar-batch-3.3.2.jar:na]
at org.sonar.runner.internal.batch.Launcher.executeBatch(Launcher.java:69) [sonar-runner.jar:na]
at org.sonar.runner.internal.batch.Launcher.execute(Launcher.java:61) [sonar-runner.jar:na]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.7.0_09]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) ~[na:1.7.0_09]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.7.0_09]
at java.lang.reflect.Method.invoke(Method.java:601) ~[na:1.7.0_09]
at org.sonar.runner.Runner.delegateExecution(Runner.java:285) [sonar-runner.jar:na]
at org.sonar.runner.Runner.execute(Runner.java:151) [sonar-runner.jar:na]
at org.sonar.runner.Main.execute(Main.java:84) [sonar-runner.jar:na]
at org.sonar.runner.Main.main(Main.java:56) [sonar-runner.jar:na]

Activity

Ascending order - Click to sort in descending order
  • All
  • Comments
  • Work Log
  • History
  • Activity
Hide
Permalink
Freddy Mallet added a comment - 04/Jan/13 6:56 AM

@Andres, could you provide the list of Sonar properties that you're using to launch this XML analysis ?

Show
Freddy Mallet added a comment - 04/Jan/13 6:56 AM @Andres, could you provide the list of Sonar properties that you're using to launch this XML analysis ?
Hide
Permalink
Anders Jacobsson added a comment - 07/Jan/13 1:38 AM

Sure, these are the properties (I have only included the relevant module):

sonar.projectKey=xyz
sonar.projectName=123
sonar.projectVersion=1.0
sonar.java.source=1.6
sonar.modules=cockpits-xml
sonar.sources=src
sonar.tests=testsrc
sonar.binaries=
sonar.libraries=
sonar.dynamicAnalysis=reuseReports
sonar.surefire.reportsPath=../../../../log/junit/
sonar.jacoco.reportPath=../../../../log/jacoco/merged-unittests.exec
sonar.core.codeCoveragePlugin=jacoco
sonar.language=java
sonar.exclusions=
cockpits-xml.sonar.projectName=cockpits-xml
cockpits-xml.sonar.projectBaseDir=bin/custom/xyz/cockpits
cockpits-xml.sonar.language=xml
cockpits-xml.sonar.xml.sourceDirectory=.
cockpits-xml.sonar.xml.includeFileFilter=*/.xml
cockpits-xml.sonar.xml.schemas=../tools/schemas/spring-beans-3.1.xsd

Hope this helps.

Show
Anders Jacobsson added a comment - 07/Jan/13 1:38 AM Sure, these are the properties (I have only included the relevant module): sonar.projectKey=xyz sonar.projectName=123 sonar.projectVersion=1.0 sonar.java.source=1.6 sonar.modules=cockpits-xml sonar.sources=src sonar.tests=testsrc sonar.binaries= sonar.libraries= sonar.dynamicAnalysis=reuseReports sonar.surefire.reportsPath=../../../../log/junit/ sonar.jacoco.reportPath=../../../../log/jacoco/merged-unittests.exec sonar.core.codeCoveragePlugin=jacoco sonar.language=java sonar.exclusions= cockpits-xml.sonar.projectName=cockpits-xml cockpits-xml.sonar.projectBaseDir=bin/custom/xyz/cockpits cockpits-xml.sonar.language=xml cockpits-xml.sonar.xml.sourceDirectory=. cockpits-xml.sonar.xml.includeFileFilter=* / .xml cockpits-xml.sonar.xml.schemas=../tools/schemas/spring-beans-3.1.xsd Hope this helps.
Hide
Permalink
Julien HENRY added a comment - 23/Jan/13 10:16 AM

Problem is that Spring XSD (http://www.springframework.org/schema/beans/spring-beans-3.1.xsd) import the following namespace: http://www.w3.org/XML/1998/namespace

This namespace was not part of plugin builtin schema so I've added it.

In case you need a schema that is not part of builtin ones you can also add it to the property "schemas" of the rule (just be sure to provide schema in order of dependency). Separator is whitespace (@Freddy should we change that to comma?)

Note that I have removed the property sonar.xml.schemas as it was not standard to override a rule configuration from command line.

It is also possible to reference a XSD by its URL, but this is a very simple implementation (URL.openStream()) that will not honor proxy configuration.

As a sum up the "schema" property of the XSD validation rule supports:

  • autodetect
  • name of built in schema (should we provide a list somewhere?)
  • filename (relative to project root)
  • URL (with no support of http proxy)
    and you can provide several values with whitespace as separator.
Show
Julien HENRY added a comment - 23/Jan/13 10:16 AM Problem is that Spring XSD ( http://www.springframework.org/schema/beans/spring-beans-3.1.xsd ) import the following namespace: http://www.w3.org/XML/1998/namespace This namespace was not part of plugin builtin schema so I've added it. In case you need a schema that is not part of builtin ones you can also add it to the property "schemas" of the rule (just be sure to provide schema in order of dependency). Separator is whitespace (@Freddy should we change that to comma?) Note that I have removed the property sonar.xml.schemas as it was not standard to override a rule configuration from command line. It is also possible to reference a XSD by its URL, but this is a very simple implementation (URL.openStream()) that will not honor proxy configuration. As a sum up the "schema" property of the XSD validation rule supports: autodetect name of built in schema (should we provide a list somewhere?) filename (relative to project root) URL (with no support of http proxy) and you can provide several values with whitespace as separator.
Hide
Permalink
Freddy Mallet added a comment - 25/Jan/13 10:11 AM

Validated Julien !

Show
Freddy Mallet added a comment - 25/Jan/13 10:11 AM Validated Julien !

People

  • Assignee:
    Julien HENRY
    Reporter:
    Anders Jacobsson
Vote (0)
Watch (3)

Dates

  • Created:
    20/Dec/12 2:21 AM
    Updated:
    01/Feb/13 2:44 AM
    Resolved:
    23/Jan/13 10:16 AM
  • Atlassian JIRA (v5.2.7#850-sha1:b2af0c8)
  • Report a problem
  • Powered by a free Atlassian JIRA open source license for Codehaus. Try JIRA - bug tracking software for your team.