JPAContainer NoSuchMethodException

Hello all!

I have noticed a new error while debugging my app that wasn’t there before and I am not quite sure what I have done! I have a form with the datasource of the form set to one of my entityitems (Either a new entityitem or existing depending if I am creating a new entity or editing an existing. One of the entityitems fields is a reference column to another entity. In my formfactory I have created a combobox and set the containerdatasource to my JPAContainer for that referenced entity. I have also overriden the getItemCaption() function to make the combobox items more human readable. This worked perfectly for a while, but now when I commit the form I get the following error:

Caused by: com.vaadin.data.Buffered$SourceException
        at com.vaadin.ui.Form.commit(Form.java:365)
        at com.vacom.client.ui.page.BillboardPage$ContractWindow$1.buttonClick(BillboardPage.java:1010)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at com.vaadin.event.ListenerMethod.receiveEvent(ListenerMethod.java:490)
        ... 35 more
Caused by: com.vaadin.data.Buffered$SourceException
        at com.vaadin.ui.AbstractField.commit(AbstractField.java:246)
        at com.vaadin.ui.Form.commit(Form.java:339)
        ... 41 more
Caused by: com.vaadin.data.Property$ConversionException: java.lang.NoSuchMethodException: com.vacom.client.model.LightingPlan.<init>(java.lang.String)
        at com.vaadin.addon.jpacontainer.JPAContainerItem$ItemProperty.setValue(JPAContainerItem.java:247)
        at com.vaadin.ui.AbstractField.commit(AbstractField.java:241)
        ... 42 more
Caused by: java.lang.NoSuchMethodException: com.vacom.client.model.LightingPlan.<init>(java.lang.String)
        at java.lang.Class.getConstructor0(Class.java:2706)
        at java.lang.Class.getConstructor(Class.java:1657)
        at com.vaadin.addon.jpacontainer.JPAContainerItem$ItemProperty.setValue(JPAContainerItem.java:241)
        ... 43 more

I overrode the commit() function for the combobox to see what class the getValue() is and it is an Integer representing the item id for my container, so I am not sure why it is looking for a String constructor for that entity. I recently tried to use Vaadin 6.6.1, but ran into so many issues that I backtracked to 6.5.6. Like I said, it was initially working fine, but now I get this error. Any ideas?

Thanks,
Scott

Alright, for some reason the combobox is not binding the data correct. This is what I have:

            ContractFieldFactory fieldFactory = new ContractFieldFactory();
            final Form contractForm = new Form(); 
            contractForm.setFormFieldFactory(fieldFactory);
            contractForm.setWriteThrough(false);
            contractForm.setItemDataSource(contract);  // where contract = EntityItem<Contract>
            contractForm.setVisibleItemProperties(
                        new String[]{"name",
                            "schedule",
                            "scheduleStart",
                            "scheduleEnd"});

In my fieldFactory:

            JPAContainer<Schedule> scheduleContainer = new JPAContainer<Schedule>(Schedule.class);

            @Override
            public Field createField(Item itemId, Object propertyId, Component uiContext) {
                 if ("schedule".equals(propertyId)) {
                    ComboBox cb = new ComboBox("Schedule",scheduleContainer );
                    cb.setRequired(true);
                    cb.setItemCaptionPropertyId("name");
                    cb.setNullSelectionAllowed(false);
                    cb.setRequiredError("Please select a Schedule");
                    cb.setImmediate(true);
                    return cb;
                } 
            }

It seems as though when I try to commit the form it is trying to set the Value for schedule to the Integer value of the selected combobox schedule. Since it is looking for the schedule entity and not an Integer, the error is thrown.

The only way I have found around this is to override the commit() function of the combobox to do nothing:

                    ComboBox cb = new ComboBox("Schedule",scheduleContainer ) {
                        
                        @Override
                        public void commit() {}
                        
                    };

Then handle it on my own. The problem with that is that when I edit an existing contract, the combobox doesn’t show the current schedule as the current value.

I am hoping someone can shed some light on this. I have to believe that I made a small mistake somewhere, b/c this WAS working.

Thanks,
Scott

I think you problem has the same cause as mine.

http://vaadin.com/forum/-/message_boards/view_message/341397

I received some suggestions here on the forum, but because of the fact that I now have to reengineering a giant application in PL/SQL (and tha fact that the MTB season has started and I do need to train a lot B) ) I did not have time yet to solve my case. That particular project is for now on hold, but I am sure I’ll continue on it soon. I am looking froward to that.