NoClassDefFoundError while using cypher-dsl in an unmanaged server extension

I am trying to import neo4j-cypher-dsl into an unmanaged server extension. I can start the extension but when I call the REST API method that uses DSL code I see the following error in the log:

javax.servlet.ServletException: org.glassfish.jersey.server.ContainerException: java.lang.NoClassDefFoundError: org/neo4j/cypherdsl/core/Cypher
	at org.glassfish.jersey.servlet.WebComponent.serviceImpl( ~[jersey-container-servlet-core-2.34.jar:?]

This is likely to be caused by this line of code in org.neo4j.cypherdsl.core.Cypher:

static final ResourceBundle MESSAGES = ResourceBundle.getBundle("org.neo4j.cypherdsl.core.messages");

Has anyone come across this problem?

Hi @AlbertGevorgyan Michael here, author of the Neo4j Cypher-DSL.

This works just fine. Did you remember to package up the Cypher-DSL with your code? Cypher-DSL is not a module / library of the Neo4j database. It is distributed as a separate artifact. So if you want to use it inside an extension or plugin, you have to package it up. I usually suggest the maven-assembly-plugin. An alternative is the Shade-Plugin.

Here's a working example, first the pom.xml with the dependencies. Notice how Neo4j core is in scope provided (as the extension is deployed into Neo4j, hence, the api is provided) and how Cypher-DSL is compile scope (Mavens) default:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns=""






Notice the configuration of the assembler plugin. I use the predefined descriptorRef jar-with-dependencies.

The resulting JAR will contain the repackaged library. As I said, shading is another option (which can also rename packages).

The 3rd option would be packaging your code as you normally would (thin jar), add it as plugin to neo4j plus the cypher-dsl.jar.

Anyhow, here's the example code for reference:

package org.neo4j.examples.server.unmanaged;

import static org.neo4j.cypherdsl.core.Cypher.parameter;


import org.neo4j.cypherdsl.core.Cypher;
import org.neo4j.cypherdsl.core.Expression;
import org.neo4j.cypherdsl.core.Functions;
import org.neo4j.cypherdsl.core.renderer.Configuration;
import org.neo4j.cypherdsl.core.renderer.Renderer;
import org.neo4j.dbms.api.DatabaseManagementService;
import org.neo4j.string.UTF8;

public class HelloWorldResource {
	private final DatabaseManagementService dbms;

	public HelloWorldResource(@Context DatabaseManagementService dbms) {
		this.dbms = dbms;

	public Response hello(@PathParam("nodeId") long nodeId) {

		// Let's make sure we trigger the messages ;)
		try {
			Cypher.returning((Expression) null);
		} catch (Exception e) {
			System.out.println("oops… " + e.getMessage());

		var anyNode = Cypher.anyNode("n");
		var statement = Cypher.match(anyNode)
		var cypher = Renderer.getRenderer(Configuration.prettyPrinting()).render(statement);
		return Response.status(Status.OK).entity(UTF8.encode("Here's a nice query\n\n" + cypher + "\n\n")).build();

when called, the result looks like this:

curl --user neo4j:secret localhost:7474/examples/unmanaged/helloworld/4711
Here's a nice query

WHERE id(n) = $nodeId

and the server prints the output I had in the code demonstrating that the message resource is not the cause of such a thing (oops… At least one expressions to return is required.).

I hope this helps.

Thanks for the quick answer. Translating this to Gradle: the the Shadow plugin works for me.

On a side note: is it actually recommended to use Cypher in extensions given that the Core API is also available?