Menu

ERROR COMPILING EXT GWT CLASS

Help
2008-07-08
2013-04-25
  • Daniele Renda

    Daniele Renda - 2008-07-08

    Hi all,
    I've an issue about enum. Infact with the hibernate4gwt (that use beanlib) is thrown an error in compiling this class of the library ext gwt:

    import java.util.Comparator;

    /**
    * Defines GXT public constants and enumerations.
    */
    public class Style {

    /**
      * Horizontal alignment enumeration.
      */
    public enum HorizontalAlignment {
       LEFT, CENTER, RIGHT
    }

    /**
      * Vertical alignment enumerations.
      */
    public enum VerticalAlignment {
       TOP, MIDDLE, BOTTOM;
    }

    /**
      * Scroll enumeration.
      */
    public enum Scroll {
       AUTO("auto"), ALWAYS("scroll"), NONE("hidden");
       private final String value;

       private Scroll(String value) {
         this.value = value;
       }

       public String value() {
         return value;
       }
    }

    /**
      * Sort direction enum.
      */
    public enum SortDir {

       NONE {
         @Override
         public Comparator comparator(Comparator c) {
           return c;
         }
       },

       ASC {
         @Override
         public <X> Comparator<X> comparator(final
    Comparator<X> c) {
           return new Comparator<X>() {
             public int compare(X o1, X o2) {
               return c.compare(o1, o2);
             }
           };
         }
       },

       DESC {
         @Override
         public <X> Comparator<X> comparator(final
    Comparator<X> c) {
           return new Comparator<X>() {
             public int compare(X o1, X o2) {
               return c.compare(o2, o1);
             }
           };
         }
       };

       public static SortDir toggle(SortDir sortDir) {
         return (sortDir == ASC) ? DESC : ASC;
       }

       /**
        * An example of how to use this :
        *
        * List<Something> list = ...
        *
        * Collections.sort(list, SortDir.ASC.comparator(new
    Comparator() { public
        * int compare(Object o1, Object o2) { return ... } });
        *
        *
        * @return a Comparator that wraps the specific
    comparator that orders the
        *         results acording to the sort direction
        */
       public abstract <X> Comparator<X>
    comparator(Comparator<X> c);
    }

    /**
      * Layout out regions.
      */
    public enum LayoutRegion {
       NORTH, EAST, SOUTH, WEST, CENTER;
    }

    public enum Direction {
       UP, DOWN, LEFT, RIGHT;
    }

    /**
      * Scroll direction enum.
      */
    public enum ScrollDir {
       VERTICAL, HORIZONTAL;
    }

    /**
      * Selection mode enum.
      */
    public enum SelectionMode {
       SINGLE, SIMPLE, MULTI;
    }

    /**
      * Orientation enum.
      */
    public enum Orientation {
       VERTICAL, HORIZONTAL;
    }

    /**
      * A constant known to be zero (0).
      */
    public static final int NONE = 0;

    /**
      * Indicates that a default value should be used (value is
    -1).
      */
    public static final int DEFAULT = -1;

    /**
      * Constant for marking a string as undefined rather than
    null.
      */
    public static final String UNDEFINED = "undefined";

    }

    The exception is:
    GRAVE: Exception while dispatching incoming RPC call
    net.sf.beanlib.BeanlibException: java.lang.NoSuchMethodException: com.extjs.gxt.ui.client.Style$SortDir$1.<init>()
    at net.sf.beanlib.provider.replicator.BeanReplicator.replicateBean(BeanReplicator.java:103)
    at net.sf.beanlib.hibernate3.Hibernate3JavaBeanReplicator.replicateBean(Hibernate3JavaBeanReplicator.java:71)
    at net.sf.beanlib.provider.replicator.ReplicatorTemplate.replicateByBeanReplicatable(ReplicatorTemplate.java:115)
    at net.sf.beanlib.provider.replicator.ReplicatorTemplate.replicate(ReplicatorTemplate.java:110)
    at net.sf.beanlib.provider.BeanTransformer.transform(BeanTransformer.java:123)
    at net.sf.beanlib.provider.BeanPopulator.doit(BeanPopulator.java:169)
    at net.sf.beanlib.provider.BeanPopulator.processSetterMethod(BeanPopulator.java:133)
    at net.sf.beanlib.provider.BeanPopulator.populate(BeanPopulator.java:104)
    at net.sf.beanlib.provider.replicator.ReplicatorTemplate.populateBean(ReplicatorTemplate.java:164)
    at net.sf.beanlib.provider.replicator.BeanReplicator.replicateBean(BeanReplicator.java:107)
    at net.sf.beanlib.hibernate3.Hibernate3JavaBeanReplicator.replicateBean(Hibernate3JavaBeanReplicator.java:71)
    at net.sf.beanlib.provider.replicator.ReplicatorTemplate.replicateByBeanReplicatable(ReplicatorTemplate.java:115)
    at net.sf.beanlib.provider.replicator.ReplicatorTemplate.replicate(ReplicatorTemplate.java:110)
    at net.sf.beanlib.provider.BeanTransformer.transform(BeanTransformer.java:123)
    at net.sf.beanlib.provider.BeanPopulator.doit(BeanPopulator.java:169)
    at net.sf.beanlib.provider.BeanPopulator.processSetterMethod(BeanPopulator.java:133)
    at net.sf.beanlib.provider.BeanPopulator.populate(BeanPopulator.java:104)
    at net.sf.hibernate4gwt.core.LazyKiller.populate(LazyKiller.java:253)
    at net.sf.hibernate4gwt.core.LazyKiller.attach(LazyKiller.java:211)
    at net.sf.hibernate4gwt.core.HibernateBeanManager.mergePojo(HibernateBeanManager.java:508)
    at net.sf.hibernate4gwt.core.HibernateBeanManager.merge(HibernateBeanManager.java:282)
    at net.sf.hibernate4gwt.gwt.HibernateRPCHelper.parseInputParameters(HibernateRPCHelper.java:80)
    at net.sf.hibernate4gwt.gwt.HibernateRemoteService.processCall(HibernateRemoteService.java:164)
    at com.google.gwt.user.server.rpc.RemoteServiceServlet.doPost(RemoteServiceServlet.java:85)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:390)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
    at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
    at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
    at java.lang.Thread.run(Thread.java:619)
    Caused by: java.lang.NoSuchMethodException: com.extjs.gxt.ui.client.Style$SortDir$1.<init>()
    at java.lang.Class.getConstructor0(Class.java:2706)
    at java.lang.Class.getDeclaredConstructor(Class.java:1985)
    at net.sf.beanlib.provider.replicator.ReplicatorTemplate.newInstanceAsPrivileged(ReplicatorTemplate.java:202)
    at net.sf.beanlib.hibernate3.Hibernate3JavaBeanReplicator.createToInstance(Hibernate3JavaBeanReplicator.java:66)
    at net.sf.hibernate4gwt.core.beanlib.merge.MergeClassBeanReplicator.createToInstance(MergeClassBeanReplicator.java:215)
    at net.sf.beanlib.provider.replicator.BeanReplicator.replicateBean(BeanReplicator.java:95)
    ... 40 more

    It's a bug or there is some action that I can make to avoid this problem?

    Thanks a lot!

     
    • Hanson Char

      Hanson Char - 2008-07-08

      Hi Daniele,

      I just wrote a test class (using beanlib-3.3.0beta17) against your style class, and it ran without any problem.  Could the problem be more related to hibernate4gwt ?

      Hanson

      import net.sf.beanlib.hibernate.HibernateBeanReplicator;
      import net.sf.beanlib.hibernate3.Hibernate3BeanReplicator;

      public class TestStyle {
          public static void main(String[] args) {
              HibernateBeanReplicator replicator = new Hibernate3BeanReplicator();
              Style from = new Style();
              Style toDeep = replicator.deepCopy(from);
              System.out.println(from);
              System.out.println(toDeep);
              Style to = replicator.copy(from);
              System.out.println(to);
          }
      }

       
      • Hanson Char

        Hanson Char - 2008-07-08

        In fact your Style class doesn't even have anything to do with Hibernate. So alternatively you can use BeanReplicator directly.  See below for an example.  It also runs without any problem.

        Hanson

        package beanlib;

        import net.sf.beanlib.provider.replicator.BeanReplicator;

        public class TestStyle2 {
            public static void main(String[] args) {
                BeanReplicator replicator = new BeanReplicator();
               
                Style from = new Style();
                Style to = replicator.replicateBean(from);
                System.out.println(from);
                System.out.println(to);
            }
        }

         
    • Daniele Renda

      Daniele Renda - 2008-07-09

      Hi Hanson,
      thanks very much for you replay.

      I'm testing this solution in this days.

      THanks!!

       
    • Bruno Marchesson

      Hi all,

      The issue comes from the 'SortDir' enum, which is declared in the style class but not a member of it.
      The following test case must be failing :

      public static void main(String[] args) {
      HibernateBeanReplicator replicator = new Hibernate3BeanReplicator();
      Style.SortDir from = Style.ASC;
      Style.SortDir toDeep = replicator.deepCopy(from);
      System.out.println(from);
      System.out.println(toDeep);
      Style.SortDir to = replicator.copy(from);
      System.out.println(to);
      }

      Regards
      Bruno

       
      • Hanson Char

        Hanson Char - 2008-07-13

        Hi Bruno,

        This is interesting.  Apparently the problem is caused by

          Style.SortDir.ASC.getClass().isEnum()

        which unexpectedly returns false!

        To get around this problem is easy, though.  Will be cutting a release shortly.

        Thanks for reporting this!

        Hanson

         
      • Hanson Char

        Hanson Char - 2008-07-13

        Hi Bruno,

        Can you try out the latest release, beanlib-3.3.0beta19, to see if it fixes the problem ?

        Thanks,
        hanson

         
    • Bruno Marchesson

      Hi Hanson,

      Great : it works fine !

      Many thanks
      Bruno

       

Log in to post a comment.