Java.lang.NoClassDefFoundError when using enum in class

I am getting weird when deploying my code java.lang.NoClassDefFoundError

. There is no compile error, but when I deploy it using jetty I get the error

org.springframework.beans.factory.BeanCreationException:
 Error creating bean with name 'org.springframework.dao.annotation.
                                  PersistenceExceptionTranslationPostProcessor#0'
 defined in class path resource [applicationContext-dao.xml]:
  Initialization of bean failed;

nested exception is 
 org.springframework.beans.factory.BeanCreationException:
  Error creating bean with name 'sessionFactory'
  defined in class path resource [applicationContext-dao.xml]:
   Invocation of init method failed;

nested exception is
 java.lang.NoClassDefFoundError: com/core/model/Webhook$Event

      

The class looks like below

public class Webhook extends BaseObject implements Serializable {

    public enum Event {
        ORDER_CREATE,
        ORDER_UPDATE,
        ORDER_DELETE,
        TICKET_CREATE,
        TICKET_UPDATE,
        TICKET_DELETE,
        CUSTOMER_CREATE,
        CUSTOMER_UPDATE,
        CUSTOMER_DELETE,
        MENU_ITEM_UPDATE,
        CHECK_OFFER
    }

    private Event triggerEvent;

    public Event getTriggerEvent() {
        return triggerEvent;
    }

    public void setTriggerEvent(Event triggerEvent) {
        this.triggerEvent = triggerEvent;
    }

    public String getTriggerEventString() {
        return triggerEvent.toString();
    }

    public void setTriggerEventString(String triggerEvent) {
        this.triggerEvent = Event.valueOf(triggerEvent);
    }    
}

      

Any idea what's going on? It doesn't even show what the error looks like.

+3


source to share


1 answer


java.lang.NoClassDefFoundError . This usually indicates that we previously tried to load the class from the classpath, but that failed for some reason - now we are trying to use the class again (and therefore need to load it since it failed the last time). but we're not even going to try to download it because we haven't done it before (and reasonably suspect we'll fail again). The earlier failure could be a ClassNotFoundException or ExceptionInInitializerError (indicating a failure in a static initialization block), or any number of other problems. The point is, NoClassDefFoundError is not necessarily a class problem.



When I deploy to Weblogic I often had a NoClassDefFoundError due to the Weblogic cache. Can you try to clear the jetty cache or rename an event rename like Event1 and try again?

+1


source







All Articles