Results 1 to 2 of 2

Thread: javaconfig with custom loadeer?

  1. #1

    Default 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. #2
    Join Date
    Apr 2007
    Posts
    307

    Default

    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
    Chris Beams
    Spring Framework committer, VMware
    http://github.com/cbeams

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •