Problems with integrating GWT widget

Hi folks,
a group of mine is implementing a web application with Vaadin. Everything is fine and everything works fine. But we have a little problem. We want to integrate one GWT widget into our Vaadin web application. I followed the instruction in the Vaadin book and i was able to run the the build-widgeset.xml and everything. Now i wanted to add the widget as a component into the web application and to deploy it on a server to test if everything works.
When i start my browser (e.g. Firefox or IE) nothing appears. No widget, nothing. Just the grey background from the Vaadin default theme. In Hosted Mode i got a java.lang.NoSuchMethod error. And he tells me that he failed to load the module.
I don’t know where the mistake could be and i am desperate, because the web application has to be finished in a few weeks. Please help me.
If it is necessary i would post the code. But maybe you are familiar with this problem.
Thanks for your help

Greetz

Ace

Hi,

Hard to say directly. This might be some missing javascript files or a small mistake in widgetset configuration.

I have gone through the widget development process a few times, I’ll share my thoughts for some sanity checks:

  • Correct “inheritance” and entry point class name in your gwt.xml file (should be if it compiles):
<module>
	<!-- Inherit super widgetset -->
	<inherits name="com.vaadin.terminal.gwt.DefaultWidgetSet" /> 
	
	<!-- Entry point -->
	<entry-point class="com.example.test.client.TestApplicationWidgetset"/>
</module>
  • The actual widgetset class (above: com.example.test.client.TestApplicationWidgetset) correctly implements the two required functions:

public Paintable createWidget(UIDL uidl) and

protected Class<?> resolveWidgetType(UIDL uidl)
  • GWT enforces a certain directory structure (the “client” package naming above).
  • To activate the widgetset Make sure the application web.xml contains the widgetset entry like:
<init-param>
	<param-name>widgetset</param-name>
	<param-value>com.example.test.TestApplicationWidgetset</param-value>
</init-param>
  • In deployment phase make sure the VAADIN subdirectory (containing the compiled widgetsets) is included in war file.
  • And finally: please recheck that you don’t have misspelled any of those looong widgetset names in build-widgetset.xml or in web xml. I made an error with mixed-case names that made it to fail during deployment.

You should be able to avoid most of these mistakes if using the Eclipse plugin. Just use the wizards to create widgetset and the component stubs and continue from there. I recommend that :slight_smile:

This NoSuchMethod exception is something I have not encountered. Anyone else seen one of these?

Thanks for this fast response. I have checked all these things several times. You won’t belive how exactly you can spell a word -_-
I think the best thing would be i add the code right here:

  • de.decidr.ui.gwt.ModelingToolWidgetSet.gwt.xml
    This is the gwt.xml file.
    <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE module PUBLIC "-//Google Inc.//DTD Google Web Toolkit 1.6.4//EN" "http://google-web-toolkit.googlecode.com/svn/tags/1.6.4/distro-source/core/src/gwt-module.dtd"> <module> <!-- Inherit the core Web Toolkit stuff. --> <inherits name='com.google.gwt.user.User'/> <!-- Inherit the default GWT style sheet. You can change --> <!-- the theme of your GWT application by uncommenting --> <!-- any one of the following lines. --> <inherits name='com.google.gwt.user.theme.standard.Standard'/> <!-- Inherit NoEntry version to avoid multiple entrypoints --> <inherits name="com.vaadin.terminal.gwt.DefaultWidgetSetNoEntry" /> <inherits name="de.decidr.modelingtool.ModelingTool" /> <inherits name='com.allen_sauer.gwt.dnd.gwt-dnd'/> <inherits name='com.extjs.gxt.ui.GXT'/> <!-- Entry point --> <entry-point class="de.decidr.ui.gwt.client.ModelingToolWidgetSet"/> </module>
  • de.decidr.ui.gwt.client.ModelingToolWidgetSet.java
    This is the widget set.
    [code]


    /*
  • The DecidR Development Team licenses this file to you under
  • the Apache License, Version 2.0 (the “License”); you may
  • not use this file except in compliance with the License.
  • You may obtain a copy of the License at
  • http://www.apache.org/licenses/LICENSE-2.0
  • Unless required by applicable law or agreed to in writing,
  • software distributed under the License is distributed on an
  • “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  • KIND, either express or implied. See the License for the
  • specific language governing permissions and limitations
  • under the License.
  • /

    package de.decidr.ui.gwt.client;

    import com.vaadin.terminal.gwt.client.DefaultWidgetSet;
    import com.vaadin.terminal.gwt.client.Paintable;
    import com.vaadin.terminal.gwt.client.UIDL;

    import de.decidr.ui.gwt.client.ui.VModelingTool;

    /**
  • TODO: add comment
  • @author AT
  • /
    public class ModelingToolWidgetSet extends DefaultWidgetSet {

    /* (non-Javadoc)
  • @see com.vaadin.terminal.gwt.client.DefaultWidgetSet#resolveWidgetType(com.vaadin.terminal.gwt.client.UIDL)
  • /
    @Override
    protected Class resolveWidgetType(UIDL uidl) {
    final String tag = uidl.getTag();
    if(“modelingtool”.equals(tag)){
    return VModelingTool.class;
    }
    return super.resolveWidgetType(uidl);
    }

    /* (non-Javadoc)
  • @see com.vaadin.terminal.gwt.client.DefaultWidgetSet#createWidget(com.vaadin.terminal.gwt.client.UIDL)
  • /
    @Override
    public Paintable createWidget(UIDL uidl) {
    final Class type = resolveWidgetType(uidl);
    if(VModelingTool.class == type){
    VModelingTool vModelingTool = new VModelingTool();
    vModelingTool.init(0L);
    return vModelingTool;
    }
    return super.createWidget(uidl);
    }

    }

    [/code]
  • de.decidr.gwt.client.ui.VModelingTool.java
    This is the vaadin specific modeling tool. It extends the GWT widget.
    [code]

    /*
  • The DecidR Development Team licenses this file to you under
  • the Apache License, Version 2.0 (the “License”); you may
  • not use this file except in compliance with the License.
  • You may obtain a copy of the License at
  • http://www.apache.org/licenses/LICENSE-2.0
  • Unless required by applicable law or agreed to in writing,
  • software distributed under the License is distributed on an
  • “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  • KIND, either express or implied. See the License for the
  • specific language governing permissions and limitations
  • under the License.
  • /

    package de.decidr.ui.gwt.client.ui;

    import com.vaadin.terminal.Paintable;
    import com.vaadin.terminal.gwt.client.ApplicationConnection;
    import com.vaadin.terminal.gwt.client.UIDL;

    import de.decidr.modelingtool.client.ModelingToolWidget;

    /**
  • TODO: add comment
  • @author AT
  • /
    public class VModelingTool extends ModelingToolWidget implements com.vaadin.terminal.gwt.client.Paintable {

    private String uidlId;

    private ApplicationConnection client;

    private final String CLASSNAME = “modelingtool”;

    /**
  • TODO: add comment
  • /
    public VModelingTool() {
    super();
    setStyleName(CLASSNAME);
    }

    /* (non-Javadoc)
  • @see com.vaadin.terminal.gwt.client.Paintable#updateFromUIDL(com.vaadin.terminal.gwt.client.UIDL, com.vaadin.terminal.gwt.client.ApplicationConnection)
  • /
    @Override
    public void updateFromUIDL(UIDL uidl, ApplicationConnection client) {
    if (client.updateComponent(this, uidl, true))
    return;

    this.client = client;

    uidlId = uidl.getId();

    }



    }

    [/code]
  • de.decidr.ui.view.ModelingTool
    This class should be the server side component or better the custom component so i can add i to the application.
    [code]

    /*
  • The DecidR Development Team licenses this file to you under
  • the Apache License, Version 2.0 (the “License”); you may
  • not use this file except in compliance with the License.
  • You may obtain a copy of the License at
  • http://www.apache.org/licenses/LICENSE-2.0
  • Unless required by applicable law or agreed to in writing,
  • software distributed under the License is distributed on an
  • “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  • KIND, either express or implied. See the License for the
  • specific language governing permissions and limitations
  • under the License.
  • /

    package de.decidr.ui.view;

    import java.util.Map;

    import com.vaadin.terminal.PaintException;
    import com.vaadin.terminal.PaintTarget;
    import com.vaadin.ui.AbstractComponent;
    import com.vaadin.ui.AbstractField;

    /**
  • TODO: add comment
  • @author AT
  • /
    public class ModelingTool extends AbstractComponent {

    /**
  • TODO: add comment
  • /
    public ModelingTool() {
    super();
    }

    /* (non-Javadoc)
  • @see com.vaadin.ui.AbstractComponent#getTag()
  • /
    @Override
    public String getTag() {
    return “modelingtool”;
    }

    /* (non-Javadoc)
  • @see com.vaadin.ui.AbstractField#paintContent(com.vaadin.terminal.PaintTarget)
  • /
    @Override
    public void paintContent(PaintTarget target) throws PaintException {

    super.paintContent(target);

    }

    /* (non-Javadoc)
  • @see com.vaadin.ui.AbstractField#changeVariables(java.lang.Object, java.util.Map)
  • /
    @Override
    public void changeVariables(Object source, Map variables) {

    super.changeVariables(source, variables);
    }

    }

    [/code]

The whole GWT implementation is in another project called ModelingTool. You can assume that there everything is correct.
Thanks for your help

Greetz

Ace

Hi Ace,
I was having a bit of difficulty with the integration of custom widgets too (including the blank, grey screen problem you mentioned :stuck_out_tongue: ). The problem in my case ended up being having the GWT widget classes and the widgetset .gwt.xml in the wrong packages. To make it easier for myself in the future, I created a Maven Archetype that generates a demo application with a custom GWT widgetset and its buildfile.

In case it’s helpful to you, I uploaded the archetype, and instructions on how to use it here:

http://dev.vaadin.com/wiki/Articles/MavenIntegration

Cheers,
Daniel

Hi Daniel,
thank you for your response. But i have a problem. If i create the demo application with the archetype my system connects with the maven repository and tries to find the com.vaadin.vaadin-archetype. But there isn’t such a package. I have installed it into my local repository ~/.m2 but i won’t work. So i even can’t try this. And if I try to add a custom widget to an existing application everything works fine, but in the WEB-INF/VAADIN folder there isn’t a folde named widgetset. So the question from which point do i have to name my folder. Because you wrote


<configuration>
                        <!-- if you don't specify any modules, the plugin will find them -->
                        <!--modules>
                            ..
                        </modules-->
                        <webappDirectory>[b]
${project.build.directory}/${project.build.finalName}/
[/b]VAADIN/widgetsets</webappDirectory>
                        <gwtVersion>${gwt.version}</gwtVersion>
                        <extraJvmArgs>-Xmx512M -Xss1024k</extraJvmArgs>
                    </configuration>

where do i have to define the variables project.build.directory and project.build.finalName. Or can i put a local path in?

Greetz

'Ace

Ok i tried it with the archetype. I got it to work. The main difference is that the pom.xml takes care of everything. That means that the build-widgetset.xml is integrated in the pom.xml. Nothing else. Or am i wrong.
The way with the .xml file is cleaner in my opinion. But that is different from person to person.
But i think i made everything right and i doesn’t work. Could it be, that the widget is realized in a different project? But i inherited the projects, and everything works find i could build the widgetset. The folder widgetset under WEB-INF/VAADIN is created. The only thing is that the component isn’t shown in my browser.
Please please help me. If you want information i will give you the information. But that thing must work.

Thanks

Greetz

Ace

Hi Ace,
Sorry to disappoint you, but I’m definitely no expert in this area. One thing that does stand out to me as out of the ordinary is that you’re saying your VAADIN directory is inside your WEB-INF directory. From memory VAADIN, WEB-INF, and META-INF should all be in the same directory.
Regarding your questions about the Maven build variables (e.g. ${project.build.finalName}), those are automatically resolved by Maven, though you can certainly replace them with hardcoded paths. It sounds like you’re not much of a fan of Maven :slight_smile: , but if you change your mind, there’s loads of information about using Maven at http://maven.apache.org/ .
Good luck Mate!

Daniel

Hi Daniel
sorry you are right.
I wanted to say, that my VAADIN folder is in the webapp folder. So everything is allright. META-INF, WEB-INF and VAADIN are in the same directory.
Oh i am a fan of maven really, but the way explained in the book is cleaner for me. But that is different from person to person.
Okay i just wondered where these variables are resolved but now it’s clear.
I hope somebody else can help me. Because i think i made everything correct and the folder structure is correct, too. So i am wondering where the mistake could be.
But thanks for your help i will post my solution if i will have one -_-
But i appreciate some new information from other users.

thanks

Greetz

Ace

Hi folks
could it be that Vaadin has problems to integrate widgets which are in a different project? Because in every demo application i see that the GWT widget is integrated in the gwt.client.ui package.
In my case the widget is in a different project and so i have to inherit this project in my .gwt.xml. Which leads to the result that the compiler asks me for the depending .gwt.xml and there is an other entry point. Does this matter? Or do i have to uncomment this entry point and just have one entry point in my .gwt.xml?

Greetz

Ace

Hi Ace

I have made custom widget as own project and inheriting it in a another project. So I guess it’s not a problem in Vaadin. If I remember right you can have only one entry point. That is why your project should inherit *NoEntry.xml file of your custom widget.

Pete

I forgot to mention that I used Sami’s readme.txt when making my own widget as a different project. You can read it from
incubator
.

With recent Vaadin versions (from 5.3), it is no longer necessary to inherit the NoEntry version, as only one widgetset entry point will be taken into consideration.

This was addressed in http://dev.vaadin.com/ticket/2494.

Quoting the ticket:

“This is done via a convention: the .gwt.xml now needs to have the same ‘simple name’ as the entry-point (aka widgetset.java), and the entry-point must be in the same package:
com.example.gwt.FooWidgetSet?.gwt.xml → com.example.gwt.client[.optional.package]
.FooWidgetSet?.java”