maven-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Herve Boutemy (JIRA)" <j...@codehaus.org>
Subject [jira] Commented: (ARCHETYPE-329) StringIndexOutOfBoundsException when generating archetype for multi-module project
Date Fri, 24 Sep 2010 17:59:32 GMT

    [ http://jira.codehaus.org/browse/ARCHETYPE-329?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=236398#action_236398
] 

Herve Boutemy commented on ARCHETYPE-329:
-----------------------------------------

can you attach a test case to the issue, please?

> StringIndexOutOfBoundsException when generating archetype for multi-module project
> ----------------------------------------------------------------------------------
>
>                 Key: ARCHETYPE-329
>                 URL: http://jira.codehaus.org/browse/ARCHETYPE-329
>             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(MojoExecutor.java:148)
> 	at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:87)
> 	at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:79)
> 	at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:86)
> 	at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:58)
> 	at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
> 	at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
> 	at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:252)
> 	at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:100)
> 	at org.apache.maven.cli.MavenCli.execute(MavenCli.java:443)
> 	at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:166)
> 	at org.apache.maven.cli.MavenCli.main(MavenCli.java:130)
> 	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.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290)
> 	at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230)
> 	at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409)
> 	at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352)
> Caused by: org.apache.maven.plugin.MojoFailureException: String index out of range: -9
> 	at org.apache.maven.archetype.mojos.CreateProjectFromArchetypeMojo.execute(CreateProjectFromArchetypeMojo.java:205)
> 	at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:110)
> 	at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:144)
> 	... 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(String.java:1937)
> 	at java.lang.String.substring(String.java:1904)
> 	at org.apache.maven.archetype.generator.DefaultFilesetArchetypeGenerator.getOutputFile(DefaultFilesetArchetypeGenerator.java:315)
> 	at org.apache.maven.archetype.generator.DefaultFilesetArchetypeGenerator.processTemplates(DefaultFilesetArchetypeGenerator.java:691)
> 	at org.apache.maven.archetype.generator.DefaultFilesetArchetypeGenerator.processArchetypeTemplates(DefaultFilesetArchetypeGenerator.java:451)
> 	at org.apache.maven.archetype.generator.DefaultFilesetArchetypeGenerator.processFilesetProject(DefaultFilesetArchetypeGenerator.java:562)
> 	at org.apache.maven.archetype.generator.DefaultFilesetArchetypeGenerator.processFilesetModule(DefaultFilesetArchetypeGenerator.java:497)
> 	at org.apache.maven.archetype.generator.DefaultFilesetArchetypeGenerator.processFilesetModule(DefaultFilesetArchetypeGenerator.java:526)
> 	at org.apache.maven.archetype.generator.DefaultFilesetArchetypeGenerator.generateArchetype(DefaultFilesetArchetypeGenerator.java:211)
> 	at org.apache.maven.archetype.generator.DefaultArchetypeGenerator.processFileSetArchetype(DefaultArchetypeGenerator.java:136)
> 	at org.apache.maven.archetype.generator.DefaultArchetypeGenerator.generateArchetype(DefaultArchetypeGenerator.java:106)
> 	at org.apache.maven.archetype.generator.DefaultArchetypeGenerator.generateArchetype(DefaultArchetypeGenerator.java:149)
> 	at org.apache.maven.archetype.generator.DefaultArchetypeGenerator.generateArchetype(DefaultArchetypeGenerator.java:209)
> 	at org.apache.maven.archetype.DefaultArchetypeManager.generateProjectFromArchetype(DefaultArchetypeManager.java:71)
> {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: http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

       

Mime
View raw message