Gentlement and Ladies;
Well Folks, here is what I think was happening and how it was resolved.
I was calling the Spring code resident in jar b from code in jar a. My
inclination is that
the classpath search for the applicationContext file was done in jar a only.
To get around this, I used the following :
ApplicationContext ctx;
XmlBeanFactory factory;
InputStream is;
is=this.getClass().getResourceAsStream"/conf/applicationContext.xml");
factory = new XmlBeanFactory(new InputStreamResource(is));
mgr = (TtydoManager) factory.getBean("ttydoManager");
Interestingly, the URLResource class would as an argument for the
XmlBeanFactory constructor.
Thanks for all of the responses.
John Olmstead
Note: forwarded message attached.
John Olmstead
jolmstead2k@xxxxxxxxx
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com --- Begin Message ---
|
To: |
users@xxxxxxxxxx |
|
Subject: |
Loading Spring Application Context Bean Factory from inside a jar file. |
|
From: |
John Olmstead <jolmstead2k@xxxxxxxxx> |
|
Date: |
Wed, 14 Dec 2005 12:46:53 -0800 (PST) |
Gentlemen;
I have developed a standalone java app that uses Spring for its persistence
management layer.
The classloader will not load the application context using Springs
ClassPathXmlApplicationContext class intended for this purpose. All of the unit
tests
performed on this app pass. I have tried multiple variations of the following:
ApplicationContext
ctx = new
ClassPathXmlApplicationContext("classpath*:conf/applicationContext.xml");
//This
loads the context with 0 bean definitions.
String[] paths = {"/conf/applicationContext.xml"};
or
paths = {"/applicationContext.xml"};
ctx = new ClassPathXmlApplicationContext(paths); //This results in a
FileNotFound Exception
thrown and occurs whether or not I place the resource in the root or a sub
directory.
I'm stumped. Don't know what else to try. Any suggestions would be
appreciated and my
apologies if I missed something trivial.
By the way, the resource xml file is correctly bundled in the jar.
Thanks;
John Olmstead
John Olmstead
jolmstead2k@xxxxxxxxx
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
--- End Message ---
|