spring-loaded icon indicating copy to clipboard operation
spring-loaded copied to clipboard

Spring Data JPA NoSuchMethodError after reloading

Open rascio opened this issue 12 years ago • 7 comments

Sometimes when I modify some code, and then re-execute it I have some problems with the repositories interfaces implementation created by Spring Data JPA, ending up with exceptions like this:

java.lang.NoSuchMethodError: UtenteRepository.findOne(Ljava/io/Serializable;)Ljava/lang/Object;
at org.springsource.loaded.TypeRegistry.iincheck(TypeRegistry.java:1297)

Using:

 java version "1.7.0_21"
 Java(TM) SE Runtime Environment (build 1.7.0_21-b11)
 Java HotSpot(TM) Server VM (build 23.21-b01, mixed mode)

rascio avatar Sep 05 '13 10:09 rascio

Are you able to attach a working code sample and describe the modification you make? That'll be the quickest way to get to the root of the problem.

aclement avatar Sep 18 '13 23:09 aclement

Ok I wil try to re-create the error and post the code as soon as possible

rascio avatar Sep 19 '13 18:09 rascio

I'm trying this out on a spring roo project with jpa, and it starts just fine, but if I make a change to a jpa repository interface, it starts returning null results, even if I completely undo the change. If I restart with the query change, everything works as expected

cm325 avatar Jun 26 '14 20:06 cm325

I'm seeing this happen often, even only changing static resources / JSPs. There doesn't seem to be a specific sequence to recreate it, just seems to be luck of the draw...

dwelch2344 avatar Mar 10 '15 22:03 dwelch2344

Something interesting I just noticed about how we're seeing this error: it seems to be related with inheritance of generic interfaces and not overriding methods declarations (possibly just needing concrete types?)

For example, if we have a BaseRepository<T> interface with T findOne(..) and then a FooRepository extends BaseRepository<Foo> interface that doesn't explicitly override findOne with Foo findOne(..), the method won't be available after reloading.

But if we add the following and reload, things run smooth again:

@Override 
Foo findOne(Long aLong);

It's not just SpringData related. We're seeing it with our service tier also. I'll try to get a project up tomorrow to demonstrate.

We shouldn't need to redeclare along the way, right? If so, it means our SpringData repositories would have to explicitly specify method inherited which would kill readability (though the tooling makes it easy)

dwelch2344 avatar Mar 16 '15 15:03 dwelch2344

Suffering from same errors here. Anytime we compile, it causes springloaded to go invalid while using Spring data repository interfaces. Environment is Java 8 here.

crystoll avatar Apr 21 '15 05:04 crystoll

getting same error here after I added springloaded to my project.

java.lang.NoSuchMethodError: com.xxx.persistence.entities.Album.getImage()Lcom/echo/persistence/entities/Image; this is the line where exception happens return getAlbumImages().stream().map(AlbumImage::getImage).collect(Collectors.toList());

shredmaster avatar May 09 '15 05:05 shredmaster