Question

I am developing a spring command line app and working fine in Eclipse. However in command line I am getting the following error;

Exception in thread "main" org.springframework.beans.factory.BeanDefinitionStore
Exception: Unrecognized xbean namespace mapping: http://www.springframework.org/
schema/aop
    at org.apache.xbean.spring.context.v2c.XBeanNamespaceHandler.parseBeanFromExtensionElement(XBeanNamespaceHandler.java:284)
    at org.apache.xbean.spring.context.v2c.XBeanNamespaceHandler.parse(XBeanNamespaceHandler.java:156)
    at org.apache.xbean.spring.context.v2.XBeanNamespaceHandler.parse(XBeanNamespaceHandler.java:49)
    at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseCustomElement(BeanDefinitionParserDelegate.java:1419)
    at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseCustomElement(BeanDefinitionParserDelegate.java:1409)
    at org.apache.xbean.spring.context.v2.XBeanBeanDefinitionDocumentReader.parseBeanDefinitions(XBeanBeanDefinitionDocumentReader.java:84)
    at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.doRegisterBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:140)
    at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.registerBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:111)
    at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.registerBeanDefinitions(XmlBeanDefinitionReader.java:493)
    at org.apache.xbean.spring.context.v2.XBeanXmlBeanDefinitionReader.registerBeanDefinitions(XBeanXmlBeanDefinitionReader.java:79)

Code:

import org.apache.xbean.spring.context.ClassPathXmlApplicationContext;
import org.springframework.context.support.AbstractApplicationContext;
import org.springframework.stereotype.Component;

@Component
public class SpringCommandLine {

private static final String APP_CONTEXT_PATH = "classpath:/BatchClientBeans.xml";

public static void main(String[] args) {

    AbstractApplicationContext context = new     ClassPathXmlApplicationContext(APP_CONTEXT_PATH);
    context.registerShutdownHook();

    BatchClientDAO batchClientDAOBean = (BatchClientDAO) context.getBean("batchClientDAOBean");
    System.out.println("Next batch ID: " + batchClientDAOBean.getNextBatchId());

    System.out.println("Exiting...");

}

}

My beans configuration file is as follows;

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:camel="http://camel.apache.org/schema/spring"
xsi:schemaLocation="
    http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
">

 <bean id="batchClientDAOBean" class="com.test.data_analysis.client.BatchClientDAOImpl">
    <property name="sqlMapClientTemplate" ref="sqlMapClientTemplateLocal" />
</bean>
</beans>  

Any help would be greatly appreciated.

Was it helpful?

Solution

Looks like you have wrong import:

import org.apache.xbean.spring.context.ClassPathXmlApplicationContext;

but should be:

import org.springframework.context.support.ClassPathXmlApplicationContext;
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top