Uploaded image for project: 'Spring Roo'
  1. Spring Roo
  2. ROO-120 Support multi module Maven projects
  3. ROO-2883

Last step of scaffolding multi-module Roo project fails with wrong webmvc-config.xml detection

    Details

    • Type: Sub-task
    • Status: Resolved
    • Priority: Major
    • Resolution: Cannot Reproduce
    • Affects Version/s: 1.2.0.RC1
    • Fix Version/s: 1.2.0.RC1
    • Component/s: WEB MVC
    • Labels:
      None

      Description

      When I use this script:

      project --topLevelPackage org.chariot.multimodule.demo --projectName multi-module
      module create --moduleName business-tier --topLevelPackage ~.business 
      module focus --moduleName ~
      module create --moduleName web-tier --topLevelPackage ~.web
       
      module focus --moduleName business-tier
      jpa setup --database HYPERSONIC_PERSISTENT --provider HIBERNATE 
      entity jpa --class ~.model.Course --activeRecord false
      field string --fieldName name
      repository jpa --interface ~.orm.CourseRepository --entity ~.model.Course
      service --interface ~.service.CourseService --entity ~.model.Course
       
      module focus --moduleName ~
      module focus --moduleName web-tier
      web mvc setup
      web mvc scaffold --class ~.controller.CourseController --backingType business-tier|~.model.Course
      business-tier|~.model.Course roo> 

      I get this exception with the current trunk build as of the spring-roo-1.2.0.BUILD-SNAPSHOT_20111108.053941-75f95ca.zip snapshot and pulling / building Roo from trunk. It appears that the scaffold fails because it is attempting to add the converters to the business project, not the web one. It then sets the focus of the shell to the business tier.

      Is this a bug, or something you're working on in-flight that I'm seeing not completely sewn up in trunk?

      Thanks,

      Ken

      roo> module focus --moduleName web-tier
      web-tier roo> web mvc scaffold --class web-tier|~.controller.CourseController --backingType business-tier|~.model.Course
      '/Users/krimple/roo_demos/demos/multi-module/business-tier/src/main/webapp/WEB-INF/spring/webmvc-config.xml' does not exist
      java.lang.IllegalArgumentException: '/Users/krimple/roo_demos/demos/multi-module/business-tier/src/main/webapp/WEB-INF/spring/webmvc-config.xml' does not exist
          at org.springframework.roo.support.util.Assert.isTrue(Assert.java:65)
          at org.springframework.roo.addon.web.mvc.controller.WebMvcOperationsImpl.installConversionService(WebMvcOperationsImpl.java:71)
          at org.springframework.roo.addon.web.mvc.controller.ControllerOperationsImpl.createAutomaticController(ControllerOperationsImpl.java:120)
          at org.springframework.roo.addon.web.mvc.controller.ControllerCommands.webMvcScaffold(ControllerCommands.java:115)
          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.springframework.roo.support.util.ReflectionUtils.invokeMethod(ReflectionUtils.java:191)
          at org.springframework.roo.process.manager.ProcessManagerHostedExecutionStrategy$1.callback(ProcessManagerHostedExecutionStrategy.java:49)
          at org.springframework.roo.process.manager.internal.DefaultProcessManager.doTransactionally(DefaultProcessManager.java:183)
          at org.springframework.roo.process.manager.internal.DefaultProcessManager.execute(DefaultProcessManager.java:146)
          at org.springframework.roo.process.manager.ProcessManagerHostedExecutionStrategy.execute(ProcessManagerHostedExecutionStrategy.java:47)
          at org.springframework.roo.shell.AbstractShell.executeCommand(AbstractShell.java:204)
          at org.springframework.roo.shell.jline.JLineShell.promptLoop(JLineShell.java:403)
          at org.springframework.roo.shell.jline.JLineShell.run(JLineShell.java:158)
          at java.lang.Thread.run(Thread.java:680)

        Activity

        Hide
        stewarta Alan Stewart added a comment -

        No errors now, and provided that --packaging POM is added to the project command above, this is behaving as expected. Note without the --packaging option, a "src" directory is created in the root directory, which is to be expected. I believe this ticket can be closed.

        Show
        stewarta Alan Stewart added a comment - No errors now, and provided that --packaging POM is added to the project command above, this is behaving as expected. Note without the --packaging option, a "src" directory is created in the root directory, which is to be expected. I believe this ticket can be closed.
        Hide
        krimple Ken Rimple added a comment -

        I will check on my end tonight, unless I find something new I would agree. I saw the POM behavior - nice!

        Show
        krimple Ken Rimple added a comment - I will check on my end tonight, unless I find something new I would agree. I saw the POM behavior - nice!
        Hide
        aswan Andrew Swan added a comment -

        I've tried to reproduce Ken's problem as well, and can't do so either.

        @Javier, "perform eclipse" won't work on a newly-created multi-module web project because the web module (in your case "mercurius-web") has a dependency on some "business" module (in your case "mercurius-codes") that doesn't yet exist in your local repository. So the Eclipse plugin is trying to add to the web module's classpath a JAR file that hasn't even been created yet. This is not a Roo-specific problem; the same thing happens if you quit Roo and type "mvn eclipse:clean eclipse:eclipse" (first making sure that there's not an old copy of the business JAR in your local M2 repository). The solution (as you found) is to ensure that all of your modules' dependencies are available via the Maven artifact resolution mechanism before you run the Eclipse plugin, which in the case of your business modules means that they have already been deployed to your local repository. You can do this per module if you prefer (by running "mvn install" in each one's directory), or you can do it for the whole project (easier but slower) in one line like this:

        mvn install eclipse:clean eclipse:eclipse

        Or you can use the m2e plugin, which seems to have better and better support for AspectJ each time I use it.

        Show
        aswan Andrew Swan added a comment - I've tried to reproduce Ken's problem as well, and can't do so either. @Javier, " perform eclipse " won't work on a newly-created multi-module web project because the web module (in your case " mercurius-web ") has a dependency on some "business" module (in your case " mercurius-codes ") that doesn't yet exist in your local repository. So the Eclipse plugin is trying to add to the web module's classpath a JAR file that hasn't even been created yet. This is not a Roo-specific problem; the same thing happens if you quit Roo and type "mvn eclipse:clean eclipse:eclipse" (first making sure that there's not an old copy of the business JAR in your local M2 repository). The solution (as you found) is to ensure that all of your modules' dependencies are available via the Maven artifact resolution mechanism before you run the Eclipse plugin, which in the case of your business modules means that they have already been deployed to your local repository. You can do this per module if you prefer (by running "mvn install" in each one's directory), or you can do it for the whole project (easier but slower) in one line like this: mvn install eclipse:clean eclipse:eclipse Or you can use the m2e plugin, which seems to have better and better support for AspectJ each time I use it.
        Hide
        aswan Andrew Swan added a comment -

        Closing this ticket as it doesn't happen in the current revision.

        Show
        aswan Andrew Swan added a comment - Closing this ticket as it doesn't happen in the current revision.
        Hide
        jbbarquero Javier Beneito Barquero added a comment -

        Thank you very much Andrew,

        Your instructions worked well in that test project and I'm using them now for a production project.

        Kind regards.

        Show
        jbbarquero Javier Beneito Barquero added a comment - Thank you very much Andrew, Your instructions worked well in that test project and I'm using them now for a production project. Kind regards.

          People

          • Assignee:
            aswan Andrew Swan
            Reporter:
            krimple Ken Rimple
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: