Announcement Announcement Module
Collapse

JavaConfig forum decommissioned in favor of Core Container

As described at

http://static.springsource.org/sprin...fig/README.TXT

key features of the Spring JavaConfig project have been migrated into the core Spring Framework as of version 3.0.

Please see the Spring 3.0 documentation on @Configuration and @Bean support:

http://static.springsource.org/sprin...tml#beans-java

For any questions related to @Configuration classes and @Bean methods in Spring 3.0, please post in the dedicated 'Core Container' forum at

http://forum.springsource.org/forumdisplay.php?f=26
See more
See less
javaconfig with custom loadeer? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • javaconfig with custom loadeer?

    Hi,

    I would like to create a springcontainer using javaconfig with a custom class loader. This is what I've tried:
    Code:
      System.err.println(RnaCompoundDBConfig.class.getName());
            
            JavaConfigApplicationContext applicationContext = new JavaConfigApplicationContext();
    
            // here I set my custom classloader which is url-class loader
            applicationContext.setClassLoader(this.getClass().getClassLoader());
            applicationContext.addConfigClass(RnaCompoundDBConfig.class);
            applicationContext.refresh();
    However I get an exception when doing the refresh:

    Code:
    java.io.FileNotFoundException: Class file [de/mpicbg/tds/rm/hcstools/RnaCompoundDBConfig.class] not found). Check the log messages... (ProcessThread.run())
      java.lang.RuntimeException: java.io.FileNotFoundException: Class file [de/mpicbg/tds/rm/hcstools/RnaCompoundDBConfig.class] not found
          org.springframework.config.java.internal.parsing.asm.AsmUtils.getClassAsStream(AsmUtils.java:98)
          org.springframework.config.java.internal.factory.support.AsmJavaConfigBeanDefinitionReader.loadBeanDefinitions(AsmJavaConfigBeanDefinitionReader.java:69)
          org.springframework.config.java.internal.process.InternalConfigurationPostProcessor.parseAnyConfigurationClasses(InternalConfigurationPostProcessor.java:128)
          org.springframework.config.java.internal.process.InternalConfigurationPostProcessor.postProcessBeanFactory(InternalConfigurationPostProcessor.java:76)
          org.springframework.config.java.context.JavaConfigApplicationContext.invokeBeanFactoryPostProcessors(JavaConfigApplicationContext.java:121)
          org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:362)
          de.mpicbg.tds.rm.hcstools.AnnotateRNAScreen.setupService(AnnotateRNAScreen.java:50)
    The AsmUtils seem to ignore my custom classloader. What could be my mistake?

    Any help is appreciated.

    Best, Holger

  • #2
    First, strongly consider using Spring 3.0 and its AnnotationConfigApplicationContext. It replaces the JavaConfig project and its JavaConfigApplicationContext.

    Second, this will probably be a hard limitation of the way that things work right now. ASM is assuming that the class is loadable as a classpath resource. If you're fetching it via a URL, that violates the assumption.

    Add an issue for this in JIRA if you like. It's conceivable that we could accommodate this, because at the end of the day ASM really just needs an input stream.

    http://jira.springframework.org/browse/SPR

    Comment

    Working...
    X