title: Why do I get a java.lang.NoSuchFieldError: on an Enum value?
body: <p>I have an Enum inside a jar that I have produced myself. This jar is a dependency of a second jar, which uses the enum values.</p>
  
  <p>Now, the second jar is a logging framework, whereas the first jar in this case is the model classes of the logging framework.</p>
  
  <p>I am trying to implement this logging framework into a web application that I have made. Long story short, it still needs some work, but I am stuck on a single problem. An error in the framework's configuration initialization is caught as an exception, and it calls a method. This method has an Enum value as one of it's parameters. However, I get a java.lang.NoSuchFieldError on this enum.</p>
  
  <p>The Enum value was ERROR, so i figured it could be a coincidence. But when I changed it to BABYLOVE the error message changed as well.</p>
  
  <p>I've checked for redundancies and/or possible overlappings in class/enum names, but there are none that I can find.</p>
  
  <p><strong>Sequence of order:</strong></p>
  
  <ol>
  <li><strong>Web App calls for initialization of logging-framework (direct dependency)</strong></li>
  <li><strong>logging-framework has issues loading it's own configuration, and throws an exception</strong></li>
  <li><strong>Exception is handeled, and a method is called to register the error</strong></li>
  <li><strong>The method is called with several parameters, one which is an enum value from logging-framework-model.jar, which is a transitive dependency of the web app</strong></li>
  <li><p><strong>The web-app throws an exception</strong></p>
  
  <pre><code>java.lang.NoSuchFieldError: BABYLOVE
  at logging.framework.Constants.&lt;clinit&gt;(Constants.java:52)
  at logging.framework.Logger.&lt;init&gt;(Logger.java:60)
  at logging.framework.LogContext.getLoggerFromContext(LogContext.java:95)
  at logging.framework.LogContext.getCurrent(LogContext.java:48)
  at action.navigation.CalendarElementEditorAction.execute(CalendarElementEditorAction.java:39)
  Truncated. see log file for complete stacktrace
  </code></pre>
  
  <blockquote>
    <p></p>
  </blockquote></li>
  </ol>
  
  <p>Constants, line 51-52:</p>
  
  <pre><code>public static final Event ConfigValidationFailed = 
  EventLogHelper.getEvent(EventLogSource.LoggingFramework, EventLogEntryType.BABYLOVE");
  </code></pre>
  
  <p>EventLogEntryType:</p>
  
  <pre><code>@XmlType(name = "EventLogEntryType")
  @XmlEnum
  public enum EventLogEntryType {
  
  //for test purposes, should be removed. This variable is given a name that can not be confused with standard names in error messages, like Error and Warning can.
  @XmlEnumValue("BabyLove")
  BABYLOVE("BabyLove"),
  
  @XmlEnumValue("Error")
  ERROR("Error"),
  @XmlEnumValue("Warning")
  WARNING("Warning"),
  @XmlEnumValue("Information")
  INFORMATION("Information"),
  @XmlEnumValue("SuccessAudit")
  SUCCESSAUDIT("SuccessAudit"),
  @XmlEnumValue("FailureAudit")
  FAILUREAUDIT("FailureAudit");
  
  
  
  private final String value;
  
  EventLogEntryType(String v) {
      value = v;
  }
  
  public String value() {
      return value;
  }
  
  public static EventLogEntryType  fromValue(String v) {
      for (EventLogEntryType c: EventLogEntryType .values()) {
          if (c.value.equals(v)) {
              return c;
          }
      }
      throw new IllegalArgumentException(v);
  }
  </code></pre>
  
  <p>I don't know if it matters, but I am using maven2 to deal with my dependencies.</p>