org.springframework.beans.factory.BeanDefinitionStoreException: Unexpected exception parsing XML document from file [C:/temp/tempworkspace/test-handler2/src/main/webapp/WEB-INF/spring/app-config.xml]; nested exception is java.lang.RuntimeException: Failed to load class from classpath

Spring JIRA | Mike Youngstrom | 7 years ago
  1. 0

    When I enable "Load NamespaceHandlers and XSDs from project's classpath" SpringIDE successfully loads my custom NamespaceHandlers from the classpath. However, when the custom handler is executed by SpringIDE it fails to find any classes sourced in the current project. This only happens if the NamespaceHandler is loaded as a .jar project dependency. I've attached a testcase. To duplicate do the following. 1. unzip custom.zip 2. run mvn clean install on custom.zip 3. unzip test-handler.zip 4. import test-handler into eclipse using a maven->import existing project When app-config.xml is processed by springIDE it will throw the following exception: [code] org.springframework.beans.factory.BeanDefinitionStoreException: Unexpected exception parsing XML document from file [C:/temp/tempworkspace/test-handler2/src/main/webapp/WEB-INF/spring/app-config.xml]; nested exception is java.lang.RuntimeException: Failed to load class from classpath at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:412) at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:334) at org.springframework.ide.eclipse.beans.core.internal.model.BeansConfig$2.loadBeanDefinitions(BeansConfig.java:371) at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:302) at org.springframework.ide.eclipse.beans.core.internal.model.BeansConfig$3.call(BeansConfig.java:414) at org.springframework.ide.eclipse.beans.core.internal.model.BeansConfig$3.call(BeansConfig.java:1) at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303) at java.util.concurrent.FutureTask.run(FutureTask.java:138) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441) at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303) at java.util.concurrent.FutureTask.run(FutureTask.java:138) at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) at java.lang.Thread.run(Thread.java:619) Caused by: java.lang.RuntimeException: Failed to load class from classpath at org.test.handler.CustomParser.parse(CustomParser.java:15) at org.springframework.beans.factory.xml.NamespaceHandlerSupport.parse(NamespaceHandlerSupport.java:73) at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseCustomElement(BeanDefinitionParserDelegate.java:1335) at org.springframework.ide.eclipse.beans.core.internal.model.BeansConfig$ErrorSuppressingBeanDefinitionParserDelegate.parseCustomElement(BeansConfig.java:1244) at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseCustomElement(BeanDefinitionParserDelegate.java:1325) at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.parseBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:136) at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.registerBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:93) at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.registerBeanDefinitions(XmlBeanDefinitionReader.java:493) at org.springframework.ide.eclipse.beans.core.internal.model.BeansConfig$2.registerBeanDefinitions(BeansConfig.java:384) at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:390) ... 13 more Caused by: java.lang.ClassNotFoundException: org.test.handler.WelcomeController at java.net.URLClassLoader$1.run(URLClassLoader.java:202) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:190) at java.lang.ClassLoader.loadClass(ClassLoader.java:307) at java.lang.ClassLoader.loadClass(ClassLoader.java:248) at org.springframework.util.ClassUtils.forName(ClassUtils.java:258) at org.test.handler.CustomParser.parse(CustomParser.java:13) ... 22 more [/code] Alternatively if you import custom project into the same eclipse workspace then everything works great. It is only a problem when the custom NamespaceHandler is loaded as a dependent .jar.

    Spring JIRA | 7 years ago | Mike Youngstrom
    org.springframework.beans.factory.BeanDefinitionStoreException: Unexpected exception parsing XML document from file [C:/temp/tempworkspace/test-handler2/src/main/webapp/WEB-INF/spring/app-config.xml]; nested exception is java.lang.RuntimeException: Failed to load class from classpath
  2. 0

    When I enable "Load NamespaceHandlers and XSDs from project's classpath" SpringIDE successfully loads my custom NamespaceHandlers from the classpath. However, when the custom handler is executed by SpringIDE it fails to find any classes sourced in the current project. This only happens if the NamespaceHandler is loaded as a .jar project dependency. I've attached a testcase. To duplicate do the following. 1. unzip custom.zip 2. run mvn clean install on custom.zip 3. unzip test-handler.zip 4. import test-handler into eclipse using a maven->import existing project When app-config.xml is processed by springIDE it will throw the following exception: [code] org.springframework.beans.factory.BeanDefinitionStoreException: Unexpected exception parsing XML document from file [C:/temp/tempworkspace/test-handler2/src/main/webapp/WEB-INF/spring/app-config.xml]; nested exception is java.lang.RuntimeException: Failed to load class from classpath at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:412) at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:334) at org.springframework.ide.eclipse.beans.core.internal.model.BeansConfig$2.loadBeanDefinitions(BeansConfig.java:371) at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:302) at org.springframework.ide.eclipse.beans.core.internal.model.BeansConfig$3.call(BeansConfig.java:414) at org.springframework.ide.eclipse.beans.core.internal.model.BeansConfig$3.call(BeansConfig.java:1) at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303) at java.util.concurrent.FutureTask.run(FutureTask.java:138) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441) at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303) at java.util.concurrent.FutureTask.run(FutureTask.java:138) at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) at java.lang.Thread.run(Thread.java:619) Caused by: java.lang.RuntimeException: Failed to load class from classpath at org.test.handler.CustomParser.parse(CustomParser.java:15) at org.springframework.beans.factory.xml.NamespaceHandlerSupport.parse(NamespaceHandlerSupport.java:73) at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseCustomElement(BeanDefinitionParserDelegate.java:1335) at org.springframework.ide.eclipse.beans.core.internal.model.BeansConfig$ErrorSuppressingBeanDefinitionParserDelegate.parseCustomElement(BeansConfig.java:1244) at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseCustomElement(BeanDefinitionParserDelegate.java:1325) at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.parseBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:136) at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.registerBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:93) at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.registerBeanDefinitions(XmlBeanDefinitionReader.java:493) at org.springframework.ide.eclipse.beans.core.internal.model.BeansConfig$2.registerBeanDefinitions(BeansConfig.java:384) at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:390) ... 13 more Caused by: java.lang.ClassNotFoundException: org.test.handler.WelcomeController at java.net.URLClassLoader$1.run(URLClassLoader.java:202) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:190) at java.lang.ClassLoader.loadClass(ClassLoader.java:307) at java.lang.ClassLoader.loadClass(ClassLoader.java:248) at org.springframework.util.ClassUtils.forName(ClassUtils.java:258) at org.test.handler.CustomParser.parse(CustomParser.java:13) ... 22 more [/code] Alternatively if you import custom project into the same eclipse workspace then everything works great. It is only a problem when the custom NamespaceHandler is loaded as a dependent .jar.

    Spring JIRA | 7 years ago | Mike Youngstrom
    org.springframework.beans.factory.BeanDefinitionStoreException: Unexpected exception parsing XML document from file [C:/temp/tempworkspace/test-handler2/src/main/webapp/WEB-INF/spring/app-config.xml]; nested exception is java.lang.RuntimeException: Failed to load class from classpath
  3. 0

    graph-builder error downloading osm

    GitHub | 4 years ago | robertoferraz
    java.lang.ClassNotFoundException: org.opentripplanner.graph_builder.openstreetmap.impl.RegionBasedOpenStreetMapProviderImpl
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    Bean Creation Exception with JBoss 5.1.2

    Stack Overflow | 3 years ago | ajit kumar
    org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [com.abc.myapp.cmc.infrastructure.util.CustomPropertyPlaceholderConfigurer] for bean with name 'applicationPropertyConfigurer' defined in ServletContext resource [/WEB-INF/spring-config/applicationContext.xml]; nested exception is java.lang.ClassNotFoundException: com.abc.myapp.cmc.infrastructure.util.CustomPropertyPlaceholderConfigurer
  6. 0

    Failed to load applicationContext: NoSuchBeanDefinitionException when running JUnit test in Spring MVC app

    Stack Overflow | 6 years ago | Soroush Hakami
    org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [com.mchange.v2.c3p0.ComboPooledDataSource] for bean with name 'dataSource' defined in class path resource [db-config.xml]; nested exception is java.lang.ClassNotFoundException: com.mchange.v2.c3p0.ComboPooledDataSource

  1. kid 84 times, last 8 months ago
  2. archenroot 1 times, last 1 week ago
  3. tyson925 5 times, last 2 weeks ago
  4. tzrlk 1 times, last 2 weeks ago
  5. musketyr 1 times, last 2 weeks ago
63 more registered users
31 unregistered visitors
Not finding the right solution?
Take a tour to get the most out of Samebug.

Tired of useless tips?

Automated exception search integrated into your IDE

Root Cause Analysis

  1. java.lang.ClassNotFoundException

    org.test.handler.WelcomeController

    at java.net.URLClassLoader$1.run()
  2. Java RT
    ClassLoader.loadClass
    1. java.net.URLClassLoader$1.run(URLClassLoader.java:202)
    2. java.security.AccessController.doPrivileged(Native Method)
    3. java.net.URLClassLoader.findClass(URLClassLoader.java:190)
    4. java.lang.ClassLoader.loadClass(ClassLoader.java:307)
    5. java.lang.ClassLoader.loadClass(ClassLoader.java:248)
    5 frames
  3. Spring Core
    ClassUtils.forName
    1. org.springframework.util.ClassUtils.forName(ClassUtils.java:258)
    1 frame
  4. org.test.handler
    CustomParser.parse
    1. org.test.handler.CustomParser.parse(CustomParser.java:13)
    1 frame
  5. Spring Beans
    BeanDefinitionParserDelegate.parseCustomElement
    1. org.springframework.beans.factory.xml.NamespaceHandlerSupport.parse(NamespaceHandlerSupport.java:73)
    2. org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseCustomElement(BeanDefinitionParserDelegate.java:1335)
    2 frames
  6. org.springframework.ide
    BeansConfig$ErrorSuppressingBeanDefinitionParserDelegate.parseCustomElement
    1. org.springframework.ide.eclipse.beans.core.internal.model.BeansConfig$ErrorSuppressingBeanDefinitionParserDelegate.parseCustomElement(BeansConfig.java:1244)
    1 frame
  7. Spring Beans
    XmlBeanDefinitionReader.registerBeanDefinitions
    1. org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseCustomElement(BeanDefinitionParserDelegate.java:1325)
    2. org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.parseBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:136)
    3. org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.registerBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:93)
    4. org.springframework.beans.factory.xml.XmlBeanDefinitionReader.registerBeanDefinitions(XmlBeanDefinitionReader.java:493)
    4 frames
  8. org.springframework.ide
    BeansConfig$2.registerBeanDefinitions
    1. org.springframework.ide.eclipse.beans.core.internal.model.BeansConfig$2.registerBeanDefinitions(BeansConfig.java:384)
    1 frame
  9. Spring Beans
    XmlBeanDefinitionReader.loadBeanDefinitions
    1. org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:390)
    2. org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:334)
    2 frames
  10. org.springframework.ide
    BeansConfig$2.loadBeanDefinitions
    1. org.springframework.ide.eclipse.beans.core.internal.model.BeansConfig$2.loadBeanDefinitions(BeansConfig.java:371)
    1 frame
  11. Spring Beans
    XmlBeanDefinitionReader.loadBeanDefinitions
    1. org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:302)
    1 frame
  12. org.springframework.ide
    BeansConfig$3.call
    1. org.springframework.ide.eclipse.beans.core.internal.model.BeansConfig$3.call(BeansConfig.java:414)
    2. org.springframework.ide.eclipse.beans.core.internal.model.BeansConfig$3.call(BeansConfig.java:1)
    2 frames
  13. Java RT
    Thread.run
    1. java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
    2. java.util.concurrent.FutureTask.run(FutureTask.java:138)
    3. java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)
    4. java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
    5. java.util.concurrent.FutureTask.run(FutureTask.java:138)
    6. java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
    7. java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
    8. java.lang.Thread.run(Thread.java:619)
    8 frames