Skip to content

ClassPathSkillSource discovers no skills in Spring Boot executable JARs #1895

In review

Description

@zhangxiangnan

Describe the bug

ClassPathSkillSource("skills/") silently discovers no skills when the application runs through Spring Boot's executable-JAR launcher. The same skill files are readable through the thread context classloader, and discovery works when the same classes and dependencies are placed on an ordinary classpath.

This also reproduces with a plain URLClassLoader containing a jar:file:...!/ root, so it is not a model/provider issue.

Environment

  • Official main: b2572c1b3955ae6950b712e865abc082403aa084 (1.15.1-SNAPSHOT), built locally without downstream patches for the baseline.
  • Java 21.0.9, macOS arm64.
  • Spring Boot loader 4.0.2; Guava 33.0.0-jre from ADK core's dependencies.
  • No model, API key, application server or Golem code is involved in the reproducer below.

Expected and observed behavior

The fixture includes app-skill under BOOT-INF/classes/skills/ and library-skill in BOOT-INF/lib/library-skills.jar.

Launch Direct classloader reads ADK discovery
Ordinary java -cp Both SKILL.md files readable Both skills found
Boot java -jar Both SKILL.md files readable Empty map

Boot output on unmodified main:

loader=org.springframework.boot.loader.launch.LaunchedClassLoader
directRead[app-skill]=70
directRead[library-skill]=74
adkSkills=[]
Caused by: java.lang.AssertionError: Expected both application and nested-library skills

Cause

scanClassPath() relies exclusively on Guava ClassPath.from(classLoader). Guava scans file: classpath roots, while Boot's LaunchedClassLoader exposes jar:nested:...!/ roots. Resource reading works, but those roots are not included in discovery.

Steps to reproduce

From a checkout of the commit above, build core and save its classes, then obtain the official Boot loader:

mvn -f core/pom.xml -Dtest=ClassPathSkillSourceTest test
jar --create --file /tmp/adk-core.jar -C core/target/classes .
mvn dependency:get -Dartifact=org.springframework.boot:spring-boot-loader-tools:4.0.2
python3 reproducer.py \
  --core-jar /tmp/adk-core.jar \
  --classpath-report core/target/surefire-reports/TEST-com.google.adk.skills.ClassPathSkillSourceTest.xml \
  --expect-boot-failure

Save the script below as reproducer.py. It packages a real Boot executable JAR using the official loader distributed in spring-boot-loader-tools, launches both modes in separate JVMs and asserts the exact discovery failure. It also exercises instructions and nested resource listing/reading in the successful mode. All fixture files are written to a temporary directory; the checkout is not modified. The nested skill library deliberately has no directory entries.

Standalone reproducer (Python 3)
from pathlib import Path
import argparse,io,json,os,subprocess,tempfile,zipfile
import xml.etree.ElementTree as ET
parser=argparse.ArgumentParser()
parser.add_argument('--core-jar',type=Path,required=True)
parser.add_argument('--classpath-report',type=Path,required=True)
parser.add_argument('--expect-boot-failure',action='store_true')
parser.add_argument('--boot-loader-tools',type=Path,default=Path.home()/'.m2/repository/org/springframework/boot/spring-boot-loader-tools/4.0.2/spring-boot-loader-tools-4.0.2.jar')
args=parser.parse_args()
root=Path(tempfile.mkdtemp(prefix='adk-skill-boot-repro-'))
properties=ET.parse(args.classpath_report).find('properties')
classpath=next(p.attrib['value'] for p in properties if p.attrib['name']=='java.class.path').split(os.pathsep)
prefixes=('guava-', 'failureaccess-', 'listenablefuture-', 'rxjava-', 'reactive-streams-', 'jackson-', 'snakeyaml-')
libs=[Path(p) for p in classpath if Path(p).name.startswith(prefixes) and p.endswith('.jar')]
assert len(libs)>=9, libs
classes=root/'classes'; classes.mkdir(exist_ok=True)
probe=root/'SkillProbe.java'
probe.write_text('''import com.google.adk.skills.ClassPathSkillSource;
import java.nio.charset.StandardCharsets;
import java.util.Set;
public class SkillProbe {
  public static void main(String[] args) throws Exception {
    ClassLoader loader = Thread.currentThread().getContextClassLoader();
    System.out.println("loader=" + loader.getClass().getName());
    for (String name : Set.of("app-skill", "library-skill")) {
      try (var input = loader.getResourceAsStream("skills/" + name + "/SKILL.md")) {
        if (input == null) throw new AssertionError("resource unreadable: " + name);
        System.out.println("directRead[" + name + "]=" + input.readAllBytes().length);
      }
    }
    var source = new ClassPathSkillSource("skills/");
    var names = source.listFrontmatters().blockingGet().keySet();
    System.out.println("adkSkills=" + names);
    if (!names.equals(Set.of("app-skill", "library-skill"))) {
      throw new AssertionError("Expected both application and nested-library skills");
    }
    for (String name : names) {
      if (!source.loadInstructions(name).blockingGet().equals("Instructions.")) throw new AssertionError(name);
      var paths = source.listResources(name, "references").blockingGet();
      if (!paths.equals(com.google.common.collect.ImmutableList.of("references/guide.txt"))) throw new AssertionError(paths);
      String resource = new String(source.loadResource(name, paths.get(0)).blockingGet().read(), StandardCharsets.UTF_8);
      if (!resource.equals("Guide.")) throw new AssertionError(resource);
    }
    // Open a second source to catch accidentally closed classloader-owned archives.
    if (new ClassPathSkillSource("skills/").listFrontmatters().blockingGet().size() != 2) throw new AssertionError();
    System.out.println("PASS: discovery, instructions, resource listing/read, repeated source");
  }
}
''')
subprocess.run(['javac','-proc:none','--release','17','-cp',os.pathsep.join([str(args.core_jar.resolve()),*map(str,libs)]),'-d',str(classes),str(probe)],check=True)
def skill(name):
    return {'skills/'+name+'/SKILL.md':f'---\nname: {name}\ndescription: Independent fixture\n---\nInstructions.'.encode(),
            'skills/'+name+'/references/guide.txt':b'Guide.'}
for name,data in skill('app-skill').items():
    p=classes/name;p.parent.mkdir(parents=True,exist_ok=True);p.write_bytes(data)
library=root/'library-skills.jar'
with zipfile.ZipFile(library,'w') as z:
    for name,data in skill('library-skill').items(): z.writestr(name,data)
# The official Boot loader is distributed inside loader-tools, not copied from Golem.
loaderTools=args.boot_loader_tools
with zipfile.ZipFile(loaderTools) as z: loaderBytes=z.read('META-INF/loader/spring-boot-loader.jar')
def bootjar(label,core):
    path=root/(label+'-boot.jar')
    with zipfile.ZipFile(path,'w') as z:
        with zipfile.ZipFile(io.BytesIO(loaderBytes)) as loader:
            for entry in loader.infolist():
                if entry.filename.startswith('org/') and not entry.is_dir(): z.writestr(entry.filename,loader.read(entry))
        z.writestr('META-INF/MANIFEST.MF','Manifest-Version: 1.0\r\nMain-Class: org.springframework.boot.loader.launch.JarLauncher\r\nStart-Class: SkillProbe\r\n\r\n')
        z.writestr('BOOT-INF/classes/',b'')
        z.writestr('BOOT-INF/lib/',b'')
        for p in classes.rglob('*'):
            if p.is_file(): z.write(p,'BOOT-INF/classes/'+p.relative_to(classes).as_posix())
        for p in [core,library,*libs]: z.write(p,'BOOT-INF/lib/'+p.name,compress_type=zipfile.ZIP_STORED)
    return path
results=[]
for label,core in [('baseline' if args.expect_boot_failure else 'fixed',args.core_jar.resolve())]:
    boot=bootjar(label,core)
    for mode,command in [('classpath',['java','-cp',os.pathsep.join([str(classes),str(library),str(core),*map(str,libs)]),'SkillProbe']),('boot',['java','-jar',str(boot)])]:
        completed=subprocess.run(command,stdout=subprocess.PIPE,stderr=subprocess.STDOUT,text=True)
        (root/(label+'-'+mode+'.log')).write_text(completed.stdout)
        results.append({'source':label,'mode':mode,'exit':completed.returncode,'output':completed.stdout})
        expected=1 if args.expect_boot_failure and mode=='boot' else 0
        assert completed.returncode==expected, results[-1]
        if expected: assert 'adkSkills=[]' in completed.stdout and 'Expected both application' in completed.stdout, results[-1]
print(json.dumps(results,indent=2))
(root/'results.json').write_text(json.dumps(results,indent=2))

Additional context

A fix and regression tests are prepared. The intended fix supplements the existing scan using standard JarURLConnection support for JAR roots, without adding a Spring runtime dependency to core. With the fix, both launch modes pass discovery, instruction/resource access, and construction of a second source. A PR with the validation results will follow.

Activity

  1. added 2 commits that reference this issue on Nov 23, 2026
    0f3d4e3
    c891ae8
  2. self-assigned this
    on Nov 24, 2026
  3. added theissue type on Nov 24, 2026
  4. added a commit that references this issue on Nov 25, 2026
    8c0f4a9
  5. hemasekhar-p commented on Nov 25, 2026

    @hemasekhar-p
    Contributor

    Hi @zhangxiangnan, thank you for bringing this to our attention and for contributing a PR. I have successfully reproduced this reported behavior. Our team is currently reviewing this issue and your submission and we will keep you informed if we require any further details.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions