Quantcast

Grails maven dependency management for inherited plugins

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Grails maven dependency management for inherited plugins

Alam Sher
I have a grails plugin with following BuildCofnig.groovy

    grails.project.class.dir = "target/classes"
    grails.project.test.class.dir = "target/test-classes"
    grails.project.test.reports.dir = "target/test-reports"
    //grails.project.war.file = "target/${appName}-${appVersion}.war"
    grails.project.dependency.resolution = {
        // inherit Grails' default dependencies
        inherits("global") {
   
        }
   
        log "warn" // log level of Ivy resolver, either 'error', 'warn', 'info', 'debug' or 'verbose'
        repositories {
            grailsPlugins()
            grailsHome()
            mavenCentral()
            mavenLocal()
            mavenRepo "http://repository.codehaus.org"
            flatDir name: 'lib', dirs: "${userHome}/libs"
        }
   
        dependencies {
   
            runtime('mysql:mysql-connector-java:5.1.9')
   
            compile('net.sf.jasperreports:jasperreports:4.0.1') {
                excludes 'antlr', 'commons-beanutils', 'commons-collections', 'commons-logging',
                         'ant', 'mondrian', 'commons-javaflow', 'barbecue', 'xml-apis-ext', 'xml-apis', 'xalan', 'groovy', 'groovy-all', 'hibernate', 'saaj-api', 'servlet-api',
                         'xercesImpl', 'xmlParserAPIs', 'spring-core', 'bsh', 'spring-beans', 'jaxen', 'barcode4j', 'batik-svg-dom', 'batik-xml', 'batik-awt-util', 'batik-dom',
                         'batik-css', 'batik-gvt', 'batik-script', 'batik-svggen', 'batik-util', 'batik-bridge', 'persistence-api', 'jdtcore', 'bcmail-jdk14', 'bcprov-jdk14', 'bctsp-jdk14'
            }
            compile('vomsws:VomsWsClient:1.0')
            compile('com.jaxfront:jaxfront-core:1.0',
                    'com.jaxfront:jaxfront-html:1.0')
            compile('freemarker:freemarker:2.3.8')
            compile('org.apache.poi:poi:3.6')
            compile('commons-net:commons-net:3.0')
            compile('commons-httpclient:commons-httpclient:3.1')
        }
    }


I can pacakge plugin successfully. However when I import this plugin in a fresh Grails project and try to do run-app. I get following exception stacktrace:

      [groovyc] Compiling 452 source files to C:\Users\Alam Sher\.grails\1.3.2\projects\witribe-test-gui\plugin-classes
    : java.lang.NoClassDefFoundError: org/apache/xerces/xni/parser/XMLParseException
       
at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:116)
        at _GrailsCompile_groovy$_run_closure4_closure10.doCall(_GrailsCompile_groovy:118)
        ...........
    Caused by: java.lang.NoClassDefFoundError: org/apache/xerces/xni/parser/XMLParseException
    .......

    Caused by: java.lang.ClassNotFoundException: org.apache.xerces.xni.parser.XMLParseException
       
at org.codehaus.groovy.tools.RootLoader.findClass(RootLoader.java:156)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
        at org.codehaus.groovy.tools.RootLoader.loadClass(RootLoader.java:128)
    ........

    --- Nested Exception ---
    java.lang.NoClassDefFoundError: org/apache/xerces/xni/parser/XMLParseException
        at java.lang.Class.getDeclaredFields0(Native Method)
    ........
   
   Caused by: java.lang.ClassNotFoundException: org.apache.xerces.xni.parser.XMLParseException
        at org.codehaus.groovy.tools.RootLoader.findClass(RootLoader.java:156)
   ......
    Compilation error: java.lang.NoClassDefFoundError: org/apache/xerces/xni/parser/XMLParseException


Kind of lost what's the problem here.. Frankly speaking I'm new to this dependency management using Maven and have no clue what so ever.

Your suggestions, recommendations are welcome.


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Grails maven dependency management for inherited plugins

anders
Just ran across your issue in search for the answer to a similar question.

Don't know if you have found the answer in the meantime, but judging from the error message, it could be  related to your "excludes ... 'xercesImpl'... " statement.

- org/apache/xerces/xni/parser/XMLParseException is part of 'xercesImpl', and it seems like it is needed at runtime.
So might be worth trying to remove this exclusion  or alternatively, (depending on what your reasons are for excluding it in the first place,) add it as a separate runtime dependency : runtime('xerces:xercesImpl:X.X.X'),  where X.X.X should be substituted with the correct version.

- Another time you have similar issues with ClassNotFoundException's a good place to search for the right dependency can be:http://www.jarvana.com/jarvana/ (just enter the full name of the class that cannot be found)

Hope this will be helpful to you - or someone else :-)

Anders

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Grails maven dependency management for inherited plugins

pledbrook
> Don't know if you have found the answer in the meantime, but judging from
> the error message, it could be  related to your "excludes ...
> 'xercesImpl'... " statement.
>
> - org/apache/xerces/xni/parser/XMLParseException is part of 'xercesImpl',
> and it seems like it is needed at runtime.

For future reference, we strongly recommend that 'xml-apis' and
'xmlParserAPIs' are excluded from dependencies that include them.
'xercesImpl' is fine though.

--
Peter Ledbrook
Grails Advocate
SpringSource - A Division of VMware

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Loading...