Announcement Announcement Module
Collapse
No announcement yet.
AnnotationConfigApplicationContext with multiple ClassLoaders Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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
    Hi,
    Did you solved this issue?

    Comment


    • #3
      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

      Comment


      • #4
        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?

        Comment


        • #5
          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

          Comment

          Working...
          X