5 Replies Latest reply on Jul 20, 2009 9:43 AM by Werner van Mook

    Caching, hybernate and using enums => no go

    Werner van Mook Newbie

      Hi,

      We have JBoss AS 5.1.0 and use hibernate to store our session beans in MySQL DB. Also pojo caching is used to make the objects available throughout the cluster.

      For both hibernate and caching we use annotations.
      @Replicable for classes that need to go into cache and
      @Entity for objects that need to be stored using hibernate.

      We compile everything and the @Replicable classes with aopc.

      If we deploy the created jar file and start JBoss we get a java.lang.VerifyError.

      This error originates from a switch statement that is using an enum to switch.

      The enum is defined in a @Replicable class called HelperClass
      the switch method is defined in the bean called Request

      Disabling hibernate OR @Replicable OR both there is no problem starting JBoss.

      I can not imagine that this is an unknown problem, one of you probably must have had the same problem. If so what was the solution?

      Kind regards,
      Werner van Mook





      package entity;
      
      import org.jboss.cache.pojo.annotation.Replicable;
      import org.jboss.cache.pojo.annotation.Transient;
      
      
      @Replicable
      public class HelperClass {
      
       private RuntimeStateRange runtimeState = RuntimeStateRange.RESTING;
      
       public static enum RuntimeStateRange {
       OFFLINE,
       CONNECTED,
       PROBLEM,
       PROBLEM_CONNECTING,
       PROBLEM_SENDING,
       INTERRUPTED,
       STOPPED,
       INVALID,
       RESTING,
       BUSY,
       INITIALIZING };
      
       public HelperClass() {
       System.out.println("HelperClass created.");
       }
      
       public int EnumgetRuntimeState() {
       return this.runtimeState.ordinal();
       }
      
       public RuntimeStateRange getRuntimeStateRange(){
       return runtimeState;
       }
      }




      package entity;
      
      import javax.persistence.Entity;
      import javax.persistence.GeneratedValue;
      import javax.persistence.Id;
      
      import org.jboss.cache.pojo.annotation.Replicable;
      
      import entity.HelperClass.RuntimeStateRange;
      
      @Entity
      @Replicable
      public class Request {
      
       private long id;
       private String filename;
      
      
       public Request(){
       }
      
       /**
       * @return the id
       */
       @Id
       @GeneratedValue
       public long getId() {
       return id;
       }
      
       /**
       * @param id the id to set
       */
       public void setId(long id) {
       this.id = id;
       }
      
       /**
       * @return the filename
       */
       public String getFilename() {
       return filename;
       }
      
       /**
       * @param filename the filename to set
       */
       public void setFilename(String filename) {
       this.filename = filename;
       }
      
       @Override
       public String toString() {
       return "id: " + id + " filename: " + filename;
       }
      
       public void inform() {
       HelperClass help = new HelperClass();
       informDeviceStateWhileHavingFullLock(help);
       }
      
       private void informDeviceStateWhileHavingFullLock(HelperClass osDeviceState) {
      // Thread.currentThread().setName("JMS Inform device " + getName() + " " + osDeviceState.EnumgetRuntimeState().toString());
       switch (osDeviceState.getRuntimeStateRange()) {
       case PROBLEM_CONNECTING:
       System.out.println(osDeviceState.EnumgetRuntimeState());
       break;
       case PROBLEM_SENDING:
       System.out.println(osDeviceState.EnumgetRuntimeState());
       break;
       case CONNECTED:
       System.out.println(osDeviceState.EnumgetRuntimeState());
       break;
       case INVALID:
       System.out.println(osDeviceState.EnumgetRuntimeState());
       break;
       case INTERRUPTED:
       System.out.println(osDeviceState.EnumgetRuntimeState());
       break;
       case STOPPED:
       System.out.println(osDeviceState.EnumgetRuntimeState());
       break;
       default:
       System.out.println("Device state default is always ignored");
       break;
       }
       }
      
      
      }