title: Spring Boot ProGuard Embedded Tomcat Obfuscation
body: <p>I'm not sure ProGuard is suited for this.
  I've a Spring Boot app that I need to obfuscate. Using proguard-maven-plugin I reached a point where I have my code obfuscated. Anyway I had to repackage some jars because spring loader doesnt support compressed ones, but this is not the problem.
  Something is wrong in the way the embedded tomcat start because i get this problem:</p>
  
  <pre><code>[main] ERROR o.s.boot.SpringApplication - Application startup failed                                              
  org.springframework.context.ApplicationContextException: Unable to start embedded container; nested exception is org.springfram
  ework.context.ApplicationContextException: Unable to start EmbeddedWebApplicationContext due to missing EmbeddedServletContaine
  rFactory bean.  
  </code></pre>
  
  <p>proguard-maven-plugin configuration</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"&gt;
      &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
  
      &lt;parent&gt;
          &lt;groupId&gt;org.foogroup&lt;/groupId&gt;
          &lt;artifactId&gt;foo&lt;/artifactId&gt;
          &lt;version&gt;0.0.1-SNAPSHOT&lt;/version&gt;
      &lt;/parent&gt;
  
      &lt;name&gt;fooname&lt;/name&gt;
      &lt;description&gt;foo description&lt;/description&gt;
      &lt;groupId&gt;foogid&lt;/groupId&gt;
      &lt;artifactId&gt;fooaid&lt;/artifactId&gt;
      &lt;version&gt;0.0.1-SNAPSHOT&lt;/version&gt;
  
      &lt;packaging&gt;jar&lt;/packaging&gt;
  
      &lt;properties&gt;
          &lt;!-- Specify Java Compiler Version --&gt;
          &lt;maven.compiler.source&gt;1.8&lt;/maven.compiler.source&gt;
          &lt;maven.compiler.target&gt;1.8&lt;/maven.compiler.target&gt;
      &lt;/properties&gt;
  
      &lt;dependencies&gt;
  
          &lt;dependency&gt;
              &lt;groupId&gt;org.apache.pdfbox&lt;/groupId&gt;
              &lt;artifactId&gt;pdfbox&lt;/artifactId&gt;
              &lt;version&gt;1.8.11&lt;/version&gt;
          &lt;/dependency&gt;
  
          &lt;dependency&gt;
              &lt;groupId&gt;com.itextpdf&lt;/groupId&gt;
              &lt;artifactId&gt;itextpdf&lt;/artifactId&gt;
              &lt;version&gt;5.5.3&lt;/version&gt;
          &lt;/dependency&gt;
  
  
      &lt;/dependencies&gt;
  
      &lt;build&gt;
  
          &lt;resources&gt;
              &lt;resource&gt;
                  &lt;directory&gt;src/main/resources&lt;/directory&gt;
                  &lt;filtering&gt;true&lt;/filtering&gt;
              &lt;/resource&gt;
          &lt;/resources&gt;
  
          &lt;plugins&gt;
              &lt;plugin&gt;
                  &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
                  &lt;artifactId&gt;spring-boot-maven-plugin&lt;/artifactId&gt;
              &lt;/plugin&gt;
  
              &lt;plugin&gt;
                  &lt;groupId&gt;com.github.wvengen&lt;/groupId&gt;
                  &lt;artifactId&gt;proguard-maven-plugin&lt;/artifactId&gt;
                  &lt;executions&gt;
                      &lt;execution&gt;
                          &lt;phase&gt;package&lt;/phase&gt;
                          &lt;goals&gt;
                              &lt;goal&gt;proguard&lt;/goal&gt;
                          &lt;/goals&gt;
                      &lt;/execution&gt;
                  &lt;/executions&gt;
                  &lt;configuration&gt;
                      &lt;obfuscate&gt;true&lt;/obfuscate&gt;
                      &lt;injar&gt;${project.build.finalName}.jar&lt;/injar&gt;
                      &lt;outjar&gt;${project.build.finalName}-small.jar&lt;/outjar&gt;
                      &lt;outputDirectory&gt;${project.build.directory}&lt;/outputDirectory&gt;
  
                      &lt;options&gt;
                          &lt;option&gt;-optimizations !class/marking/final&lt;/option&gt;
                          &lt;option&gt;-adaptresourcefilecontents
                              **.properties,META-INF/MANIFEST.MF,META-INF/spring.*&lt;/option&gt;
                          &lt;option&gt;-keepattributes
                              Exceptions,InnerClasses,Signature,Deprecated,SourceFile,LineNumberTable,*Annotation*,EnclosingMethod&lt;/option&gt;
                          &lt;option&gt;-keepclasseswithmembers public class * { public static
                              void main(java.lang.String[]);}&lt;/option&gt;
                          &lt;option&gt;-keepclassmembers class * {
                              @org.springframework.beans.factory.annotation.Autowired *;
                              @org.springframework.beans.factory.annotation.Value *;
                              }
                          &lt;/option&gt;
                          &lt;option&gt;-keep public class org.foo.**&lt;/option&gt;
                          &lt;option&gt;-keep public class org.springframework.**&lt;/option&gt;
                      &lt;/options&gt;
                      &lt;libs&gt;
                          &lt;lib&gt;${java.home}/lib/rt.jar&lt;/lib&gt;
                      &lt;/libs&gt;
                      &lt;injarNotExistsSkip&gt;true&lt;/injarNotExistsSkip&gt;
                  &lt;/configuration&gt;
                  &lt;dependencies&gt;
                      &lt;dependency&gt;
                          &lt;groupId&gt;net.sf.proguard&lt;/groupId&gt;
                          &lt;artifactId&gt;proguard-base&lt;/artifactId&gt;
                          &lt;version&gt;5.2.1&lt;/version&gt;
                          &lt;scope&gt;runtime&lt;/scope&gt;
                      &lt;/dependency&gt;
                  &lt;/dependencies&gt;
              &lt;/plugin&gt;
          &lt;/plugins&gt;
      &lt;/build&gt;
  &lt;/project&gt;
  </code></pre>
  
  <p>I found some tips <a href="http://midgetontoes.com/tips-for-using-proguard-with-spring-framework/" rel="nofollow">here</a> but doesnt mention anything about any issue with embedded servlet containers.</p>
  
  <p>I suspect that i'm doing something wrong in the process and I cannot find any reliable working sample/tips on the web about this specific issue.</p>
  
  <p>If you guys have suggestions on how to address this I'm all hears :)</p>