One Star

Can't load Spring context in Talend ESB Runtime

What I am doing: I'm using an external JAR library made with Spring, through a tJavaFlex component. I've created a Routine with my own method and library that is loading my application context this way:
public String customMethod(){
ApplicationContext ap = new ClassPathXmlApplicationContext("classpath:/META-INF/spring/application-context.xml");
CustomInterface test = (CustomInterface) ap.getBean("customClass");

return test.businessMethod();
}

My application-context.xml looks like this one:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns=""
      xmlns:xsi=""
      xmlns:context=""
      xmlns:mvc=""
      xsi:schemaLocation="
                         
                          ">
   <!-- Spring IoC Context -->
   <context:component-scan base-package="com.test" />
   <import resource="root-config.xml" />
   <import resource="classpath:/root-context.xml" />
   <!-- Enables the Spring MVC @Controller programming model -->
   <mvc:annotation-driven />
</beans>

the tJavaFlex component is inside a Job that is called from a Route.
If I run this on my Talend Open Studio ESB it works.
My problem: from the mediation perspective, I right-click on my route and build it, so I can deploy inside my Runtimefolder/container/deploy.
But when I use my route from my container it doesn't work! It looks like it can't load the application-context.xml file, giving me an exception like it can't find a bean named "customClass".
Is it because the "classpath" is differend in the built kar file? How can I fix this?
2 REPLIES
One Star

Re: Can't load Spring context in Talend ESB Runtime

Route already contains own Spring config (Spring view at Mediation perspective). You can extend it as you wish.
One Star

Re: Can't load Spring context in Talend ESB Runtime

Route already contains own Spring config (Spring view at Mediation perspective). You can extend it as you wish.

I'm using a Routine not a Route...