简体   繁体   中英

java.lang.NoSuchMethodError , build process is broken

I've a problem with my build and it caused a huge headache for me.

I had an old class and I was using it to fetch data from it, and I created a new class with the same methods. When I test it locally on my machine, everything works fine, but when I try to do a build, it broke because it's unstable and I got this error in the log file:

Caused by: java.lang.NoSuchMethodError: com.mashvisor.bean.Neighborhood.getTraditionalRates()Lcom/mashvisor/database/dao/views/NeighborhoodRentalRates;
at com.mashvisor.database.dao.PropertyDao.retrieve(PropertyDao.java:91)

The NeighborhoodRentalRates class is the old class, and in my code I'm sure im not using it nor trying to access it in that line, here's my code for that line:

Hibernate.initialize(property.getNeighborhood().getTraditionalRates());

and here's it's declaration

public TraditionalNeighborhoodRentalRates getTraditionalRates() {
    return traditionalRates;
}

The TraditionalNeighborhoodRentalRates is the new class, and the only change here is the class name.

Could any body help?

Your code is still calling the old method, ie it is looking for a method with the signature:

public NeighborhoodRentalRates getTraditionalRates() { ... }

Just using the same names it not enough. To have classes with the same (method-)interface, you have to have the same names, return types and argument types in all methods.

So you need to go through your calling code and make sure the new type is expected everywhere as return type and recompile the calling code.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM