Results 1 to 5 of 5

Thread: AnnotationConfigApplicationContext with multiple ClassLoaders

  1. #1
    Join Date
    May 2011
    Location
    Brazil
    Posts
    3

    Default AnnotationConfigApplicationContext with multiple ClassLoaders

    Hello guys,

    I'm trying to use AnnotationConfigApplicationContext within the following scenario:

    Code:
    AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext();
    ctx.setClassLoader(this.getClass().getClassLoader()); // Changes here to take ProcessConfig
    ctx.register(ProcessConfig.class);
    ctx.register(ApiConfig.class); // Exception here
    ctx.refresh();
    Where ApiConfig.class is in the thread ClassLoader:

    Thread.currentThread().getContextClassLoader();

    Is there any configuration that could be made for AnnotationConfigApplicationContext allowing it to consider both classLoaders?

    Thank you

  2. #2

    Default

    Hi,
    Did you solved this issue?

  3. #3
    Join Date
    May 2011
    Location
    Brazil
    Posts
    3

    Default

    Quote Originally Posted by Mordechai Tamam View Post
    Hi,
    Did you solved this issue?
    Hi,

    Yes it was a problem in the Classloader. During that implementation I had access to two Classloaders, due some specific proprietary API lifecycle.

    When I used the correct one, the issue was solved.

    Thanks

  4. #4

    Default

    Thanks.
    On my application, I'm facing the same issue as yours (the need to register several classes from different class loaders), since the class loader that is being used by the AnnotationConfigApplicationContext is static , a class not found exception is thrown (when the refresh method is invoked).

    On my use case, I can not change the implementation (means, I must use different class loader for each one of the classes that I register).

    Do you have a solution to offer?

  5. #5
    Join Date
    May 2011
    Location
    Brazil
    Posts
    3

    Default

    Quote Originally Posted by Mordechai Tamam View Post
    Thanks.
    On my application, I'm facing the same issue as yours (the need to register several classes from different class loaders), since the class loader that is being used by the AnnotationConfigApplicationContext is static , a class not found exception is thrown (when the refresh method is invoked).

    On my use case, I can not change the implementation (means, I must use different class loader for each one of the classes that I register).

    Do you have a solution to offer?
    For the moment I'don have anything in mind that could guide you.

    Hope another member can share some experience with us.

    Regards

Posting Permissions

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