"No fragment found for method" when hotswaping JpaRepository class

246 views
Skip to first unread message

Jeff D

unread,
Nov 15, 2021, 12:31:57 PM11/15/21
to HotswapAgent
Hello,

I am experiencing a problem when using DCEVM and Hotswap Agent with Spring Boot and specifically Spring Data JPA.

When I try to add a method to a JpaRepository interface and then call that method with a REST API call I'm getting an exception:

 org.springframework.dao.InvalidDataAccessApiUsageException: No fragment found for method public abstract java.util.List net...server.repo.PersonRepository.findPersons(java.lang.String,java.lang.String)

I have attached the full stacktrace as a separate file. 

I'm using dcevm-11.0.11+1, which is the build that is bundled with the Hotswap Agent jar.  PersonRepository is the name of my interface and it extends JpaRepository.  "findPersons" is the method that I added.  The interface existed before the app server was started and the method was added while the app server was running.

Questions:
1. Am I doing something wrong or is this a known issue?
2. Is this something that one of the Hotswap Agents should address, if not now, potentially in the future?
3. Should I submit a bug for this?

I did a little research and the problem seems to be the that RepositoryComposition is not able to find the new method.  It first looks in a local cache, and if it doesn't find it executes this method:

private static Method findMethod(InvokedMethod invokedMethod, MethodLookup lookup,
                                 Supplier<Stream<Method>> methodStreamSupplier) {

    for (MethodPredicate methodPredicate : lookup.getLookups()) {

        Optional<Method> resolvedMethod = methodStreamSupplier.get()
                .filter(it -> methodPredicate.test(invokedMethod, it)) //
                .findFirst();

        if (resolvedMethod.isPresent()) {
            return resolvedMethod.get();
        }
    }

    return null;
}

Maybe this method can't find it because it's loaded by a separate class loader?  I don't know much about DCEVM and Hotswap Agent architecture so probably this question is very incorrect.

Anyway, thank you for your time.

Technical details:
Hotswap agent:  1.4.1
Spring Boot (spring-boot-starter-data-jpa) version:  2.5.5
JDK version:  OpenJDK Runtime Environment AdoptOpenJDK-dcevm-11.0.11+1-202105021746 (build 11.0.11+1-202105021746)
JVM version:  Dynamic Code Evolution 64-Bit Server VM AdoptOpenJDK-dcevm-11.0.11+1-202105021746 (build 11.0.11+1-202105021746, mixed mode)

no-fragment-found.txt
Reply all
Reply to author
Forward
0 new messages