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.
Now, the second jar is a logging framework, whereas the first jar in this case is the model classes of the logging framework.
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.
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.
I've checked for redundancies and/or possible overlappings in class/enum names, but there are none that I can find.
Sequence of order:
- Web App calls for initialization of logging-framework (direct dependency)
- logging-framework has issues loading it's own configuration, and throws an exception
- Exception is handeled, and a method is called to register the error
- 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
The web-app throws an exception
java.lang.NoSuchFieldError: BABYLOVE at logging.framework.Constants.<clinit>(Constants.java:52) at logging.framework.Logger.<init>(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
Constants, line 51-52:
public static final Event ConfigValidationFailed =
EventLogHelper.getEvent(EventLogSource.LoggingFramework, EventLogEntryType.BABYLOVE");
EventLogEntryType:
@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);
}
I don't know if it matters, but I am using maven2 to deal with my dependencies.