users
[Top] [All Lists]

Fwd: Loading Spring Application Context Bean Factory from inside a jar f

To: users@xxxxxxxxxx
Subject: Fwd: Loading Spring Application Context Bean Factory from inside a jar file.
From: John Olmstead <jolmstead2k@xxxxxxxxx>
Date: Thu, 15 Dec 2005 09:52:10 -0800 (PST)
Delivered-to: mailing list users@cinjug.org
Domainkey-signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; h=Message-ID:Received:Date:From:Subject:To:MIME-Version:Content-Type:Content-Transfer-Encoding; b=E4ZISzBsIKKVss8JDrWl6a6hp2C5FNC5P/7jZMzZb/rRA1kaG0hJxH2v06KhHA1OKrXdgQSI+8m4Wj3PnGAC76nPYMFJjwfVnxhr2w4l0zZtSpUMSwl35EOPHdxjpY4YiTJRqCAaNLPYNXcuNV+RC6To+3Lvh+vUv/onxmREkak= ;
Mailing-list: contact users-help@cinjug.org; run by ezmlm
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 ---
<Prev in Thread] Current Thread [Next in Thread>