-3

I have a listener program that triggers a main program based on the below conditions

  1. If the database has new records
  2. If the time from last run is 10 minutes.

This is done using ScheduledExecutorService of Java (https://stackoverflow.com/a/26043250/1930402 helped out). So, I am calling a perfectly working program from this Listener, located in another Project and another Folder. That is, I am calling project B from project A. To enable this, I added a dependency of Project B in Project A's POM.xml.

There is an error in one of the classes of Project B, and it is NoSuchMethodError. I can see the method right there. From the answers of this post, https://stackoverflow.com/a/24902026/1930402, I understand that this particular class might not be there in my build path. I am not sure of this.

Can anyone advise?

Note: Project B runs without any issues when it is run independently.

Java Doc tells:

"Normally, this error is caught by the compiler; this error can only occur at run time if the definition of a class has incompatibly changed."

How can the definition of my class change while running using a static instance?

This is my stack:

         java.lang.NoSuchMethodError:a.b.c.StringUtils.formatDateToString(Ljava/lang/Object;)Ljava/lang/String;

So, these are the key points: Maven Dependency, ScheduledExecutorService, Static Class.

Community
  • 1
  • 1
pnv
  • 1,437
  • 3
  • 23
  • 52

1 Answers1

1

The reason for the error was that same class names and same package names were present in Project A and Project B and a set of other projects which were being used. Once I made each of them unique, things started working fine.

pnv
  • 1,437
  • 3
  • 23
  • 52