Getting java.lang.NoClassDefFoundError: com/vaadin/data/Property using Metawidget with Vaadin

486 Views Asked by At

I am trying to use Metawidget with Vaadin and getting the following error when I run my code

java.lang.NoClassDefFoundError: com/vaadin/data/Property

I am using Vaadin 8 and Metawidget 4.2 (latest available release). I did track down the exception to the code below in org.metawidget.vaadin.ui.widgetprocessor.binding.simple.SimpleBindingProcessor

    // SimpleBindingProcessor only binds to Property components (TextFields, Labels, etc)

    if ( !( component instanceof Property ) ) {
        return component;
    }

I checked the Vaadin API and the interface com.vaadin.data.Property exists in Vaadin 7.x but not in 8.x. It looks like Metawidget has not been ported to work with Vaadin 8.x and above. I have used Metawidget with Java Swing and I am extremely happy with the productivity gain it has offered and would love to use it with Vaadin as well. I am looking for suggestions on how to proceed. (Probably questions 2 to 5 is for @Richard Kennard / @Loghman Barari )

  1. Has anyone used Metawidget with Vaadin 8.x and above? What is the effort to extend Metawidget and make the necessary changes?
  2. Is there a plan for releasing a new version of Metawidget with support for Vaadin 8.x and above?
  3. Is there a class I can use that is already part of Metawidget, that I am not aware of?
  4. In continuation of question 1, Can I get a sense of the effort required for the migration so that I can attempt to enhance Metawidget to support Vaadin8.x and above?
  5. Is my only option to use Vaadin 7.x?

My code is below

@Theme("mytheme")
public class MyUI extends UI {

    @Override
    protected void init(VaadinRequest vaadinRequest) {

    VerticalLayout layoutPlaceHolder = new VerticalLayout();
    VaadinMetawidget myMetawidget = new VaadinMetawidget();

    Person p = new Person("Mr", "Pramod C S", 40, false);
    myMetawidget.setToInspect(myMetawidget);

    layoutPlaceHolder.addComponent(myMetawidget);

    setContent(layoutPlaceHolder);
    }

    @WebServlet(urlPatterns = "/*", name = "MyUIServlet", asyncSupported = true)
    @VaadinServletConfiguration(ui = MyUI.class, productionMode = false)
    public static class MyUIServlet extends VaadinServlet {
    }
}

The Person class code is below

import org.metawidget.inspector.annotation.UiSection;

public class Person {
    private String title;
    private String  name;
    private int     age;
    private boolean retired;

    public Person() {
        // TODO Auto-generated constructor stub
    }
    public Person(String title, String name, int age, boolean retired) {
        this.name = name;
        this.age = age;
        this.retired = retired;
        this.title = title;
    }

    public String getName() { return name; }
    public void setName( String name ) { this.name = name; }

    public int getAge() { return age; }
    public void setAge( int age ) { this.age = age; }

    @UiSection(value = { "Test" }) 
    public boolean isRetired() { return retired; }
    public void setRetired( boolean retired ) { this.retired = retired; }

    public String getTitle() { return title;}
    public void setTitle(String  title) {this.title = title;}
}
2

There are 2 best solutions below

1
On

Apparently there has not been new releases of the Metawidget for while based on their version history, and thus lacking support for latest frameworks including new Vaadin versions. However there are couple of alternatives

With Vaadin 8 you could use Crud UI add-on and with Vaadin Platform (v12 or newer required) there is new Vaadin Crud component, which are not exactly the same, but target to help the same use cases.

0
On

Metawidget is still being developed (albeit much more slowly) but I'm personally focusing more on JavaScript frameworks (like Vue). However I'd love for someone to take up the mantle and port Metawidget to Vaadin 8!

In terms of 'how much work', the whole source code for VaadinMetawidget is only a couple of thousand lines (including whitespace and comments) so probably not too much. Most of the functionality is handled by the Pipeline helper class. If you have experience porting Vaadin 7 components to Vaadin 8 it should (hopefully) be straightforward.