• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Getting Datasource from ApplicationContext.xml from standalone application

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,

I am writing one standalone java class, which will in turn access services and dao which are in the spring framework.
I used the ClassPathXmlApplicationContect to access the appContext.
My app is deployed in weblogic server and I successfully got the appContext using the following code.



As of now for development purpose, our applicationContext.xml have datasource entry like shown below.


which I know is a bad practice to give username and password in the xml directly.
So I created one JNDI and altered the applicationContext.xml as :



Now the problem is that when I try to initialize the appcontext using ClassPathXmlApplicationContext its failing saying cannot create datasource.
I feel somehow that I need to give the server name and port number to initialize but donno how.

Please help me as my standalone cannot be run without this. But, the web application is running fine.

Happy Coding,
Anoop
 
Ranch Hand
Posts: 159
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Can't the container handle the connection pool? (I'm assuming not, since your application is a standalone).
If yes, you can get the dataSource this way:
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic