You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Russell Bateman <ru...@windofkeltia.com> on 2008/05/01 04:44:49 UTC

QuickStart example just doesn't work

Am I just broken? Nothing could be easier to download and set up, but 
walking the QuickStart 
(http://maven.apache.org/guides/getting-started/maven-in-five-minutes.html), 
I find the example simply doesn't work.

    C:\russ\dev>set
    JAVA_HOME=C:\Program Files\Java\jdk1.6.0_04
    M2=C:\Program Files\Apache Software Foundation\apache-maven-2.0.9\bin
    M2_HOME=C:\Program Files\Apache Software Foundation\apache-maven-2.0.9
    MAVEN_OPTS=-Xms256m -Xmx512m

    C:\russ\dev>mvn archetype:create -DgroupId=com.mycompany.app
    -DartifactId=my-app

    [INFO] Scanning for projects...
    [INFO] Searching repository for plugin with prefix: 'archetype'.
    [INFO]
    ------------------------------------------------------------------------
    [INFO] Building Maven Default Project
    [INFO]    task-segment: [archetype:create] (aggregator-style)
    [INFO]
    ------------------------------------------------------------------------
    [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:create]
    [WARNING] This goal is deprecated. Please use mvn archetype:generate
    instead
    [INFO] Defaulting package to group ID: com.mycompany.app
    [INFO]
    ----------------------------------------------------------------------------
    [INFO] Using following parameters for creating OldArchetype:
    maven-archetype-quickstart:RELEASE
    [INFO]
    ----------------------------------------------------------------------------
    [INFO] Parameter: groupId, Value: com.mycompany.app
    [INFO] Parameter: packageName, Value: com.mycompany.app
    [INFO] Parameter: package, Value: com.mycompany.app
    [INFO] Parameter: artifactId, Value: my-app
    [INFO] Parameter: basedir, Value: C:\russ\dev
    [INFO] Parameter: version, Value: 1.0-SNAPSHOT
    [INFO] ********************* End of debug info from resources from
    generated POM  ***********************
    [INFO] OldArchetype created in dir: C:\russ\dev\my-app
    [INFO]
    ------------------------------------------------------------------------
    [INFO] BUILD SUCCESSFUL
    [INFO]
    ------------------------------------------------------------------------
    [INFO] Total time: 3 seconds
    [INFO] Finished at: Wed Apr 30 20:24:59 MDT 2008
    [INFO] Final Memory: 8M/254M
    [INFO]
    ------------------------------------------------------------------------

    C:\russ\dev\my-app>tree
    Folder PATH listing
    Volume serial number is 0006EEA4 B0CE:6693
    C:.
    ????src
        ????main
        ?   ????java
        ?       ????com
        ?           ????mycompany
        ?               ????app
        ?                   ????App.java
        ????test
            ????java
                ????com
                    ????mycompany
                        ????app
                           ????AppTest.java

    C:\russ\dev\my-app>java -cp target/my-app-1.0-SNAPSHOT.jar
    com.mycompany.app.App

    *Exception in thread "main" java.lang.NoClassDefFoundError:
    com/mycompany/app/App*

    Caused by: java.lang.ClassNotFoundException: com.mycompany.app.App
            at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
            at java.security.AccessController.doPrivileged(Native Method)
            at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
            at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
            at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:276)
            at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
            at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)


The class is indeed there as my tree command shows, but Java can't find 
it. This problem would not happen in Eclipse as long as the code is 
there, but as it's Maven that's going to do the build eventually, it 
won't work. Or, maybe JDK 6 is broken for Maven's use.

    C:\russ\dev\my-app> java -version
    java version "1.6.0_04"
    Java(TM) SE Runtime Environment (build 1.6.0_04-b12)
    Java HotSpot(TM) Client VM (build 10.0-b19, mixed mode, sharing)



RE: QuickStart example just doesn't work

Posted by "Brian E. Fox" <br...@reply.infinity.nu>.
Looks like you missed this section:

Build the Project

mvn package

The command line will print out various actions, and end with the
following:

 ...
[INFO]
------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
[INFO]
------------------------------------------------------------------------
[INFO] Total time: 2 seconds
[INFO] Finished at: Thu Oct 05 21:16:04 CDT 2006
[INFO] Final Memory: 3M/6M
[INFO]
------------------------------------------------------------------------

Unlike the first command executed (archetype:create ) you may notice the
second is simply a single word - package . Rather than a goal, this is a
phase . A phase is a step in the build lifecycle , which is an ordered
sequence of phases. When a phase is given, Maven will execute every
phase in the sequence up to and including the one defined. For example,
if we execute the compile phase, the phases that actually get executed
are:

   1. validate
   2. generate-sources
   3. process-sources
   4. generate-resources
   5. process-resources
   6. compile



-----Original Message-----
From: Russell Bateman [mailto:russ@windofkeltia.com] 
Sent: Wednesday, April 30, 2008 10:45 PM
To: users@maven.apache.org
Subject: QuickStart example just doesn't work

Am I just broken? Nothing could be easier to download and set up, but 
walking the QuickStart 
(http://maven.apache.org/guides/getting-started/maven-in-five-minutes.ht
ml), 
I find the example simply doesn't work.

    C:\russ\dev>set
    JAVA_HOME=C:\Program Files\Java\jdk1.6.0_04
    M2=C:\Program Files\Apache Software
Foundation\apache-maven-2.0.9\bin
    M2_HOME=C:\Program Files\Apache Software
Foundation\apache-maven-2.0.9
    MAVEN_OPTS=-Xms256m -Xmx512m

    C:\russ\dev>mvn archetype:create -DgroupId=com.mycompany.app
    -DartifactId=my-app

    [INFO] Scanning for projects...
    [INFO] Searching repository for plugin with prefix: 'archetype'.
    [INFO]
 
------------------------------------------------------------------------
    [INFO] Building Maven Default Project
    [INFO]    task-segment: [archetype:create] (aggregator-style)
    [INFO]
 
------------------------------------------------------------------------
    [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:create]
    [WARNING] This goal is deprecated. Please use mvn archetype:generate
    instead
    [INFO] Defaulting package to group ID: com.mycompany.app
    [INFO]
 
------------------------------------------------------------------------
----
    [INFO] Using following parameters for creating OldArchetype:
    maven-archetype-quickstart:RELEASE
    [INFO]
 
------------------------------------------------------------------------
----
    [INFO] Parameter: groupId, Value: com.mycompany.app
    [INFO] Parameter: packageName, Value: com.mycompany.app
    [INFO] Parameter: package, Value: com.mycompany.app
    [INFO] Parameter: artifactId, Value: my-app
    [INFO] Parameter: basedir, Value: C:\russ\dev
    [INFO] Parameter: version, Value: 1.0-SNAPSHOT
    [INFO] ********************* End of debug info from resources from
    generated POM  ***********************
    [INFO] OldArchetype created in dir: C:\russ\dev\my-app
    [INFO]
 
------------------------------------------------------------------------
    [INFO] BUILD SUCCESSFUL
    [INFO]
 
------------------------------------------------------------------------
    [INFO] Total time: 3 seconds
    [INFO] Finished at: Wed Apr 30 20:24:59 MDT 2008
    [INFO] Final Memory: 8M/254M
    [INFO]
 
------------------------------------------------------------------------

    C:\russ\dev\my-app>tree
    Folder PATH listing
    Volume serial number is 0006EEA4 B0CE:6693
    C:.
    ????src
        ????main
        ?   ????java
        ?       ????com
        ?           ????mycompany
        ?               ????app
        ?                   ????App.java
        ????test
            ????java
                ????com
                    ????mycompany
                        ????app
                           ????AppTest.java

    C:\russ\dev\my-app>java -cp target/my-app-1.0-SNAPSHOT.jar
    com.mycompany.app.App

    *Exception in thread "main" java.lang.NoClassDefFoundError:
    com/mycompany/app/App*

    Caused by: java.lang.ClassNotFoundException: com.mycompany.app.App
            at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
            at java.security.AccessController.doPrivileged(Native
Method)
            at
java.net.URLClassLoader.findClass(URLClassLoader.java:188)
            at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
            at
sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:276)
            at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
            at
java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)


The class is indeed there as my tree command shows, but Java can't find 
it. This problem would not happen in Eclipse as long as the code is 
there, but as it's Maven that's going to do the build eventually, it 
won't work. Or, maybe JDK 6 is broken for Maven's use.

    C:\russ\dev\my-app> java -version
    java version "1.6.0_04"
    Java(TM) SE Runtime Environment (build 1.6.0_04-b12)
    Java HotSpot(TM) Client VM (build 10.0-b19, mixed mode, sharing)



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: QuickStart example just doesn't work

Posted by Russell Bateman <ru...@windofkeltia.com>.
You're absolutely right. Somehow I missed the mvn package command in the 
5-minute quick start stuff and I have no excuse for that.
Wow, this stuff works really well now. Thanks to both of you for this 
answer.

Russ

Wendy Smoak wrote:
> On Thu, May 1, 2008 at 11:00 AM, Wendy Smoak <ws...@gmail.com> wrote:
>
>   
>>  Creating an archetype with Maven doesn't mean it's watching to see
>>     
>
> Should be:  Creating a project from an archetype ...
>
>   

Re: QuickStart example just doesn't work

Posted by Wendy Smoak <ws...@gmail.com>.
On Thu, May 1, 2008 at 11:00 AM, Wendy Smoak <ws...@gmail.com> wrote:

>  Creating an archetype with Maven doesn't mean it's watching to see

Should be:  Creating a project from an archetype ...

-- 
Wendy

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: QuickStart example just doesn't work

Posted by Wendy Smoak <ws...@gmail.com>.
On Thu, May 1, 2008 at 10:44 AM, Russell Bateman <ru...@windofkeltia.com> wrote:
> Am I just broken? Nothing could be easier to download and set up, but
> walking the QuickStart
> (http://maven.apache.org/guides/getting-started/maven-in-five-minutes.html),
> I find the example simply doesn't work.
...
>    C:\russ\dev>mvn archetype:create -DgroupId=com.mycompany.app
>    -DartifactId=my-app
...
>    C:\russ\dev\my-app>java -cp target/my-app-1.0-SNAPSHOT.jar
>    com.mycompany.app.App

Try 'mvn install' before you try to execute it.  At least, I don't see
where you ever compiled the code and created the jar...

Creating an archetype with Maven doesn't mean it's watching to see
when things need to be compiled.  As you pointed out, that's what IDEs
do for you.

-- 
Wendy

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org