Skip to content

Instantly share code, notes, and snippets.

@folkengine
Created November 14, 2011 21:26
Show Gist options
  • Save folkengine/1365236 to your computer and use it in GitHub Desktop.
Save folkengine/1365236 to your computer and use it in GitHub Desktop.
Grails Reading in XML
package com.limited.ss.item
import org.springframework.context.ApplicationContext
import org.springframework.context.ApplicationContextAware
import grails.converters.*
class TestService implements ApplicationContextAware {
static transactional = false
def applicationContext
def loadSampleData() {
def myfile = applicationContext.getResource("/WEB-INF/xml/sampleevents.xml").getFile().text
def xml = XML.parse(myfile)
def events = xml.event
log.info("SIZE: ${events.size()}")
return xml
}
void setApplicationContext(ApplicationContext applicationContext) {
this.applicationContext = applicationContext
}
}
@folkengine
Copy link
Author

This works when deployed to Tomcat, or Jetty, but not in a WebLogic war file. Back to the drawing board.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment