I finally solved this issue by using:
Class ContextAccessor{
ApplicationContext context = new
FileSystemXmlApplicationContext(this.getClass().getProtectionDomain().
getCodeSource().getLocation().getPath());
public static ApplicationContext getContext(){
return context;
}
}
Assuming the context is at ProjectB/target/classes/context.xml