title: Kafka Producer Class Not Found Exception
body: <p>I tried to implement a simple producer consumer example with kafka and I achieved with the following properties:</p>
  
  <pre><code>Properties configProperties = new Properties();
      configProperties.put(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG,"localhost:" + portNumber);
      configProperties.put(ProducerConfig.KEY_SERIALIZER_CLASS_CONFIG,"org.apache.kafka.common.serialization.ByteArraySerializer");
      configProperties.put(ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG,"org.apache.kafka.common.serialization.StringSerializer");
  
      // Belirtilen property ayarlarına sahip kafka producer oluşturulur
      org.apache.kafka.clients.producer.Producer producer = new KafkaProducer(configProperties);
  </code></pre>
  
  <p>However when I try the exact same configs, and everything else the same, in another project which is a plugin for a data visualization software, I got this error:</p>
  
  <pre><code>.... // Here there is some other stuff but I thing the important one is the below one
  Caused by: java.lang.NoClassDefFoundError: org/apache/kafka/clients/producer/Producer
  at App.MyControlPanel.&lt;init&gt;(MyControlPanel.java:130)
  at App.CytoVisProject.&lt;init&gt;(CytoVisProject.java:29)
  ... 96 more
  Caused by: java.lang.ClassNotFoundException: org.apache.kafka.clients.producer.Producer
  at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
  at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
  at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
  ... 98 more
  </code></pre>
  
  <p>In the first one that I said it worked, I was using "mvn clean compile assembly:single", but in the second one I created a jar file for the whole project. Because the visualization software wants a jar file to install the plugin. Since every thing is same (At least I could not find any difference, I used same code) I guess the problem is about the way build the project. What happened here? What is the difference between "mvn clean compile assembly:single" and building a jar file in IntelliJ? Why I got this error and how to fix this? Thanks a lot for help!</p>
  
  <hr>
  
  <p>As I said in the last comment of the first answer, I have a plugin which has manifest and transform as goal. Here:</p>
  
  <pre><code>&lt;plugin&gt;
              &lt;groupId&gt;com.springsource.bundlor&lt;/groupId&gt;
              &lt;artifactId&gt;com.springsource.bundlor.maven&lt;/artifactId&gt;
              &lt;version&gt;1.0.0.M2&lt;/version&gt;
              &lt;configuration&gt;
                  &lt;outputManifest&gt;C:\Users\USER\AppData\Local\Temp\archetype2tmp/META-INF/MANIFEST.MF&lt;/outputManifest&gt;
                  &lt;failOnWarnings&gt;false&lt;/failOnWarnings&gt;
                  &lt;removeNullHeaders&gt;true&lt;/removeNullHeaders&gt;
                  &lt;manifestHeaders&gt;&lt;![CDATA[Bundle-ManifestVersion: 2
  Bundle-Name: CytoVisProject
  Bundle-SymbolicName: CytoVisProject
  Spring-DM-Version: ${pom.version}
  ]]&gt;&lt;/manifestHeaders&gt;
              &lt;/configuration&gt;
              &lt;!-- generate the manifest automatically during packaging --&gt;
              &lt;executions&gt;
                  &lt;execution&gt;
                      &lt;id&gt;bundle-manifest&lt;/id&gt;
                      &lt;phase&gt;package&lt;/phase&gt;
                      &lt;goals&gt;
                          &lt;goal&gt;manifest&lt;/goal&gt;
                          &lt;goal&gt;transform&lt;/goal&gt;
                      &lt;/goals&gt;
                  &lt;/execution&gt;
              &lt;/executions&gt;
          &lt;/plugin&gt;
  </code></pre>
  
  <p>If I use a shade plugin like below:</p>
  
  <pre><code>&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.0&lt;/version&gt;
              &lt;configuration&gt;
  
              &lt;/configuration&gt;
              &lt;executions&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;/execution&gt;
              &lt;/executions&gt;
          &lt;/plugin&gt;
  </code></pre>
  
  <p>It does not works, because I need to use manifest and transform as goals in my plugin. How can I add kafka classes to the jar file that IntelliJ creates to solve this problem (I am not sure if this can solve or not)?</p>