Skip to content

ClassNotFoundException with APOC when running with embedded Java API and custom procedure classloader #676

@DirkMahler

Description

@DirkMahler

jQAssistant uses the Java API of Neo4j 4.4.x in embedded mode and allows registration of custom procedures (e.g. APOC), internally mapped to:

GlobalProcedures.registerProcedure(procedureType);

The procedureType is loaded using a custom classloader having the classloader which provides the Neo4j classes as parent. The registration itself is successful, but trying to use the procedure

call apoc.help('help')

fails with

Neo.ClientError.Procedure.ProcedureCallFailed
Failed to invoke procedure `apoc.help`: Caused by: java.lang.NoClassDefFoundError: apoc/help/Help

The issue seems to be related to the hard-coded classloader used in https://github.com/neo4j/neo4j/blob/4.4/community/procedure/src/main/java/org/neo4j/procedure/impl/ProcedureCompilation.java#L840, I replaced it locally with the TCCL and everything is fine. If required I can provide a PR, but we'd need to align how to create a test for it (doesn't seem trivial).
Let me know if I should provide a demonstrator project with instructions on how to reproduce.

Neo4j Version: 4.4.26
Operation System: Win10 (probably any)
API: Embedded Java API/ Cypher

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions