title: How to unit-test JSP Tags?
body: <p>I have a custom JSP tag</p>
  
  <pre><code>public class HappyTag extends TagSupport { ... }
  </code></pre>
  
  <p>and now I need to test it.</p>
  
  <p>So I've created a simple JUnit test:</p>
  
  <pre><code>@Test
  public void testTag() {
      HappyTag tag = new HappyTag();
  }
  </code></pre>
  
  <p>and I get the following error:</p>
  
  <pre><code>java.lang.ClassFormatError: Absent Code attribute in method that is not native or abstract in class file javax/servlet/jsp/tagext/TagSupport
  at java.lang.ClassLoader.defineClass1(Native Method)
  at java.lang.ClassLoader.defineClassCond(ClassLoader.java:631)
  at java.lang.ClassLoader.defineClass(ClassLoader.java:615)
  at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141)
  at java.net.URLClassLoader.defineClass(URLClassLoader.java:283)
  at java.net.URLClassLoader.access$000(URLClassLoader.java:58)
  (.....)
  at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
  at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
  </code></pre>
  
  <p>I am using maven to build and test my application, tags included.
  My current dependencies of the tags sub-module are:</p>
  
  <pre class="lang-xml prettyprint-override"><code>    &lt;dependencies&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;commons-collections&lt;/groupId&gt;
          &lt;artifactId&gt;commons-collections&lt;/artifactId&gt;
          &lt;version&gt;3.2.1&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;javax&lt;/groupId&gt;
          &lt;artifactId&gt;javaee-api&lt;/artifactId&gt;
          &lt;version&gt;6.0-SNAPSHOT&lt;/version&gt;
          &lt;scope&gt;provided&lt;/scope&gt;
      &lt;/dependency&gt;
  
  &lt;/dependencies&gt;
  </code></pre>
  
  <p>plus some dependencies from the parent module:</p>
  
  <pre class="lang-xml prettyprint-override"><code>   &lt;dependency&gt;
          &lt;groupId&gt;javax.servlet&lt;/groupId&gt;
          &lt;artifactId&gt;servlet-api&lt;/artifactId&gt;
          &lt;version&gt;2.5&lt;/version&gt;
          &lt;scope&gt;provided&lt;/scope&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;javax.servlet.jsp&lt;/groupId&gt;
          &lt;artifactId&gt;jsp-api&lt;/artifactId&gt;
          &lt;version&gt;2.1&lt;/version&gt;
          &lt;scope&gt;provided&lt;/scope&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;javax.servlet&lt;/groupId&gt;
          &lt;artifactId&gt;jstl&lt;/artifactId&gt;
          &lt;version&gt;1.2&lt;/version&gt;
      &lt;/dependency&gt;
  
  
      &lt;dependency&gt;
          &lt;groupId&gt;javax.portlet&lt;/groupId&gt;
          &lt;artifactId&gt;portlet-api&lt;/artifactId&gt;
          &lt;version&gt;2.0&lt;/version&gt;
          &lt;scope&gt;provided&lt;/scope&gt;
      &lt;/dependency&gt;
  
      &lt;dependency&gt;
          &lt;groupId&gt;org.portletfaces&lt;/groupId&gt;
          &lt;artifactId&gt;portletfaces-bridge-impl&lt;/artifactId&gt;
          &lt;version&gt;2.0.0&lt;/version&gt;
      &lt;/dependency&gt;
  
  
      &lt;dependency&gt;
          &lt;groupId&gt;javax.el&lt;/groupId&gt;
          &lt;artifactId&gt;el-api&lt;/artifactId&gt;
          &lt;version&gt;2.2&lt;/version&gt;
          &lt;scope&gt;provided&lt;/scope&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.glassfish.web&lt;/groupId&gt;
          &lt;artifactId&gt;el-impl&lt;/artifactId&gt;
          &lt;version&gt;2.2&lt;/version&gt;
          &lt;scope&gt;provided&lt;/scope&gt;
      &lt;/dependency&gt;
  </code></pre>
  
  <p>Those dependencies are enough to compile and use the tags in my JSP. They are not enough to test the tag :-(</p>
  
  <p>So, what did I do wrong?</p>
  
  <p>Kindest regards,<br/>
  Q.</p>