Announcement Announcement Module
No announcement yet.
Weblogic (Timer) Classpath Problem Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Weblogic (Timer) Classpath Problem


    I'm experiencing FileNotFound Exceptions from ClassPathXmlApplicationContext.

    My app is packaged with some APP-INF entries and a war file.

    The web-app initializes a weblogic timer (timer listener packaged in the war)

    When the timer listener fires it is throwing the FileNotFoundExceptions.

    I've tried the Spring config files in a variety of location (all derivatives of APP-INF/META-INF/WEB-INF - both root and classes).

    I read somewhere that Spring uses the context classloader for the current thread. If this is a weblogic timer thread - might this be the system classloader - which is why the file is not found?

    How do I go about changing the classloader that Spring uses to look up the resources?


  • #2

    I managed to resolve using the following BeanFactory initialization:

    factory = new DefaultListableBeanFactory();

    XmlBeanDefinitionReader reader= new XmlBeanDefinitionReader(factory);

    ClassPathResource resource1 = new ClassPathResource( "spring-service.xml" , Registrar.class.getClassLoader() );

    ClassPathResource resource2 = new ClassPathResource( "spring-data-mediator.xml" , Registrar.class.getClassLoader() );

    ClassPathResource resource3 = new ClassPathResource( "spring-dao.xml" , Registrar.class.getClassLoader() );

    ClassPathResource resource4 = new ClassPathResource( "spring-config.xml" , Registrar.class.getClassLoader() );

    reader.loadBeanDefinitions( resource1 );
    reader.loadBeanDefinitions( resource2 );
    reader.loadBeanDefinitions( resource3 );
    reader.loadBeanDefinitions( resource4 );

    I think the trick being that my "Registrar" class is packaged up in the WAR, and the xml config files are stored under WEB-INF/classes - so even though it's a Weblogic Execute Thread (loaded via the system classloader) that's executing, the factory still has beans loaded via the web-app classpath.

    I also changed my bean factory to be a true singleton....which could well have an impact....