javaee / jaxb-v2

Other
211 stars 100 forks source link

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

Open glassfishrobot opened 15 years ago

glassfishrobot commented 15 years ago

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

When I define the 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.

[http://bobj-rs.sap.com/2009/08](http://bobj-rs.sap.com/2009/08) bobj-rs.xsd

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] ------------------------------------------------------------------------

Environment

Operating System: All Platform: All

Affected Versions

[2.1.12]

glassfishrobot commented 15 years ago

Reported by mattbishop

glassfishrobot commented 15 years ago

drampulla@java.net said: 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.

glassfishrobot commented 15 years ago

drampulla@java.net said: Just adding self to the CC list.

glassfishrobot commented 15 years ago

snajper said: 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.

glassfishrobot commented 12 years ago

basiliv said: I've got the same issue. When I don't define 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"?>

When I do define 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)
glassfishrobot commented 15 years ago

Was assigned to snajper

glassfishrobot commented 7 years ago

This issue was imported from java.net JIRA JAXB-676