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

  • Handling ClassNotFound Exception at startup

    Hello,

    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 tils.java:201)
    at org.springframework.beans.factory.support.Abstract BeanDefinition.resolveBeanClass(AbstractBeanDefini tion.java:327)
    at org.springframework.beans.factory.support.Abstract BeanFactory.resolveBeanClass(AbstractBeanFactory.j ava:1066)
    at org.springframework.beans.factory.support.DefaultL istableBeanFactory.preInstantiateSingletons(Defaul tListableBeanFactory.java:282)
    at org.springframework.context.support.AbstractApplic ationContext.refresh(AbstractApplicationContext.ja va:352)
Working...
X