4 Replies Latest reply on Feb 19, 2010 6:03 PM by tothc

    EJB 3.0 tutorial build problem with Maven 2.2.1

    tothc

      In advance: I'm new to Maven and JBoss also.

       

      Windows 7 64 bit

      Maven 2.2.1

      EJB 3.0 tutorial

       

      I want to start with the first example, the stateless bean.

      First I got FATAL errors. Googled it and turned out that I had to add this

      "  <repositories>
          <repository>
            <id>jboss-repo</id>
            <url>http://repository.jboss.org/maven2/</url>
          </repository>
        </repositories>"

       

      to the pom.xml of the stateless example. Note: does this mean that I have to do this modification to every freakin' example's pom.xml???

      After adding this to the xml the build command seemed to work, it downloaded gazillions of pom (?) files to somewhere (??? I couldn't find where, I could just read the source, the webpage address it downloaded from).

       

      But unfortunately I got an ERROR from a WARNING. Searching for this warning in google gives just one result in a blog, which doesn't solve my problem. So I would appreciate some help. Thanks.

       

      "$EJB3_TUTORIAL_HOME\source\stateless>mvn clean install -e -PRunSingleTutorial

      + Error stacktraces are turned on.
      [INFO] Scanning for projects...
      [INFO] ------------------------------------------------------------------------
      [INFO] Building EJB3.0 Stateless Bean Tutorial
      [INFO]    task-segment: [clean, install]
      [INFO] ------------------------------------------------------------------------
      [INFO] [clean:clean {execution: default-clean}]
      [INFO] [enforcer:enforce {execution: enforce-banned-dependencies}]
      [WARNING] Rule 1: org.apache.maven.plugins.enforcer.RequireMavenVersion failed with message:
      Detected Maven Version: 2.2.1 is not in the allowed range [2.0.9,2.1).
      [INFO] ------------------------------------------------------------------------
      [ERROR] BUILD ERROR
      [INFO] ------------------------------------------------------------------------
      [INFO] Some Enforcer rules have failed. Look above for specific messages explaining why the rule failed.
      [INFO] ------------------------------------------------------------------------
      [INFO] Trace
      org.apache.maven.lifecycle.LifecycleExecutionException: Some Enforcer rules have failed. Look above for specific messages explaining why the rule failed.
          at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:719)
          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)
      Caused by: org.apache.maven.plugin.MojoExecutionException: Some Enforcer rules have failed. Look above for specific messages explaining why the rule failed.
          at org.apache.maven.plugins.enforcer.EnforceMojo.execute(EnforceMojo.java:218)
          at org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:490)
          at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:694)
          ... 17 more
      [INFO] ------------------------------------------------------------------------
      [INFO] Total time: 6 seconds
      [INFO] Finished at: Fri Feb 19 11:35:48 CST 2010
      [INFO] Final Memory: 70M/295M
      [INFO] ------------------------------------------------------------------------
      "

        • 1. Re: EJB 3.0 tutorial build problem with Maven 2.2.1
          jaikiran

          tothc wrote:

           


          [WARNING] Rule 1: org.apache.maven.plugins.enforcer.RequireMavenVersion failed with message:
          Detected Maven Version: 2.2.1 is not in the allowed range [2.0.9,2.1).

          This error states that the Maven version which you are using (2.2.1) is not allowed for the project you are building (the tutorials). Within the tutorial pom.xml file we have set this restriction. The tutorials have been tested using Maven 2.0.9. The only reason why we added a upper limit to the Maven version is because we of our experience with Maven issues with every new Maven version. It doesn't mean the the tutorial will not work against Maven 2.2.1, it just means we haven't tested it agains that version and hence don't know if it's going to run into issues.

           

          You'll have to downgrade to Maven 2.0.9 (atleast for now) to get that running. But i think it makes sense to remove that restriction from the tutorials. I'll create a JIRA for that and fix it.

           

          tothc wrote:

           


          I want to start with the first example, the stateless bean.

          First I got FATAL errors. Googled it and turned out that I had to add this

          "  <repositories>
              <repository>
                <id>jboss-repo</id>
                <url>http://repository.jboss.org/maven2/</url>
              </repository>
            </repositories>"

           

          to the pom.xml of the stateless example. Note: does this mean that I have to do this modification to every freakin' example's pom.xml???

          Maven works on the concept of "repositories" where it searches for dependent published artifacts. Any project like the tutorial you are building can depend on these published artifacts. The project has to point Maven to the right repositories. This can be done in two ways:

          1) Either set it in the pom.xml (hierarchy) of the project you are building

          OR 2) Set in a global Maven settings.xml file (like explained here http://community.jboss.org/wiki/MavenSettings)

           

          You don't have set it in every pom.xml. Either set it in the Maven settings.xml file or set it in TUTORIAL_HOME/build/pom.xml. Again, i think this should have been done in the tutorials by default so that users don't have to change it themselves. I'll create a JIRA for this too.

           

          tothc wrote:

           


          After adding this to the xml the build command seemed to work, it downloaded gazillions of pom (?) files to somewhere (??? I couldn't find where, I could just read the source, the webpage address it downloaded from).

           

          That's expected from Maven. As i explained earlier, Maven downloads the dependencies of projects from repositories. So if project A depends on project B, then while building project A, Maven downloads project B to your local file system. Project B internally might depend on project C, so this will lead to a long chain of transitive dependency downloads. So the first time you build a prooject through Maven it usually takes time to download all those dependencies. Once they are downloaded to your local file system, they won't be downloaded the next time.

           

           

          By the way, if you are running into trouble with Maven and instead are more interested in just seeing EJB3 in action, then you can alternatively use the Ant approach of building the tutorials (which is explained in the tutorial docs).

          • 3. Re: EJB 3.0 tutorial build problem with Maven 2.2.1
            tothc

            Thank you jaikiran for your detailed and kind reply!

             

            I've made modification to the global Maven settings.xml as described in http://community.jboss.org/wiki/MavenSettings (advised by jaikiran).

             

            For those who are in the same situation as me I'll describe what I did so far to overcome the issue.

            On Windows (at least on Windows 7, but I assume on other Windows version too) Maven's repository can be found in Users\${username}\.m2\repository . Maven downloaded 150 MBs (!!!) of stuff (jar files and build configurations) there.

            I searched for "[2.0.9,2.1)" in there, and found 5 pom files containing it in the form of "c:\Users\${username}\.m2\repository\org\jboss\ejb3\jboss-ejb3-build\1.0.x\jboss-ejb3-build-1.0.x.pom" where x=0, 1, 2, etc. I modified it to "[2.0.9,)", make sure that you modify the value of RequireMavenVersion tags.

             

            Now it almost builds, but it cannot start the JBossAS now. I might follow up later about that. Have to inspect that.

            • 4. Re: EJB 3.0 tutorial build problem with Maven 2.2.1
              tothc