Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

HELP accessing Class Path Xml ApplicationContext in aar file

 
Darvesh Niz
Ranch Hand
Posts: 121
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,
i am using axis and my webservice is packaged as an aar file inside my axis archive. Right now i am using a startup servlet class SpringInit which implements ServiceLifeCycle and i initilize the ClassPathXmlApplicationContext when the startup method is called when the services are initialized. This is a pretty standard way of doing it as mentioned in teh axis documentation and mentoined below.

Now the issue is how can i get hold of application context in my webservice code for example generally in a normal spring app we put spring context file under WEB-INF classes folder and use singleton class such as mentioned below


If i try this code in my webservice it says applicationContext.xml file not found which is correct sicne the aar file is not packaged as regular J2ee spec. The classpathpahtxml context has to initialized using the axisSerive class loader.
Could any body tell me whats the best practice of getting hold of the application context in the webserivce code.

FYI, as of now in order for my code to work i have a static variable and i have set that varibale when the starup method initilaized the class path xml context.
Hence my new startup method has this extra code where i set teh static variable applicationContext of ProjectApplicationContext Class like this

ProjectApplicationContext.applicationContext = appCtx;

Is this correct or totally against teh code best practices and land me in trouble. Please let me knwo


Thanks
Rashid
 
Darvesh Niz
Ranch Hand
Posts: 121
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Any body please have any update on this

Thanks
 
Darvesh Niz
Ranch Hand
Posts: 121
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I will appreciate if anybody can give some input on this.
Rashid
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic