jaxb
  1. jaxb
  2. JAXB-676

maven-jaxb-schemagen-plugin Exception when schema config defined

    Details

    • Type: Bug Bug
    • Status: Open
    • Priority: Minor Minor
    • Resolution: Unresolved
    • Affects Version/s: 2.1.12
    • Fix Version/s: not determined
    • Component/s: maven-plugin
    • Labels:
      None
    • Environment:

      Operating System: All
      Platform: All

      Description

      I have a very simple starter app with one JAXB-annotated bean. I am using maven 2.2.0.

      When I define the <schema> config section, I get an exception WRT the path to the parent XSD. When I
      remove this config section, the schema is generated just fine.

      The config section is below, followed by the exception stack trace.

      <configuration>
      <schemas>
      <schema>
      <namespace>http://bobj-rs.sap.com/2009/08</namespace>
      <file>bobj-rs.xsd</file>
      </schema>
      </schemas>
      </configuration>

      Exception:
      Note: Writing /Users/mbishop/Projects/rest/bobj-rs/trunk/types/target/generated-schema/bobj-
      rs.xsd
      Note: Writing schema2.xsd
      Problem encountered during annotation processing;
      see stacktrace below for more information.
      java.lang.StringIndexOutOfBoundsException: String index out of range: -1
      at java.lang.String.substring(String.java:1768)
      at com.sun.xml.bind.v2.schemagen.Util.getParentUriPath(Util.java:67)
      at
      com.sun.xml.bind.v2.schemagen.XmlSchemaGenerator.calculateRelativePath(XmlSchemaGenerator.java:
      1283)
      at
      com.sun.xml.bind.v2.schemagen.XmlSchemaGenerator.calculateRelativePath(XmlSchemaGenerator.java:
      1283)
      at
      com.sun.xml.bind.v2.schemagen.XmlSchemaGenerator.calculateRelativePath(XmlSchemaGenerator.java:
      1283)
      at
      com.sun.xml.bind.v2.schemagen.XmlSchemaGenerator.calculateRelativePath(XmlSchemaGenerator.java:
      1283)
      at
      com.sun.xml.bind.v2.schemagen.XmlSchemaGenerator.calculateRelativePath(XmlSchemaGenerator.java:
      1283)
      at
      com.sun.xml.bind.v2.schemagen.XmlSchemaGenerator.calculateRelativePath(XmlSchemaGenerator.java:
      1283)
      at
      com.sun.xml.bind.v2.schemagen.XmlSchemaGenerator.calculateRelativePath(XmlSchemaGenerator.java:
      1283)
      at
      com.sun.xml.bind.v2.schemagen.XmlSchemaGenerator.calculateRelativePath(XmlSchemaGenerator.java:
      1283)
      at
      com.sun.xml.bind.v2.schemagen.XmlSchemaGenerator.calculateRelativePath(XmlSchemaGenerator.java:
      1283)
      at
      com.sun.xml.bind.v2.schemagen.XmlSchemaGenerator.calculateRelativePath(XmlSchemaGenerator.java:
      1283)
      at
      com.sun.xml.bind.v2.schemagen.XmlSchemaGenerator.relativize(XmlSchemaGenerator.java:1259)
      at
      com.sun.xml.bind.v2.schemagen.XmlSchemaGenerator$Namespace.writeTo(XmlSchemaGenerator.java:
      482)
      at
      com.sun.xml.bind.v2.schemagen.XmlSchemaGenerator$Namespace.access$600(XmlSchemaGenerator.j
      ava:341)
      at com.sun.xml.bind.v2.schemagen.XmlSchemaGenerator.write(XmlSchemaGenerator.java:322)
      at com.sun.tools.xjc.api.impl.j2s.JAXBModelImpl.generateSchema(JAXBModelImpl.java:153)
      at com.sun.tools.jxc.apt.SchemaGenerator$1.process(SchemaGenerator.java:78)
      at
      com.sun.mirror.apt.AnnotationProcessors$CompositeAnnotationProcessor.process(AnnotationProcessor
      s.java:60)
      at com.sun.tools.apt.comp.Apt.main(Apt.java:454)
      at com.sun.tools.apt.main.JavaCompiler.compile(JavaCompiler.java:448)
      at com.sun.tools.apt.main.Main.compile(Main.java:1075)
      at com.sun.tools.apt.main.Main.compile(Main.java:938)
      at com.sun.tools.apt.Main.processing(Main.java:95)
      at com.sun.tools.apt.Main.process(Main.java:85)
      at com.sun.tools.apt.Main.process(Main.java:67)
      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:585)
      at com.sun.tools.jxc.AptBasedTask$InternalAptAdapter.execute(AptBasedTask.java:61)
      at com.sun.tools.jxc.AptBasedTask.compile(AptBasedTask.java:108)
      at com.sun.tools.jxc.maven2.SchemaGenAdapter.execute(SchemaGenAdapter.java:111)
      at com.sun.tools.jxc.maven2.SchemaGenMojo.execute(SchemaGenMojo.java:161)
      at org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:483)
      at
      org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:678)
      at
      org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalWithLifecycle(DefaultLifecycleExecutor.
      java:540)
      at
      org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:519)
      at
      org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExe
      cutor.java:371)
      at
      org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.jav
      a:332)
      at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:181)
      at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:356)
      at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:137)
      at org.apache.maven.cli.MavenCli.main(MavenCli.java:362)
      at org.apache.maven.cli.compat.CompatibleMain.main(CompatibleMain.java:41)
      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:585)
      at org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315)
      at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
      at org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)
      at org.codehaus.classworlds.Launcher.main(Launcher.java:375)
      [INFO] ------------------------------------------------------------------------
      [ERROR] FATAL ERROR
      [INFO] ------------------------------------------------------------------------

        Activity

        Hide
        drampulla added a comment -

        The file schema2.xsd is being written with some schema that is not in the
        namespace "http://bobj-rs.sap.com/2009/08". I have found that if I added an
        explicit configuration for all of the namespaces being generated, this error
        goes away.

        This is still a bug in my opinion, but the above workaround may help for a while.

        Show
        drampulla added a comment - The file schema2.xsd is being written with some schema that is not in the namespace "http://bobj-rs.sap.com/2009/08". I have found that if I added an explicit configuration for all of the namespaces being generated, this error goes away. This is still a bug in my opinion, but the above workaround may help for a while.
        Hide
        drampulla added a comment -

        Just adding self to the CC list.

        Show
        drampulla added a comment - Just adding self to the CC list.
        Hide
        Martin Grebac added a comment -

        Hi, would you please submit a full testcase project? That helps to get this clarified and fixed (and add to
        our testsuite so that we don't regress in the future). Thanks in advance.

        Show
        Martin Grebac added a comment - Hi, would you please submit a full testcase project? That helps to get this clarified and fixed (and add to our testsuite so that we don't regress in the future). Thanks in advance.
        Hide
        basiliv added a comment - - edited

        I've got the same issue. When I don't define <schema> config section schema generation works just fine. The only problem is that one extra xsd (schema23.xsd) is generated with the following content (looks rather empty to me):

        <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
        <xs:schema version="1.0" xmlns:xs="http://www.w3.org/2001/XMLSchema">
        </xs:schema>

        When I do define <schema> config section schema generation fails with the following exception:

        (Skipped)
        Note: Writing properfilenameA.xsd
        Note: Writing properfilenameB.xsd
        Note: Writing schema23.xsd
        Problem encountered during annotation processing;
        see stacktrace below for more information.
        java.lang.StringIndexOutOfBoundsException: String index out of range: -1
        at java.lang.String.substring(String.java:1937)
        at com.sun.xml.bind.v2.schemagen.Util.getParentUriPath(Util.java:67)
        at com.sun.xml.bind.v2.schemagen.XmlSchemaGenerator.calculateRelativePath(XmlSchemaGenerator.java:1283)
        at com.sun.xml.bind.v2.schemagen.XmlSchemaGenerator.calculateRelativePath(XmlSchemaGenerator.java:1283)
        at com.sun.xml.bind.v2.schemagen.XmlSchemaGenerator.calculateRelativePath(XmlSchemaGenerator.java:1283)
        at com.sun.xml.bind.v2.schemagen.XmlSchemaGenerator.calculateRelativePath(XmlSchemaGenerator.java:1283)
        at com.sun.xml.bind.v2.schemagen.XmlSchemaGenerator.calculateRelativePath(XmlSchemaGenerator.java:1283)
        at com.sun.xml.bind.v2.schemagen.XmlSchemaGenerator.calculateRelativePath(XmlSchemaGenerator.java:1283)
        at com.sun.xml.bind.v2.schemagen.XmlSchemaGenerator.calculateRelativePath(XmlSchemaGenerator.java:1283)
        at com.sun.xml.bind.v2.schemagen.XmlSchemaGenerator.calculateRelativePath(XmlSchemaGenerator.java:1283)
        at com.sun.xml.bind.v2.schemagen.XmlSchemaGenerator.relativize(XmlSchemaGenerator.java:1259)
        at com.sun.xml.bind.v2.schemagen.XmlSchemaGenerator$Namespace.writeTo(XmlSchemaGenerator.java:482)
        at com.sun.xml.bind.v2.schemagen.XmlSchemaGenerator$Namespace.access$600(XmlSchemaGenerator.java:341)
        at com.sun.xml.bind.v2.schemagen.XmlSchemaGenerator.write(XmlSchemaGenerator.java:322)
        at com.sun.tools.xjc.api.impl.j2s.JAXBModelImpl.generateSchema(JAXBModelImpl.java:153)
        at com.sun.tools.jxc.apt.SchemaGenerator$1.process(SchemaGenerator.java:78)
        at com.sun.mirror.apt.AnnotationProcessors$CompositeAnnotationProcessor.process(AnnotationProcessors.java:60)
        at com.sun.tools.apt.comp.Apt.main(Apt.java:454)
        at com.sun.tools.apt.main.JavaCompiler.compile(JavaCompiler.java:258)
        at com.sun.tools.apt.main.Main.compile(Main.java:1102)
        at com.sun.tools.apt.main.Main.compile(Main.java:964)
        at com.sun.tools.apt.Main.processing(Main.java:95)
        at com.sun.tools.apt.Main.process(Main.java:85)
        at com.sun.tools.apt.Main.process(Main.java:67)
        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.sun.tools.jxc.AptBasedTask$InternalAptAdapter.execute(AptBasedTask.java:61)
        at com.sun.tools.jxc.AptBasedTask.compile(AptBasedTask.java:108)
        at com.sun.tools.jxc.maven2.SchemaGenAdapter.execute(SchemaGenAdapter.java:111)
        at com.sun.tools.jxc.maven2.SchemaGenMojo.execute(SchemaGenMojo.java:161)
        at org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:490)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:694)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalWithLifecycle(DefaultLifecycleExecutor.java:556)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:535)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:387)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:348)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:180)
        at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:328)
        at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:138)
        at org.apache.maven.cli.MavenCli.main(MavenCli.java:362)
        at org.apache.maven.cli.compat.CompatibleMain.main(CompatibleMain.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.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315)
        at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
        at org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)
        at org.codehaus.classworlds.Launcher.main(Launcher.java:375)

        Show
        basiliv added a comment - - edited I've got the same issue. When I don't define <schema> config section schema generation works just fine. The only problem is that one extra xsd (schema23.xsd) is generated with the following content (looks rather empty to me): <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <xs:schema version="1.0" xmlns:xs="http://www.w3.org/2001/XMLSchema"> </xs:schema> When I do define <schema> config section schema generation fails with the following exception: (Skipped) Note: Writing properfilenameA.xsd Note: Writing properfilenameB.xsd Note: Writing schema23.xsd Problem encountered during annotation processing; see stacktrace below for more information. java.lang.StringIndexOutOfBoundsException: String index out of range: -1 at java.lang.String.substring(String.java:1937) at com.sun.xml.bind.v2.schemagen.Util.getParentUriPath(Util.java:67) at com.sun.xml.bind.v2.schemagen.XmlSchemaGenerator.calculateRelativePath(XmlSchemaGenerator.java:1283) at com.sun.xml.bind.v2.schemagen.XmlSchemaGenerator.calculateRelativePath(XmlSchemaGenerator.java:1283) at com.sun.xml.bind.v2.schemagen.XmlSchemaGenerator.calculateRelativePath(XmlSchemaGenerator.java:1283) at com.sun.xml.bind.v2.schemagen.XmlSchemaGenerator.calculateRelativePath(XmlSchemaGenerator.java:1283) at com.sun.xml.bind.v2.schemagen.XmlSchemaGenerator.calculateRelativePath(XmlSchemaGenerator.java:1283) at com.sun.xml.bind.v2.schemagen.XmlSchemaGenerator.calculateRelativePath(XmlSchemaGenerator.java:1283) at com.sun.xml.bind.v2.schemagen.XmlSchemaGenerator.calculateRelativePath(XmlSchemaGenerator.java:1283) at com.sun.xml.bind.v2.schemagen.XmlSchemaGenerator.calculateRelativePath(XmlSchemaGenerator.java:1283) at com.sun.xml.bind.v2.schemagen.XmlSchemaGenerator.relativize(XmlSchemaGenerator.java:1259) at com.sun.xml.bind.v2.schemagen.XmlSchemaGenerator$Namespace.writeTo(XmlSchemaGenerator.java:482) at com.sun.xml.bind.v2.schemagen.XmlSchemaGenerator$Namespace.access$600(XmlSchemaGenerator.java:341) at com.sun.xml.bind.v2.schemagen.XmlSchemaGenerator.write(XmlSchemaGenerator.java:322) at com.sun.tools.xjc.api.impl.j2s.JAXBModelImpl.generateSchema(JAXBModelImpl.java:153) at com.sun.tools.jxc.apt.SchemaGenerator$1.process(SchemaGenerator.java:78) at com.sun.mirror.apt.AnnotationProcessors$CompositeAnnotationProcessor.process(AnnotationProcessors.java:60) at com.sun.tools.apt.comp.Apt.main(Apt.java:454) at com.sun.tools.apt.main.JavaCompiler.compile(JavaCompiler.java:258) at com.sun.tools.apt.main.Main.compile(Main.java:1102) at com.sun.tools.apt.main.Main.compile(Main.java:964) at com.sun.tools.apt.Main.processing(Main.java:95) at com.sun.tools.apt.Main.process(Main.java:85) at com.sun.tools.apt.Main.process(Main.java:67) 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.sun.tools.jxc.AptBasedTask$InternalAptAdapter.execute(AptBasedTask.java:61) at com.sun.tools.jxc.AptBasedTask.compile(AptBasedTask.java:108) at com.sun.tools.jxc.maven2.SchemaGenAdapter.execute(SchemaGenAdapter.java:111) at com.sun.tools.jxc.maven2.SchemaGenMojo.execute(SchemaGenMojo.java:161) at org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:490) at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:694) at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalWithLifecycle(DefaultLifecycleExecutor.java:556) at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:535) at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:387) at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:348) at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:180) at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:328) at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:138) at org.apache.maven.cli.MavenCli.main(MavenCli.java:362) at org.apache.maven.cli.compat.CompatibleMain.main(CompatibleMain.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.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315) at org.codehaus.classworlds.Launcher.launch(Launcher.java:255) at org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430) at org.codehaus.classworlds.Launcher.main(Launcher.java:375)

          People

          • Assignee:
            Martin Grebac
            Reporter:
            mattbishop
          • Votes:
            1 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated: