java.lang.NoClassDefFoundError trying to connect an external database

Hi everyone!

I’m trying to connect with a database from a script at the Script Console, using the following code:

It makes a connection with a MS SQL Server database through the zxJDBC library and it should return the database version. Instead of this, I obtain the following error message:


Does anyone know what could be causing this error?
Thank you in advance!

JAXB was removed in Java 11 (see: JEP 320). How are you providing an MSSQL driver to the designer/client scope? It’s likely an old version that doesn’t support Java 11.

That said - why are you trying to dynamically create database connections from the runtime? This seems like a bad idea.

I have copied the JAR file containing the driver at the folder C:\Program Files\Inductive Automation\Ignition\lib\core\common, where the zxJDBC library can find it. I’m using this method because I want to connect to databases in other computers without the needing of configurate a new connection in Ignition. The zxJDBC library can connect to different database types using different drivers. A friend of mine has tried the same script in his Ignition and it worked, so probably the error could be caused by missing libraries. Is there some way to add JAXB to Ignition?

No, and it’s the wrong solution anyways. Download the latest MSSQL driver, from Microsoft directly, and do the same shenanigans with the JAR file. That’ll probably work.

That said, this is all unsupported, so you’re very much on your own if something goes wrong.

So, if all this is unsupported in Java 11, what is the common way to access to external databases directly from the script? Thank you so much for your help.

The supported way in Ignition is to define database connections in the gateway and run all of your DB operations with the documented system.db.* script functions.

There is no supported way to do so. The supported way is to make database connections on the gateway, using the database connection mechanism.

And, to clarify - the only part of this that’s related to Java 11 is that whatever version of the MSSQL JDBC driver you are using has an implicit dependency on JAXB, which is no longer bundled with the standard Java Runtime as of Java 11. If you download a new version of the MSSQL driver (it’s freely available: https://docs.microsoft.com/en-us/sql/connect/jdbc/download-microsoft-jdbc-driver-for-sql-server?view=sql-server-ver15) that works on Java 11 then I would expect the driver to work in this specific scenario.

The aspect that is unsupported is unsupported from Inductive Automation’s perspective. We have exactly one established mechanism to create database connections - do anything else, and you’re on your own.