0
votes

I have a grails app and the groovy under /src/groovy has import statements for Java POI HSSF for example

import org.apache.poi.hssf.usermodel.HSSFWorkbook
import org.apache.poi.hssf.usermodel.HSSFCellStyle

What is the best way to add POI to my grails app so its deployed with the war. I tried adding the jars to /lib and then adding them as runtime dependencies in BuilConfig.groovy.

dependencies {
     runtime 'mysql:mysql-connector-java:5.1.22'
     runtime 'poi-3.9-20121203'
     runtime 'poi-ooxml-3.9'
     runtime 'poi-ooxml-schemas-3.9'
     runtime 'xml-apis-ext-1.3.04'
     runtime 'xmlbeans-2.3.0'
     runtime 'xmlpull-1.1.3.1'
     runtime 'xstream-1.4.7'
}

I also tried adding it as a compile plugin this way

plugins {
        runtime ":hibernate:3.6.10.13"       
        compile ":excel-import:1.0.0"
}

Both generate this error on grails war

java.lang.NoClassDefFoundError: _GrailsClasspath_groovy$_run_closure1

EDIT: my repositories has maven but still complains about missing class def Read jars from lib folder in grails

1

1 Answers

4
votes

While adding any dependency or plugin in Grails, maven artifact semantics has to be followed instead if the plain jar name. For example,

runtime 'xmlbeans-2.3.0'

should be

runtime 'org.apache.xmlbeans:xmlbeans:2.3.0'

which corresponds to

runtime '<groupId>:<artifactId>:<version>'

Same is applicable for all the other dependencies and plugins. Rewrite those one by one and remove all jars from lib directory. Clean and compile the app subsequently.