Details

    • Type: Bug Bug
    • Status: Closed Closed
    • Priority: Blocker Blocker
    • Resolution: Fixed
    • Affects Version/s: 2.0-alpha-1
    • Fix Version/s: 2.0-alpha-3
    • Component/s: Plugin
    • Labels:
      None
    • Number of attachments :
      0

      Description

      I try to create a custom archetype-catalog.xml and use it
      "mvn archetype:create -DarchetypeCatalog=file://tmp/archetype-catalog.xml"

      but the displayed list is empty, (you could try with the https://svn.apache.org/repos/asf/maven/archetype/tags/maven-archetype-2.0-alpha-1/archetype-common/src/main/resources/archetype-catalog.xml)

      And if I copy on a http server :
      "mvn archetype:create -DarchetypeCatalog=http://scala-tools.org/"
      Then I got an exception
      java.lang.ClassCastException: org.apache.maven.archetype.catalog.ArchetypeCatalog
      at org.apache.maven.archetype.ui.DefaultArchetypeSelectionQueryer.selectArchetype(DefaultArchetypeSelectionQueryer.java:97)
      at org.apache.maven.archetype.ui.DefaultArchetypeSelector.selectArchetype(DefaultArchetypeSelector.java:179)
      at org.apache.maven.archetype.mojos.CreateProjectFromArchetypeMojo.execute(CreateProjectFromArchetypeMojo.java:165)

      It very critical, because our user can't create new project from our archetypes.

      (workaround : "mvn org.apache.maven.plugins:maven-archetype-plugin:1.0-alpha-7:create ..."

        Activity

        Hide
        David Bernard added a comment -

        May about remote custom repo :
        current code in archetype-plugin/src/main/java/org/apache/maven/archetype/ui/DefaultArchetypeSelector.java :

        while (ca.hasNext()) {
        String catalog = (String) ca.next();

        if ("internal".equalsIgnoreCase(catalog))

        { archetypes.put("internal", archetype.getInternalCatalog().getArchetypes()); }

        else if ("local".equalsIgnoreCase(catalog))

        { archetypes.put("local", archetype.getDefaultLocalCatalog().getArchetypes()); }

        else if ("remote".equalsIgnoreCase(catalog))

        { archetypes.put("remote", archetype.getRemoteCatalog().getArchetypes()); }

        else if (catalog.startsWith("file://"))

        { String path = catalog.substring(7); archetypes.put("local", archetype.getLocalCatalog(path).getArchetypes()); }

        else if (catalog.startsWith("http://"))

        { archetypes.put("remote", archetype.getRemoteCatalog(catalog)); }

        }

        should contains :
        } else if (catalog.startsWith("http://"))

        { archetypes.put("remote", archetype.getRemoteCatalog(catalog).getArchetypes()); }
        Show
        David Bernard added a comment - May about remote custom repo : current code in archetype-plugin/src/main/java/org/apache/maven/archetype/ui/DefaultArchetypeSelector.java : while (ca.hasNext()) { String catalog = (String) ca.next(); if ("internal".equalsIgnoreCase(catalog)) { archetypes.put("internal", archetype.getInternalCatalog().getArchetypes()); } else if ("local".equalsIgnoreCase(catalog)) { archetypes.put("local", archetype.getDefaultLocalCatalog().getArchetypes()); } else if ("remote".equalsIgnoreCase(catalog)) { archetypes.put("remote", archetype.getRemoteCatalog().getArchetypes()); } else if (catalog.startsWith("file://")) { String path = catalog.substring(7); archetypes.put("local", archetype.getLocalCatalog(path).getArchetypes()); } else if (catalog.startsWith("http://")) { archetypes.put("remote", archetype.getRemoteCatalog(catalog)); } } should contains : } else if (catalog.startsWith("http://")) { archetypes.put("remote", archetype.getRemoteCatalog(catalog).getArchetypes()); }
        Hide
        David Bernard added a comment -

        an other test

        • copy the custom /tmp/archetype-catalog.xml to $HOME/.m2/archetype-catalog.xml
        • run "mvn archetype:create -DarchetypeCatalog=local"
          => OK

        SO I think there is a bug with file://... and http://...

        Show
        David Bernard added a comment - an other test copy the custom /tmp/archetype-catalog.xml to $HOME/.m2/archetype-catalog.xml run "mvn archetype:create -DarchetypeCatalog=local" => OK SO I think there is a bug with file:// ... and http:// ...
        Hide
        RaphaŽl Piťroni added a comment -

        Proposition applied at revision 620348

        Show
        RaphaŽl Piťroni added a comment - Proposition applied at revision 620348
        Hide
        RaphaŽl Piťroni added a comment -

        The download of the catalog is now working.
        but beware: the goal name for calling the archetype plugin
        is now archetype:generate. we keep archetype:create for
        backward compatibility.

        Show
        RaphaŽl Piťroni added a comment - The download of the catalog is now working. but beware: the goal name for calling the archetype plugin is now archetype:generate. we keep archetype:create for backward compatibility.
        Hide
        David Legg added a comment -

        I don't think this issue is resolved.

        I've used Maven 2.0.8 and 2.0.9 on a Linux and Windows XP respectively and neither of them could download a remote archetype catalog file using http.

        A catalog file has been placed on http://cocoon.apache.org/archetype-catalog.xml

        If I run the following command: -

        mvn archetype:generate -DarchetypeCatalog=http://cocoon.apache.org/archetype-catalog.xml

        I get the following stack trace: -

        [INFO] Scanning for projects...
        [INFO] Searching repository for plugin with prefix: 'archetype'.
        [INFO] ------------------------------------------------------------------------
        [INFO] Building Maven Default Project
        [INFO] task-segment: [archetype:generate] (aggregator-style)
        [INFO] ------------------------------------------------------------------------
        [INFO] Preparing archetype:generate
        [INFO] No goals needed for project - skipping
        [INFO] Setting property: classpath.resource.loader.class => 'org.codehaus.plexus.velocity.ContextClassLoaderResourceLoader'.
        [INFO] Setting property: velocimacro.messages.on => 'false'.
        [INFO] Setting property: resource.loader => 'classpath'.
        [INFO] Setting property: resource.manager.logwhenfound => 'false'.
        [INFO] [archetype:generate]
        [INFO] Generating project in Interactive mode
        [WARNING] Error reading archetype catalog http://cocoon.apache.org/archetype-catalog.xml
        org.apache.maven.wagon.ResourceDoesNotExistException: Unable to locate resource in repository
        at org.apache.maven.wagon.providers.http.LightweightHttpWagon.fillInputData(LightweightHttpWagon.java:100)
        at org.apache.maven.wagon.StreamWagon.get(StreamWagon.java:68)
        at org.apache.maven.archetype.source.RemoteCatalogArchetypeDataSource.getArchetypeCatalog(RemoteCatalogArchetypeDataSource.java:74)
        at org.apache.maven.archetype.DefaultArchetype.getRemoteCatalog(DefaultArchetype.java:203)
        at org.apache.maven.archetype.ui.DefaultArchetypeSelector.getArchetypesByCatalog(DefaultArchetypeSelector.java:249)
        at org.apache.maven.archetype.ui.DefaultArchetypeSelector.selectArchetype(DefaultArchetypeSelector.java:74)
        at org.apache.maven.archetype.mojos.CreateProjectFromArchetypeMojo.execute(CreateProjectFromArchetypeMojo.java:180)
        at org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:451)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:558)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeStandaloneGoal(DefaultLifecycleExecutor.java:512)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:482)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:330)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:227)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:142)
        at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:336)
        at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:129)
        at org.apache.maven.cli.MavenCli.main(MavenCli.java:287)
        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)
        Caused by: java.io.FileNotFoundException: http://cocoon.apache.org/archetype-catalog.xml/archetype-catalog.xml
        at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1239)
        at org.apache.maven.wagon.providers.http.LightweightHttpWagon.fillInputData(LightweightHttpWagon.java:83)
        ... 24 more
        [INFO] No archetype defined. Using maven-archetype-quickstart (org.apache.maven.archetypes:maven-archetype-quickstart:1.0)

        I think something in Launcher.java has mangled the URL. Notice how the line that starts "Caused by: java.io.FileNotFoundException" has an extra copy of "/archetype-catalog.xml" tacked on the end?

        Show
        David Legg added a comment - I don't think this issue is resolved. I've used Maven 2.0.8 and 2.0.9 on a Linux and Windows XP respectively and neither of them could download a remote archetype catalog file using http. A catalog file has been placed on http://cocoon.apache.org/archetype-catalog.xml If I run the following command: - mvn archetype:generate -DarchetypeCatalog= http://cocoon.apache.org/archetype-catalog.xml I get the following stack trace: - [INFO] Scanning for projects... [INFO] Searching repository for plugin with prefix: 'archetype'. [INFO] ------------------------------------------------------------------------ [INFO] Building Maven Default Project [INFO] task-segment: [archetype:generate] (aggregator-style) [INFO] ------------------------------------------------------------------------ [INFO] Preparing archetype:generate [INFO] No goals needed for project - skipping [INFO] Setting property: classpath.resource.loader.class => 'org.codehaus.plexus.velocity.ContextClassLoaderResourceLoader'. [INFO] Setting property: velocimacro.messages.on => 'false'. [INFO] Setting property: resource.loader => 'classpath'. [INFO] Setting property: resource.manager.logwhenfound => 'false'. [INFO] [archetype:generate] [INFO] Generating project in Interactive mode [WARNING] Error reading archetype catalog http://cocoon.apache.org/archetype-catalog.xml org.apache.maven.wagon.ResourceDoesNotExistException: Unable to locate resource in repository at org.apache.maven.wagon.providers.http.LightweightHttpWagon.fillInputData(LightweightHttpWagon.java:100) at org.apache.maven.wagon.StreamWagon.get(StreamWagon.java:68) at org.apache.maven.archetype.source.RemoteCatalogArchetypeDataSource.getArchetypeCatalog(RemoteCatalogArchetypeDataSource.java:74) at org.apache.maven.archetype.DefaultArchetype.getRemoteCatalog(DefaultArchetype.java:203) at org.apache.maven.archetype.ui.DefaultArchetypeSelector.getArchetypesByCatalog(DefaultArchetypeSelector.java:249) at org.apache.maven.archetype.ui.DefaultArchetypeSelector.selectArchetype(DefaultArchetypeSelector.java:74) at org.apache.maven.archetype.mojos.CreateProjectFromArchetypeMojo.execute(CreateProjectFromArchetypeMojo.java:180) at org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:451) at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:558) at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeStandaloneGoal(DefaultLifecycleExecutor.java:512) at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:482) at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:330) at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:227) at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:142) at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:336) at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:129) at org.apache.maven.cli.MavenCli.main(MavenCli.java:287) 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) Caused by: java.io.FileNotFoundException: http://cocoon.apache.org/archetype-catalog.xml/archetype-catalog.xml at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1239) at org.apache.maven.wagon.providers.http.LightweightHttpWagon.fillInputData(LightweightHttpWagon.java:83) ... 24 more [INFO] No archetype defined. Using maven-archetype-quickstart (org.apache.maven.archetypes:maven-archetype-quickstart:1.0) I think something in Launcher.java has mangled the URL. Notice how the line that starts "Caused by: java.io.FileNotFoundException" has an extra copy of "/archetype-catalog.xml" tacked on the end?
        Hide
        RaphaŽl Piťroni added a comment -

        You're right,
        I remember having solved an equivalent issue.
        For now, until the fix reach a release (fixed in trunk, scheduled for 2.0-alpha-4), please use the following line:

        mvn archetype:generate -DarchetypeCatalog=http://cocoon.apache.org
        

        Please remember that in a remote catalog, any when an archetype don't define a specific repository, the
        central repository used as default URL for an archetype.

        Thanks

        Show
        RaphaŽl Piťroni added a comment - You're right, I remember having solved an equivalent issue. For now, until the fix reach a release (fixed in trunk, scheduled for 2.0-alpha-4), please use the following line: mvn archetype:generate -DarchetypeCatalog=http://cocoon.apache.org Please remember that in a remote catalog, any when an archetype don't define a specific repository, the central repository used as default URL for an archetype. Thanks
        Hide
        David Legg added a comment - - edited

        Thanks RaphaŽl.

        Actually, I like your workaround better than the original line. Not having to express the catalog name is shorter and less for a user to have to remember (or get wrong).

        I hope this behaviour will still work in 2.0-alpha-4 when it is released?

        Show
        David Legg added a comment - - edited Thanks RaphaŽl. Actually, I like your workaround better than the original line. Not having to express the catalog name is shorter and less for a user to have to remember (or get wrong). I hope this behaviour will still work in 2.0-alpha-4 when it is released?
        Hide
        RaphaŽl Piťroni added a comment -

        In fact, the both behaviour should have been made for 2.0-alpha-3, but, due to a bug,
        only the one i indicated is supported.
        I have fixed, IIRC, it for 2.0-alpha-4, to first search for provided URL to be a file, and if not append archetype-catalog.xml to it.

        RaphaŽl

        Show
        RaphaŽl Piťroni added a comment - In fact, the both behaviour should have been made for 2.0-alpha-3, but, due to a bug, only the one i indicated is supported. I have fixed, IIRC, it for 2.0-alpha-4, to first search for provided URL to be a file, and if not append archetype-catalog.xml to it. RaphaŽl

          People

          • Assignee:
            Unassigned
            Reporter:
            David Bernard
          • Votes:
            1 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: