NoSuchMethodError with ActiveMQ

前端 未结 1 802
北恋
北恋 2021-01-26 21:16
java.lang.NoSuchMethodError: org.apache.activemq.thread.TaskRunnerFactory.setThreadClassLoader(Ljava/lang/ClassLoader;)V
    at org.apache.activemq.broker.BrokerService.         


        
相关标签:
1条回答
  • 2021-01-26 21:40

    There are different reasons why this error can occur:

    • You run your application with an older activemq.jar than the one you used for compiling your source
    • Your application has more jars in its classpath and one of them contains classes of activemq as well (because it's using classes for itself). If that jar is loaded before your activemq.jar (i.e. it appears "in front" of the acitvemq.jar) the older version is in use.

    If the latter, you can put the following code into your class (before the code you shown in your question) to see where the class is loaded from:

    Class clazz = TaskRunnerFactory.class;
    String name = clazz.getName().replace('.', '/') + ".class";
    String loc = clazz.getClassLoader().getResource(name).toString();
    System.out.println(loc);
    
    0 讨论(0)
提交回复
热议问题