maven-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Petter Måhlén (JIRA) <>
Subject [jira] Commented: (ARCHETYPE-329) StringIndexOutOfBoundsException when generating archetype for multi-module project
Date Mon, 27 Sep 2010 12:06:33 GMT


Petter Måhlén commented on ARCHETYPE-329:

I've worked around the problem by changing the name of the directory in question to something
that isn't a substring, so I cannot justify spending the time to do that, I'm afraid. I hope
you have enough information to fix it despite that lack.

> StringIndexOutOfBoundsException when generating archetype for multi-module project
> ----------------------------------------------------------------------------------
>                 Key: ARCHETYPE-329
>                 URL:
>             Project: Maven Archetype
>          Issue Type: Bug
>          Components: Archetypes
>    Affects Versions: 2.0-alpha-5
>            Reporter: Petter Måhlén
> Given an archetype setup with the following multi-module archetype resources structure:
> {noformat} 
> ROOT - pom.xml
>      - container-test - pom.xml (this should be a sub-module in the resulting project)
>                       - container (a directory)
> {noformat} 
> The archetype:generate goal fails in the getOutputFile method, with the following exception:
> {noformat} 
> org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-archetype-plugin:2.0-alpha-5:generate
(default-cli) on project standalone-pom: String index out of range: -9
> 	at org.apache.maven.lifecycle.internal.MojoExecutor.execute(
> 	at org.apache.maven.lifecycle.internal.MojoExecutor.execute(
> 	at org.apache.maven.lifecycle.internal.MojoExecutor.execute(
> 	at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(
> 	at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(
> 	at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(
> 	at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(
> 	at org.apache.maven.DefaultMaven.doExecute(
> 	at org.apache.maven.DefaultMaven.execute(
> 	at org.apache.maven.cli.MavenCli.execute(
> 	at org.apache.maven.cli.MavenCli.doMain(
> 	at org.apache.maven.cli.MavenCli.main(
> 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> 	at sun.reflect.NativeMethodAccessorImpl.invoke(
> 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(
> 	at java.lang.reflect.Method.invoke(
> 	at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(
> 	at org.codehaus.plexus.classworlds.launcher.Launcher.launch(
> 	at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(
> 	at org.codehaus.plexus.classworlds.launcher.Launcher.main(
> Caused by: org.apache.maven.plugin.MojoFailureException: String index out of range: -9
> 	at org.apache.maven.archetype.mojos.CreateProjectFromArchetypeMojo.execute(
> 	at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(
> 	at org.apache.maven.lifecycle.internal.MojoExecutor.execute(
> 	... 19 more
> {noformat} 
> The CreateProjectFromArchetypeMojo hides the stack trace of the underlying exception
(this should be fixed, too, I think), but by adding debug information to the mojo in a couple
of places, and enabling debug logging, I was able to get the following trace:
> {noformat} 
> [DEBUG] Processing module container-test
> [DEBUG] Processing module rootArtifactId newArtifact
> [DEBUG] Processing module pom /Users/pettermahlen/tmp/newArtifact/container-test/pom.xml
> [DEBUG] Processing module moduleOffset container-test
> [DEBUG] Processing module outputDirectoryFile /Users/pettermahlen/tmp/newArtifact/container-test
> [DEBUG] Processing fileset project moduleId container-test
> [DEBUG] Processing fileset project pom /Users/pettermahlen/tmp/newArtifact/container-test/pom.xml
> [DEBUG] Processing fileset project moduleOffset container-test
> [DEBUG] Processing fileset project outputDirectoryFile /Users/pettermahlen/tmp/newArtifact/container-test
> [DEBUG] Processing fileset project basedirPom /Users/pettermahlen/tmp/newArtifact/pom.xml
> [DEBUG] Processing pom /Users/pettermahlen/tmp/newArtifact/container-test/pom.xml with
parent /Users/pettermahlen/tmp/newArtifact/pom.xml
> [DEBUG] Prosessing template archetype-resources/container-test/pom.xml
> [DEBUG] Merging into /Users/pettermahlen/tmp/newArtifact/container-test/pom.xml
> [DEBUG] Adding module container-test
> [INFO] Parent element not overwritten in /Users/pettermahlen/tmp/newArtifact/container-test/pom.xml
> [DEBUG] Processing filesets
> getOutputFile(container-test, container, /Users/pettermahlen/tmp/newArtifact/container-test,
false, group, container-test, org.apache.velocity.VelocityContext@390e4fd7)
> java.lang.StringIndexOutOfBoundsException: String index out of range: -9
> 	at java.lang.String.substring(
> 	at java.lang.String.substring(
> 	at org.apache.maven.archetype.generator.DefaultFilesetArchetypeGenerator.getOutputFile(
> 	at org.apache.maven.archetype.generator.DefaultFilesetArchetypeGenerator.processTemplates(
> 	at org.apache.maven.archetype.generator.DefaultFilesetArchetypeGenerator.processArchetypeTemplates(
> 	at org.apache.maven.archetype.generator.DefaultFilesetArchetypeGenerator.processFilesetProject(
> 	at org.apache.maven.archetype.generator.DefaultFilesetArchetypeGenerator.processFilesetModule(
> 	at org.apache.maven.archetype.generator.DefaultFilesetArchetypeGenerator.processFilesetModule(
> 	at org.apache.maven.archetype.generator.DefaultFilesetArchetypeGenerator.generateArchetype(
> 	at org.apache.maven.archetype.generator.DefaultArchetypeGenerator.processFileSetArchetype(
> 	at org.apache.maven.archetype.generator.DefaultArchetypeGenerator.generateArchetype(
> 	at org.apache.maven.archetype.generator.DefaultArchetypeGenerator.generateArchetype(
> 	at org.apache.maven.archetype.generator.DefaultArchetypeGenerator.generateArchetype(
> 	at org.apache.maven.archetype.DefaultArchetypeManager.generateProjectFromArchetype(
> {noformat} 
> The cause of the problem seems to be that the directory name ('container') is a substring
of the moduleOffset parameter, which eventually causes the following call to be illegal:
>                 + templateName.substring( moduleOffset.length() );
> I would have included a fix, but I don't understand what this code is doing, so I can't
really do that. Hopefully this should be enough information to solve the problem, though.
Also, it would be great to give some better error reporting by not catching Exception and
swallowing it, I think.

This message is automatically generated by JIRA.
If you think it was sent incorrectly contact one of the administrators:
For more information on JIRA, see:


View raw message