Amigo111111 Amigo111111 24.Mar.10 03:57 AM a Web browser Application development8.1 (WebSphere Portal)AIX
I have problems with business component which used for composite application. I try to use spring framework in my application and want to add users in my db when in business component memberAdded method is used.
I try to get application context different methods.
accross
logger.debug("classpath*:/applicationContext.xml");
ApplicationContext applicationContext = new ClassPathXmlApplicationContext("classpath*:/applicationContext.xml");
String[] beansNames = applicationContext.getBeanDefinitionNames();
logger.debug("beans count = [" + beansNames.length + "]");
for (int index = 0; index < beansNames.length; index++) {
logger.debug("name =[" + beansNames[index] + "]");
}
logger.debug("applicationContext=[" + applicationContext + "]");
and across
classpath:/applicationContext.xml
classpath:applicationContext.xml
applicationContext.xml
but get that file is not existed.
when i try across
URL url = this.getClass().getClassLoader().getResource("applicationContext.xml");
logger.debug("url =["+url+"]"); ;
final XmlBeanFactory factory = new XmlBeanFactory(new UrlResource(url));
String[] beansNames = factory.getBeanDefinitionNames();
logger.debug("beans count = [" + beansNames.length + "]");
for (int index = 0; index < beansNames.length; index++) {
logger.debug("name =[" + beansNames[index] + "]");
}
logger.debug("applicationContext=[" + factory + "]");
get exception
org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 4 in XML document from URL is invalid; nested exception is org.xml.sax.SAXParseException: cvc-elt.1: Cannot find the declaration of element 'beans'.
but i can use my application.xml in main method without exceptions.
i try to save servletcontext in singleton class and get in in business component. Across servletContext i get applicationContext. It work. But when i restart application, i get nullpointerexception.
I don't understand how business component work. It seems than it use old code of classes.