I'm running a Spring Boot web app with an underlying Neo4j database. In order to be able to view the Neo4j browser (direct web view onto the db), the Neo4j web server is embedded into the application using the following configuration.
@Bean(initMethod = "start", destroyMethod = "stop")
public WrappingNeoServerBootstrapper neo4jWebServer() {
return new WrappingNeoServerBootstrapper((GraphDatabaseAPI) graphDatabaseService());
}
and by including the following in the maven pom:
<dependency>
<groupId>org.neo4j.app</groupId>
<artifactId>neo4j-server</artifactId>
<classifier>static-web</classifier>
<version>2.0.2</version>
</dependency>
This all works fine when running from STS (i.e. unpackaged).
When I package the application up using the spring-boot-maven-plugin
. This creates the uber-jar correctly containing the neo4j-server-2.0.2-static-web.jar
file in the /lib folder of the uber-jar.
When I run the application directly using the uber-jar file and then attempt to hit the http://localhost:7474/browser/
URL for the Neo4j browser, it returns a 404.
The reason for this is that the Jetty DefaultServlet
attempts to getResource()
from the WebAppContext
which, in turn, calls JarFileResource.exists()
which tries to operate on the following URL string:
jar:file:/home/dev/myapp/target/myapp-0.0.1-SNAPSHOT.jar!/lib/neo4j-browser-2.0.2.jar!/browser/
Jetty fails to match anything in its resource list as it's looking for a resource called /lib/neo4j-browser-2.0.2.jar!/browser/
as the code, e.g. at http://git.eclipse.org/c/jetty/org.eclipse.jetty.project.git/tree/jetty-util/src/main/java/org/eclipse/jetty/util/resource/JarFileResource.java#n123 (and a couple of other places) is looking for the first !/
in the string.
I am going to submit a Jetty bug for this with a suggestion that they use String.lastIndexOf("!/")
in their code, which will resolve the issue.
In the meantime, apart from producing our oun standard maven assembly, does anyone have any suggestions for how I could get this to work within a Spring Boot uber-jar?
Many thanks.