title: Apache Flink - External Jar
body: <p>i'm trying to create a Flink application using maven and an extra dependency : </p>
  
  <pre><code> &lt;dependency&gt;
        &lt;groupId&gt;com.microsoft.sqlserver&lt;/groupId&gt;
        &lt;artifactId&gt;mssql-jdbc&lt;/artifactId&gt;
        &lt;version&gt;8.2.2.jre11&lt;/version&gt;
    &lt;/dependency&gt;
  </code></pre>
  
  <p>Im trying to fetch extra information from our database. When I run the code locally, everything is fine, but when run on Flink, I get this error message : 
  <a href="https://i.stack.imgur.com/Z3Tp6.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Z3Tp6.png" alt="enter image description here"></a></p>
  
  <p>So my initial tought was the dependency was not loaded on the fat jar using the maven shadow pluging, but I think it is. 
  <a href="https://i.stack.imgur.com/j1IFy.pngee" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/j1IFy.pngee" alt="enter image description here"></a></p>
  
  <p>My Flink is run in a docker container, Ive open port 1433:1433 on the container (in the compose).</p>
  
  <p>My goal is to add SQL data to the stream for an alerting system with custom rules by user.</p>
  
  <p>Here is the content of my pom.xml :</p>
  
  <p>-->
  http://maven.apache.org/xsd/maven-4.0.0.xsd">
      4.0.0</p>
  
  <pre><code>&lt;groupId&gt;org.qscale&lt;/groupId&gt;
  &lt;artifactId&gt;FlinkPrototype&lt;/artifactId&gt;
  &lt;version&gt;1.0&lt;/version&gt;
  &lt;packaging&gt;jar&lt;/packaging&gt;
  
  &lt;name&gt;Flink Quickstart Job&lt;/name&gt;
  &lt;url&gt;http://www.myorganization.org&lt;/url&gt;
  
  &lt;properties&gt;
      &lt;project.build.sourceEncoding&gt;UTF-8&lt;/project.build.sourceEncoding&gt;
      &lt;flink.version&gt;1.10.0&lt;/flink.version&gt;
      &lt;java.version&gt;1.8&lt;/java.version&gt;
      &lt;scala.binary.version&gt;2.11&lt;/scala.binary.version&gt;
      &lt;maven.compiler.source&gt;${java.version}&lt;/maven.compiler.source&gt;
      &lt;maven.compiler.target&gt;${java.version}&lt;/maven.compiler.target&gt;
  &lt;/properties&gt;
  
  &lt;repositories&gt;
      &lt;repository&gt;
          &lt;id&gt;apache.snapshots&lt;/id&gt;
          &lt;name&gt;Apache Development Snapshot Repository&lt;/name&gt;
          &lt;url&gt;https://repository.apache.org/content/repositories/snapshots/&lt;/url&gt;
          &lt;releases&gt;
              &lt;enabled&gt;false&lt;/enabled&gt;
          &lt;/releases&gt;
          &lt;snapshots&gt;
              &lt;enabled&gt;true&lt;/enabled&gt;
          &lt;/snapshots&gt;
      &lt;/repository&gt;
  &lt;/repositories&gt;
  
  &lt;dependencies&gt;
      &lt;!-- Apache Flink dependencies --&gt;
      &lt;!-- These dependencies are provided, because they should not be packaged into the JAR file. --&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.apache.flink&lt;/groupId&gt;
          &lt;artifactId&gt;flink-java&lt;/artifactId&gt;
          &lt;version&gt;${flink.version}&lt;/version&gt;
          &lt;scope&gt;provided&lt;/scope&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.apache.flink&lt;/groupId&gt;
          &lt;artifactId&gt;flink-streaming-java_${scala.binary.version}&lt;/artifactId&gt;
          &lt;version&gt;${flink.version}&lt;/version&gt;
          &lt;scope&gt;provided&lt;/scope&gt;
      &lt;/dependency&gt;
  
      &lt;!-- Add connector dependencies here. They must be in the default scope (compile). --&gt;
  
      &lt;!-- Example:
  
      &lt;dependency&gt;
          &lt;groupId&gt;org.apache.flink&lt;/groupId&gt;
          &lt;artifactId&gt;flink-connector-kafka-0.10_${scala.binary.version}&lt;/artifactId&gt;
          &lt;version&gt;${flink.version}&lt;/version&gt;
      &lt;/dependency&gt;
      --&gt;
  
      &lt;!-- Project dependencies --&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;com.microsoft.sqlserver&lt;/groupId&gt;
          &lt;artifactId&gt;mssql-jdbc&lt;/artifactId&gt;
          &lt;version&gt;8.2.2.jre11&lt;/version&gt;
      &lt;/dependency&gt;
  
      &lt;!-- Add logging framework, to produce console output when running in the IDE. --&gt;
      &lt;!-- These dependencies are excluded from the application JAR by default. --&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.slf4j&lt;/groupId&gt;
          &lt;artifactId&gt;slf4j-log4j12&lt;/artifactId&gt;
          &lt;version&gt;1.7.7&lt;/version&gt;
          &lt;scope&gt;runtime&lt;/scope&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;log4j&lt;/groupId&gt;
          &lt;artifactId&gt;log4j&lt;/artifactId&gt;
          &lt;version&gt;1.2.17&lt;/version&gt;
          &lt;scope&gt;runtime&lt;/scope&gt;
      &lt;/dependency&gt;
  &lt;/dependencies&gt;
  
  &lt;build&gt;
      &lt;plugins&gt;
  
          &lt;!-- Java Compiler --&gt;
          &lt;plugin&gt;
              &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
              &lt;artifactId&gt;maven-compiler-plugin&lt;/artifactId&gt;
              &lt;version&gt;3.1&lt;/version&gt;
              &lt;configuration&gt;
                  &lt;source&gt;${java.version}&lt;/source&gt;
                  &lt;target&gt;${java.version}&lt;/target&gt;
              &lt;/configuration&gt;
          &lt;/plugin&gt;
  
          &lt;!-- We use the maven-shade plugin to create a fat jar that contains all necessary dependencies. --&gt;
          &lt;!-- Change the value of &lt;mainClass&gt;...&lt;/mainClass&gt; if your program entry point changes. --&gt;
          &lt;plugin&gt;
              &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
              &lt;artifactId&gt;maven-shade-plugin&lt;/artifactId&gt;
              &lt;version&gt;3.1.1&lt;/version&gt;
              &lt;executions&gt;
                  &lt;!-- Run shade goal on package phase --&gt;
                  &lt;execution&gt;
                      &lt;phase&gt;package&lt;/phase&gt;
                      &lt;goals&gt;
                          &lt;goal&gt;shade&lt;/goal&gt;
                      &lt;/goals&gt;
                      &lt;configuration&gt;
                          &lt;shadedArtifactAttached&gt;true&lt;/shadedArtifactAttached&gt;
                          &lt;shadedClassifierName&gt;shaded&lt;/shadedClassifierName&gt;
                          &lt;artifactSet&gt;
                              &lt;excludes&gt;
                                  &lt;exclude&gt;org.apache.flink:force-shading&lt;/exclude&gt;
                                  &lt;exclude&gt;com.google.code.findbugs:jsr305&lt;/exclude&gt;
                                  &lt;exclude&gt;org.slf4j:*&lt;/exclude&gt;
                                  &lt;exclude&gt;log4j:*&lt;/exclude&gt;
                              &lt;/excludes&gt;
                          &lt;/artifactSet&gt;
                          &lt;filters&gt;
                              &lt;filter&gt;
                                  &lt;!-- Do not copy the signatures in the META-INF folder.
                                  Otherwise, this might cause SecurityExceptions when using the JAR. --&gt;
                                  &lt;artifact&gt;*:*&lt;/artifact&gt;
                                  &lt;excludes&gt;
                                      &lt;exclude&gt;META-INF/*.SF&lt;/exclude&gt;
                                      &lt;exclude&gt;META-INF/*.DSA&lt;/exclude&gt;
                                      &lt;exclude&gt;META-INF/*.RSA&lt;/exclude&gt;
                                  &lt;/excludes&gt;
                              &lt;/filter&gt;
                          &lt;/filters&gt;
                          &lt;transformers&gt;
                              &lt;transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer"&gt;
                                  &lt;mainClass&gt;org.qscale.StreamingJob&lt;/mainClass&gt;
                              &lt;/transformer&gt;
                          &lt;/transformers&gt;
                      &lt;/configuration&gt;
                  &lt;/execution&gt;
              &lt;/executions&gt;
          &lt;/plugin&gt;
      &lt;/plugins&gt;
  
      &lt;pluginManagement&gt;
          &lt;plugins&gt;
  
              &lt;!-- This improves the out-of-the-box experience in Eclipse by resolving some warnings. --&gt;
              &lt;plugin&gt;
                  &lt;groupId&gt;org.eclipse.m2e&lt;/groupId&gt;
                  &lt;artifactId&gt;lifecycle-mapping&lt;/artifactId&gt;
                  &lt;version&gt;1.0.0&lt;/version&gt;
                  &lt;configuration&gt;
                      &lt;lifecycleMappingMetadata&gt;
                          &lt;pluginExecutions&gt;
                              &lt;pluginExecution&gt;
                                  &lt;pluginExecutionFilter&gt;
                                      &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
                                      &lt;artifactId&gt;maven-shade-plugin&lt;/artifactId&gt;
                                      &lt;versionRange&gt;[3.1.1,)&lt;/versionRange&gt;
                                      &lt;goals&gt;
                                          &lt;goal&gt;shade&lt;/goal&gt;
                                      &lt;/goals&gt;
                                  &lt;/pluginExecutionFilter&gt;
                                  &lt;action&gt;
                                      &lt;ignore/&gt;
                                  &lt;/action&gt;
                              &lt;/pluginExecution&gt;
                              &lt;pluginExecution&gt;
                                  &lt;pluginExecutionFilter&gt;
                                      &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
                                      &lt;artifactId&gt;maven-compiler-plugin&lt;/artifactId&gt;
                                      &lt;versionRange&gt;[3.1,)&lt;/versionRange&gt;
                                      &lt;goals&gt;
                                          &lt;goal&gt;testCompile&lt;/goal&gt;
                                          &lt;goal&gt;compile&lt;/goal&gt;
                                      &lt;/goals&gt;
                                  &lt;/pluginExecutionFilter&gt;
                                  &lt;action&gt;
                                      &lt;ignore/&gt;
                                  &lt;/action&gt;
                              &lt;/pluginExecution&gt;
                          &lt;/pluginExecutions&gt;
                      &lt;/lifecycleMappingMetadata&gt;
                  &lt;/configuration&gt;
              &lt;/plugin&gt;
          &lt;/plugins&gt;
      &lt;/pluginManagement&gt;
  &lt;/build&gt;
  </code></pre>
  
  <p></p>
  
  <p>Thank you for your help !</p>