0

I get a java.lang.NoClassDefFoundError: com/mysql/jdbc/exceptions/jdbc4/CommunicationsException whenever I try to launch my application as a jar, It does not occur while launching my application from IntelliJ.

Thus I conclude this issue to being JAR Only as it works when I use it from IntelliJ, but not when I use it from the JAR.

In my pom.xml

<dependency>
    <groupId>mysql</groupId>
    <artifactId>mysql-connector-java</artifactId>
    <version>5.1.40</version>
</dependency>

Basically I have everything working except when I switch over to a JAR. I think this is caused by the JAR not having access to JDBC4 how do I force the inclusion of this in the JAR?

I've tried the following solutions aswell NONE OF THEM HAVE WORKED:

Error trying to import oracle jdbc7 driver with Maven

Find Oracle JDBC driver in Maven repository

Maven ojdbc configuration error

Maven - java.lang.ClassNotFoundException: com.mysql.jdbc.Driver

"com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure" to remote database

Community
  • 1
  • 1
Kishirada
  • 142
  • 1
  • 10

1 Answers1

1

Oracle has nothing to with it. You're using MySQL.

I think the problem is that your executable JAR does not have access to the dependencies.

Research how to create an executable JAR with dependencies using a Maven plugin.

duffymo
  • 305,152
  • 44
  • 369
  • 561
  • 1
    Thanks you so much, you just ended 5 hours of headaches. For anyone in the future having this issue my answer was here: http://stackoverflow.com/questions/574594/how-can-i-create-an-executable-jar-with-dependencies-using-maven#574650 – Kishirada Apr 15 '17 at 13:38
  • Glad you found it. I would have posted it, but I answered on my phone. – duffymo Apr 15 '17 at 14:39