I\'m developing a desktop application in java using spring and hibernate. I want to package it as a executable jar but I\'m having problems loading the context configuration XML
I suppose you want to run your application as java -jar myapp.jar
In this case, use class ClassPathXmlApplicationContext within your class with the method main.
public static void main( String[] args ) {
String config[] = { "spring-beans.xml" };
ApplicationContext ctx = new ClassPathXmlApplicationContext(config);
DataSource ds = (DataSource) ctx.getBean("dataSource", DataSource.class);
}
It's a terrible idea to try to implement your own ApplicationContext. That's too much work and too much room for errors.