A new topic, 'Spring configurations when using a WAR', has been made on a board
you are watching.
You can see it at
http://liquibase.org/forum/index.php?topic=365.new#new
The text of the topic is shown below:
Hello all,
I'm in the process of creating a CustomTaskChange that calls some common
services we use. All of the hooks for that are already configured in spring as
part of our web application. The idea is that we would package our migration
in the war file and using the war file classpath option in from the command
line, we would wire our migration with spring. However we've run into a snag.
I've tried two different ways to load the context with no luck:
1. Using ApplicationContext context = new ClassPathXmlApplicationContext( new
String[] { "someDir/applicationContext.xml" });
In this approach, I get that the applicationContext.xml is not found. I
have cracked open the war file to confirm that the file does live at
mywar/WEB-INF/classes/someDir/applicationContext.xml.
2. Using a FileOpener to get a resource as stream and use an
XmlBeanDefinitionReader to load the configuration from there. The issue I'm
having here is that our applicationContext.xml is really nothing more than
a bunch of <import resource... tags that reference other files.
Here I get an exception that resources cannot be loaded via an InputStream
with relative paths. The code for this approach looks like this:
GenericApplicationContext context = new GenericApplicationContext();
XmlBeanDefinitionReader xmlReader = new XmlBeanDefinitionReader(context);
xmlReader.setValidationMode(0);
try {
InputStream is = fileOpener
.getResourceAsStream("someDir/applicationContext.xml");
xmlReader.loadBeanDefinitions(new InputStreamResource(is));
} catch (Exception e) {
// do some logging here
}
context.refresh();
Am I missing something or is this something that can't be done with this
approach? Thanks in advance for any help!
Michael
Unsubscribe to new topics from this board by clicking here:
http://liquibase.org/forum/index.php?action=notifyboard;board=1.0
Regards,
The LiquiBase Community Forum Team.------------------------------------------------------------------------------
Download Intel® Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
Liquibase-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/liquibase-user