Getting Schema Spy to run on databases with lots of tables

Getting Schema Spy to run on databases with lots of tables

The other day I ran into issues with Schema Spy pointing it to a database with 1.200 tables for the first time.

The problem

The error output was the following:

Writing/diagramming detailsINFO  - Completed summary in 277 seconds

INFO  - Writing/diagramming details

.Exception in thread "main" java.lang.reflect.InvocationTargetException

        at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(

        at java.base/java.lang.reflect.Method.invoke(


        at org.springframework.boot.loader.Launcher.launch(

        at org.springframework.boot.loader.Launcher.launch(

        at org.springframework.boot.loader.JarLauncher.main(

Caused by: org.schemaspy.output.diagram.RenderException: Failed to generate Table diagram

        at org.schemaspy.output.diagram.TableDiagram.generateTableDiagram(

        at org.schemaspy.output.html.mustache.diagrams.MustacheTableDiagramFactory.generateRealTableDiagrams(

        at org.schemaspy.output.html.mustache.diagrams.MustacheTableDiagramFactory.generateTableDiagrams(

        at org.schemaspy.SchemaAnalyzer.generateHtmlDoc(

        at org.schemaspy.SchemaAnalyzer.analyze(

        at org.schemaspy.SchemaAnalyzer.analyze(

        at org.schemaspy.cli.SchemaSpyRunner.runAnalyzer(


        at org.schemaspy.Main.main(

        at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(

        ... 5 more

Caused by: org.schemaspy.output.diagram.RenderException: javax.script.ScriptException: java.lang.StackOverflowError in  at line number 27 at column number 596797

        at org.schemaspy.output.diagram.vizjs.VizJSDot.render(

        at org.schemaspy.output.diagram.TableDiagram.generateTableDiagram(

        ... 14 more

Maybe you feel like I did: What the heck is going on here? You get all sorts of messages but where to find the clue?

Photo by JESHOOTS.COM on Unsplash

In fact I did you the courtesy of highlighting the issue “StackOverflowError”. Don’t look at the first error “InvocationMethodException”…this is quite common and only the generic source throwing the error at you but can have various reasons.

After some digging I found an existing issue at Github #462. Remembering from my days at University: Java has two types of memory….Heap and Stack (in case you are interested read more about it here). In that case creating the diagram simply consumes more memory than allocated by default.

The solution

The solution is to increase the stack size. You might need to do a bit of fiddling around this and run it multiple times with different sizes until you found the right one.

In my case upping it to 2 megabytes did to the trick. Use the Xss switch to achieve that like -Xss2m (Caution: no space allowed between -Xss and the value). Your command then will look something like this:
java -Xss2m -jar C:\SQL\schemaSpy\installation\schemaspy-6.2.4.jar -o C:\sql\schemaSpy\output\ -vizjs -t mssql17 -dp ‘C:\SQL\schemaSpy\installation\mssql-jdbc-12.4.0.jre11.jar‘ -connprops ‘encrypt\=false’ -db StackOverflowDocumentation -host ‘DESKTOP-RGO4OCI‘ -port 1433 -u ‘sa‘ -p ‘P4$$w0rd!

Happy documenting!

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.