Tuesday, March 20, 2012

The quest for the upgrade continues ...

After my last post, I was confident that things would go smoothly, having assumed that those were the most deceptive issues I would encounter.  Sadly, that was not at all the case.  Upon doing a mvn install on the command line, I got this error:
(Listing 1)
|Loading Grails 2.0.1
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 7.298s
[INFO] Finished at: Sat Mar 17 19:22:13 EDT 2012
[INFO] Final Memory: 20M/81M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.grails:grails-maven-plugin:2.0.1:exec (default-cli) on project caffiendFrog-webapp-service: Unable to start Grails: java.lang.reflect.InvocationTargetException: Provider for javax.xml.parsers.SAXParserFactory cannot be found -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException

A quick google search for the error, in various combinations of keywords, didn't produce anything that helped.  I turned to the footnote in the error, which suggests an article that may help.  It basically says that there is something wrong with your pom.xml file, specifically some configuration is done correctly or something else is wrong.  It's a rather general article, but it did help in that I was able to focus my efforts digging through my pom.xml.

Here are some red-herrings (i.e. false leads) that I tried:

  • The message mentions something about my grails-maven-plugin, so I spent a lot of time commenting out various bits of it.  
  • Tried a mvn clean install and got a similar message, only instead of (default-cli), I got (default clean).
  • And many more combinations of commenting things and searching for the plugin's information online to see if my configurations were incorrect.
As a last ditch effort, I created 2 dummy test applications, using the grails instructions for creating a maven-ized project, to take a look at their poms.  Up until now, I had assumed that most of the stuff in my pom.xml was stuff we had intentionally put in there (keep in mind as I said, it's been awhile and I can't remember what we added and what grails put in for us).  So I created a blank project using Grails version 1.3.7 and a blank project using Grails 2.0.1.   And lo and behold ... the poms are very different indeed:
Given the vast difference, what I did next was:
  1. Compare our original (v1.3.7) pom.xml to the generated one above.
  2. Noted the differences between them, these difference would be items that we had put in.
    • i.e. We added an additional exclusion to the dependencies from org.grails:
    • (Listing 2)
      
         jcl-over-slf4j
         org.slf4j
       
    • i.e.We had an additional dependency in our original file:
    • (Listing 3)
      
       org.slf4j
       jcl-over-slf4j
       ${slf4j-version}
      
      
    • i.e. We had a "hack" in place to synchronize the app.version in Grail's application.properties file with the version in our POM. See MAVEN-79 and MAVEN-128, as well as an additional execution in our configuration of the grails-maven-plugin:
    • (Listing 4)
      
       org.grails
       grails-maven-plugin
       ${grails-version}
       true
       
        
        
         sync-versions
         validate
         
          set-version
         
        
        
        
         grails-clean
         clean
         
          set-version
          clean
         
        
        
       
       
  3. Changed the pom.xml to look like the v2.0.1 (i.e. the dependencies, plugins, repos, etc.)
  4. Inserted the differences into the new pom.xml.
    • i.e. Inserting the additional exclusion from Listing 2, note that in the v2.0.1 pom.xml, there is only one dependency to org.grails and it contains none of the exclusions that were listed in v1.3.7:
    • (Listing 2a)
      
       
       org.grails
       grails-dependencies
       ${grails-version}
       pom
        
        
         jcl-over-slf4j
         org.slf4j
        
        
      
      
    • i.e. Added in our additional dependency:
    • (Listing 3a)
      
       
       org.slf4j
       jcl-over-slf4j
       ${slf4j-version}
      
      
    • i.e. Upon further investigation, the tickets have been resolved and the hack is no longer needed. Inserted the additional execution into our new plugin definition:
    • (Listing 4a)
      
       org.grails
       grails-maven-plugin
       ${grails-version}
       true
       
        
        
         grails-clean
         clean
         
          set-version
          clean
         
        
        
       
      
      
You get the idea.

Some other things to note:

  • The plugin JAXRS & Hibernate have a dependencies on org.restlet*.  This is no longer available via maven central.  You will need to add:
mavenRepo "http://maven.restlet.org"
    To your BuildConfig.groovy file and/or your pom.xml file as an external repository.
  • I initially had trouble getting the archetype for v2.0.1.  For some reason the command mvn archetype:generate just would not pick up the new version, even though it is there and available.  To resolve this, I trashed my .m2 folder and when the dependencies were pulled in, it pulled in the new version of the archetype.
As always, I think there were some issues I ran across, but at the moment I can't think of them.  Also, at this point, the upgrade still isn't complete, and I'm getting errors, but at least the errors seem to be related to the code and possible re-naming and re-factoring that occurred in the new version.

1 comment: