spring-loaded
spring-loaded copied to clipboard
Spring Data JPA NoSuchMethodError after reloading
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)
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.
Ok I wil try to re-create the error and post the code as soon as possible
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
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...
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)
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.
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());