Announcement Announcement Module
No announcement yet.
Handling ClassNotFound Exception at startup Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Handling ClassNotFound Exception at startup


    Is their a way in spring to handle a ClassNotFoundException when I am loading a Spring Context. I have several applications that load the same Spring Config file from a database and this behavior can be expected as I do not want to create a circular dependency in my codebase. I would like to be able to not have to resolve all bean definitions at initialization. I tried lazy loading these beans however that seemed to cause issues with jms and active mq.

    Here is a snippet of the code. I would like this code to not fail if I encounter a ClassNotFoundException for some bean definitions.

    ByteArrayResource myByteArrayResource =
    new ByteArrayResource(unloadedCategoryContextMap.get (aContextKey).getBytes());

    // first load from xml configured from database
    XmlBeanDefinitionReader myXmlReader1 = new XmlBeanDefinitionReader( myContext );
    myXmlReader1.loadBeanDefinitions( myByteArrayResource );

    Here is a snippet from the stack trace.

    at org.springframework.util.ClassUtils.forName(ClassU
    at BeanDefinition.resolveBeanClass(AbstractBeanDefini
    at BeanFactory.resolveBeanClass(AbstractBeanFactory.j ava:1066)
    at istableBeanFactory.preInstantiateSingletons(Defaul
    at ationContext.refresh(AbstractApplicationContext.ja va:352)