Weird behaviour when I try to compile my Widgetset.

Hi Guys,

I was dealing these days with the problem of
“Widgetset does not contain implementation for…”
. I did all the checks that all of you mention through on the forum and nothing happened. However i’ve found the following behaviour when I compile my widgetset.

I am working on a widget that make use of jackson library to serialize a model on the server side and send it to the client.
Something like this:


@com.vaadin.ui.ClientWidget(com.pantar.widget.graph.client.ui.VGraphVisualization.class)
public class GraphVisualization extends AbstractComponent {
	...

	@Override
	public void paintContent(final PaintTarget pTarget) throws PaintException {
		super.paintContent(pTarget);

//		if (this.graphModelInitialized) {
//			JsonFactory factory = new JsonFactory();
//			ObjectMapper mapper = new ObjectMapper(f);
//			String graphModel = mapper.writeValueAsString(value)
//			
//			pTarget.addAttribute("graphModel", graphModel);
//			
//			this.graphModelInitialized = true;
//		}
	}
	...
}

I’ve realized that when I comment all the serialization stuff (like in the code above) the widgetset compiles successfully. If I uncomment that block of code and compile again, “My Widget” isn’t included on the client side, so when i do the deployement on the server and I try to get access to the application I get the famous: “Widgetset does not contain implementation for…”

I tried to change the serializer because thought that maybe the GWT has problem with the Jackson lib, so I tried to replace Jackson with json-lib but unfortunately I am getting the same results.

I don’t know if it is a problem with the GWT compiler or is an specific problem of the Vaadin Eclipse Plugin.

I am using Vaadin Eclipse Pluging to compile and Vaadin 6.6.0 version.

What I was doing to get it work, was compile the widgetset with the serialization stuff commented and then uncomment the code when I deploy on the server to test, but this is not a happy solution to the problem.

Can somebody tell me something about this behaviour? Does anybody has the same problem?

Your problem sounds quite odd. The only explanation that I can think of is that there is an error while compiling the server-side class, so that it is not compiled. Then, when the widgets in the widget set are determined using reflection from the @ClientWidget annotations, it is not found.

You could check that the file is really compiled in WebContent/WEB-INF/classes. (Or was it build/classes?)

But if you don’t see any compilation errors, I don’t see why it shouldn’t work. Eclipse can sometimes go into a bad state so that it doesn’t clear compilation errors in a project. In such rare cases, you may need to remove the project (not delete the files) and import it to get it fixed.

Hey Marko thanks for your response.

I’ve checked that the classes are compiled in the build/classes folder. Everything seems to be fine, however the widget isn’t included when I run the widgetset compilation.

I’ve created a new widget in another project to check if the problem is in the project where i am working, but i get the same results. I enabled the verbose compilation to see if there is a problem, but I can’t see nothing relevant.

The code that I am using is (the bold statement seems to be the problem):


@com.vaadin.ui.ClientWidget(com.widget.test.client.ui.VMyComponent.class)
public class MyComponent extends AbstractComponent {

	private String message = "Click here.";
	private int clicks = 0;

	@Override
	public void paintContent(final PaintTarget target) throws PaintException {
		super.paintContent(target);

		final JsonFactory factory = new JsonFactory();
		final ObjectMapper mapper = new ObjectMapper(factory);

		try {
			[b]
mapper.writeValueAsString(this.message);
[/b]

		} catch (final JsonGenerationException e) {
			throw new PaintException("JSONGeneration");
		} catch (final JsonMappingException e) {
			throw new PaintException("JSONMapping");
		} catch (final IOException e) {
			throw new PaintException("IO");
		}

		// Paint any component specific content by setting attributes
		// These attributes can be read in updateFromUIDL in the widget.
		target.addAttribute("clicks", this.clicks);
		target.addAttribute("message", this.message);

		// We could also set variables in which values can be returned
		// but declaring variables here is not required
	}

	/**
	 * Receive and handle events and other variable changes from the client.
	 * 
	 * {@inheritDoc}
	 */
	@Override
	public void changeVariables(final Object source, final Map<String, Object> variables) {
		super.changeVariables(source, variables);

		// Variables set by the widget are returned in the "variables" map.

		if (variables.containsKey("click")) {

			// When the user has clicked the component we increase the
			// click count, update the message and request a repaint so
			// the changes are sent back to the client.
			this.clicks++;
			this.message += "<br/>" + variables.get("click");

			this.requestRepaint();
		}
	}

}

When I try to compile the widget, the log that i get is:



Executing compiler with parameters 
[/home/em3/dev/java/jdk1.6.0_23/bin/java, -Djava.awt.headless=true, -Xss8M, -Xmx512M, -XX:MaxPermSize=512M, -classpath, /home/em3/dev/java/jdk1.6.0_23/jre/lib/rt.jar:/home/em3/dev/workspace/test-widget/src:/home/em3/dev/workspace/test-widget/build/classes:/home/em3/dev/eclipse/configuration/com.vaadin.integration.eclipse/download/gwt-dev/2.3.0/gwt-dev.jar:/home/em3/dev/eclipse/configuration/com.vaadin.integration.eclipse/download/gwt-user/2.3.0/gwt-user.jar:/home/em3/dev/workspace/test-widget/WebContent/WEB-INF/lib/vaadin-6.6.0.jar:/home/em3/dev/eclipse/configuration/com.vaadin.integration.eclipse/download/gwt-dependencies/2.3.0/validation-api-1.0.0.GA-sources.jar:/home/em3/dev/eclipse/configuration/com.vaadin.integration.eclipse/download/gwt-dependencies/2.3.0/validation-api-1.0.0.GA.jar:/home/em3/dev/eclipse/configuration/com.vaadin.integration.eclipse/download/gwt-user/2.3.0/gwt-user.jar:/home/em3/dev/eclipse/configuration/com.vaadin.integration.eclipse/download/gwt-dev/2.3.0/gwt-dev.jar, com.vaadin.tools.WidgetsetCompiler, -out, WebContent/VAADIN/widgetsets, -localWorkers, 2, -logLevel, INFO, com.widget.test.Test_widgetWidgetset]
Updating GWT module description file...
May 22, 2011 7:21:57 PM com.vaadin.terminal.gwt.widgetsetutils.ClassPathExplorer getAvailableWidgetSets
INFO: Widgetsets found from classpath:
	com.vaadin.terminal.gwt.DefaultWidgetSet in jar:file:/home/em3/dev/workspace/test-widget/WebContent/WEB-INF/lib/vaadin-6.6.0.jar!/
	com.widget.test.Test_widgetWidgetset in file:/home/em3/dev/workspace/test-widget/src

May 22, 2011 7:21:57 PM com.vaadin.terminal.gwt.widgetsetutils.ClassPathExplorer getAvailableWidgetSets
INFO: Search took 14ms
Done.
Starting GWT compiler
Compiling module com.widget.test.Test_widgetWidgetset
   Scanning for additional dependencies: jar:file:/home/em3/dev/workspace/test-widget/WebContent/WEB-INF/lib/vaadin-6.6.0.jar!/com/vaadin/terminal/gwt/client/WidgetSet.java
      Computing all possible rebind results for 'com.vaadin.terminal.gwt.client.WidgetMap'
         Rebinding com.vaadin.terminal.gwt.client.WidgetMap
            Invoking generator com.vaadin.terminal.gwt.widgetsetutils.EagerWidgetMapGenerator
               Detecting Vaadin components in classpath to generate WidgetMapImpl.java ...
May 22, 2011 7:22:29 PM com.vaadin.terminal.gwt.widgetsetutils.ClassPathExplorer getPaintablesHavingWidgetAnnotation
INFO: Searching for paintables..
May 22, 2011 7:22:30 PM com.vaadin.terminal.gwt.widgetsetutils.ClassPathExplorer getPaintablesHavingWidgetAnnotation
INFO: Search took 903ms
               Widget set will contain implementations for following components: 
               	com.vaadin.ui.AbsoluteLayout
               	com.vaadin.ui.Accordion
               	com.vaadin.ui.Button
               	com.vaadin.ui.CheckBox
               	com.vaadin.ui.ComboBox
               	com.vaadin.ui.CssLayout
               	com.vaadin.ui.CustomComponent
               	com.vaadin.ui.CustomLayout
               	com.vaadin.ui.DateField
               	com.vaadin.ui.DragAndDropWrapper
               	com.vaadin.ui.Embedded
               	com.vaadin.ui.Form
               	com.vaadin.ui.FormLayout
               	com.vaadin.ui.GridLayout
               	com.vaadin.ui.HorizontalLayout
               	com.vaadin.ui.HorizontalSplitPanel
               	com.vaadin.ui.InlineDateField
               	com.vaadin.ui.Label
               	com.vaadin.ui.Link
               	com.vaadin.ui.ListSelect
               	com.vaadin.ui.MenuBar
               	com.vaadin.ui.NativeButton
               	com.vaadin.ui.NativeSelect
               	com.vaadin.ui.OptionGroup
               	com.vaadin.ui.OrderedLayout
               	com.vaadin.ui.Panel
               	com.vaadin.ui.PasswordField
               	com.vaadin.ui.PopupView
               	com.vaadin.ui.ProgressIndicator
               	com.vaadin.ui.RichTextArea
               	com.vaadin.ui.Select
               	com.vaadin.ui.Slider
               	com.vaadin.ui.SplitPanel
               	com.vaadin.ui.TabSheet
               	com.vaadin.ui.Table
               	com.vaadin.ui.TextArea
               	com.vaadin.ui.TextField
               	com.vaadin.ui.Tree
               	com.vaadin.ui.TwinColSelect
               	com.vaadin.ui.Upload
               	com.vaadin.ui.UriFragmentUtility
               	com.vaadin.ui.VerticalLayout
               	com.vaadin.ui.VerticalSplitPanel
               	com.vaadin.ui.Window
               Done. (0seconds)
   Scanning for additional dependencies: jar:file:/home/em3/dev/workspace/test-widget/WebContent/WEB-INF/lib/vaadin-6.6.0.jar!/com/vaadin/terminal/gwt/client/ui/dd/VAcceptCriteria.java
      Computing all possible rebind results for 'com.vaadin.terminal.gwt.client.ui.dd.VAcceptCriterionFactory'
         Rebinding com.vaadin.terminal.gwt.client.ui.dd.VAcceptCriterionFactory
            Invoking generator com.vaadin.terminal.gwt.widgetsetutils.AcceptCriteriaFactoryGenerator
               Detecting available criteria ...
               creating mapping for com.vaadin.event.dd.acceptcriteria.Or
               creating mapping for com.vaadin.event.dd.acceptcriteria.And
               creating mapping for com.vaadin.event.dd.acceptcriteria.TargetDetailIs
               creating mapping for com.vaadin.ui.Tree.TreeDropCriterion
               creating mapping for com.vaadin.event.dd.acceptcriteria.Not
               creating mapping for com.vaadin.ui.Table.TableDropCriterion
               creating mapping for com.vaadin.event.dd.acceptcriteria.ServerSideCriterion
               creating mapping for com.vaadin.ui.Tree.TargetInSubtree
               creating mapping for com.vaadin.ui.AbstractSelect.AcceptItem
               creating mapping for com.vaadin.event.dd.acceptcriteria.ContainsDataFlavor
               creating mapping for com.vaadin.event.dd.acceptcriteria.SourceIsTarget
               creating mapping for com.vaadin.event.dd.acceptcriteria.AcceptAll
               creating mapping for com.vaadin.event.dd.acceptcriteria.SourceIs
               creating mapping for com.vaadin.ui.AbstractSelect.TargetItemIs
               Done. (0seconds)
   Compiling 6 permutations
      Compiling permutation 0...
      Process output
         Compiling
            Compiling permutation 1...
      Compiling permutation 2...
         Compiling
            Compiling permutation 3...
      Compiling permutation 4...
         Compiling
            Compiling permutation 5...
   Compile of permutations succeeded
   Linking into WebContent/VAADIN/widgetsets
      Link succeeded
   Compilation succeeded -- 182.779s

As I mentioned in my previous post, when I remove the serialization block, the widget compile Ok and the client implementation is included:


@Override
public void paintContent(final PaintTarget target) throws PaintException {
	super.paintContent(target);

	// Paint any component specific content by setting attributes
	// These attributes can be read in updateFromUIDL in the widget.
	target.addAttribute("clicks", this.clicks);
	target.addAttribute("message", this.message);

	// We could also set variables in which values can be returned
	// but declaring variables here is not required
}

The log info is:



Executing compiler with parameters 
[/home/em3/dev/java/jdk1.6.0_23/bin/java, -Djava.awt.headless=true, -Xss8M, -Xmx512M, -XX:MaxPermSize=512M, -classpath, /home/em3/dev/java/jdk1.6.0_23/jre/lib/rt.jar:/home/em3/dev/workspace/test-widget/src:/home/em3/dev/workspace/test-widget/build/classes:/home/em3/dev/eclipse/configuration/com.vaadin.integration.eclipse/download/gwt-dev/2.3.0/gwt-dev.jar:/home/em3/dev/eclipse/configuration/com.vaadin.integration.eclipse/download/gwt-user/2.3.0/gwt-user.jar:/home/em3/dev/workspace/test-widget/WebContent/WEB-INF/lib/vaadin-6.6.0.jar:/home/em3/dev/eclipse/configuration/com.vaadin.integration.eclipse/download/gwt-dependencies/2.3.0/validation-api-1.0.0.GA-sources.jar:/home/em3/dev/eclipse/configuration/com.vaadin.integration.eclipse/download/gwt-dependencies/2.3.0/validation-api-1.0.0.GA.jar:/home/em3/dev/eclipse/configuration/com.vaadin.integration.eclipse/download/gwt-user/2.3.0/gwt-user.jar:/home/em3/dev/eclipse/configuration/com.vaadin.integration.eclipse/download/gwt-dev/2.3.0/gwt-dev.jar, com.vaadin.tools.WidgetsetCompiler, -out, WebContent/VAADIN/widgetsets, -localWorkers, 2, -logLevel, INFO, com.widget.test.Test_widgetWidgetset]
Updating GWT module description file...
May 22, 2011 7:27:31 PM com.vaadin.terminal.gwt.widgetsetutils.ClassPathExplorer getAvailableWidgetSets
INFO: Widgetsets found from classpath:
	com.vaadin.terminal.gwt.DefaultWidgetSet in jar:file:/home/em3/dev/workspace/test-widget/WebContent/WEB-INF/lib/vaadin-6.6.0.jar!/
	com.widget.test.Test_widgetWidgetset in file:/home/em3/dev/workspace/test-widget/src

May 22, 2011 7:27:32 PM com.vaadin.terminal.gwt.widgetsetutils.ClassPathExplorer getAvailableWidgetSets
INFO: Search took 6ms
Done.
Starting GWT compiler
Compiling module com.widget.test.Test_widgetWidgetset
   Scanning for additional dependencies: jar:file:/home/em3/dev/workspace/test-widget/WebContent/WEB-INF/lib/vaadin-6.6.0.jar!/com/vaadin/terminal/gwt/client/WidgetSet.java
      Computing all possible rebind results for 'com.vaadin.terminal.gwt.client.WidgetMap'
         Rebinding com.vaadin.terminal.gwt.client.WidgetMap
            Invoking generator com.vaadin.terminal.gwt.widgetsetutils.EagerWidgetMapGenerator
               Detecting Vaadin components in classpath to generate WidgetMapImpl.java ...
May 22, 2011 7:28:11 PM com.vaadin.terminal.gwt.widgetsetutils.ClassPathExplorer getPaintablesHavingWidgetAnnotation
INFO: Searching for paintables..
May 22, 2011 7:28:12 PM com.vaadin.terminal.gwt.widgetsetutils.ClassPathExplorer getPaintablesHavingWidgetAnnotation
INFO: Search took 930ms
               Widget set will contain implementations for following components: 
               	com.vaadin.ui.AbsoluteLayout
               	com.vaadin.ui.Accordion
               	com.vaadin.ui.Button
               	com.vaadin.ui.CheckBox
               	com.vaadin.ui.ComboBox
               	com.vaadin.ui.CssLayout
               	com.vaadin.ui.CustomComponent
               	com.vaadin.ui.CustomLayout
               	com.vaadin.ui.DateField
               	com.vaadin.ui.DragAndDropWrapper
               	com.vaadin.ui.Embedded
               	com.vaadin.ui.Form
               	com.vaadin.ui.FormLayout
               	com.vaadin.ui.GridLayout
               	com.vaadin.ui.HorizontalLayout
               	com.vaadin.ui.HorizontalSplitPanel
               	com.vaadin.ui.InlineDateField
               	com.vaadin.ui.Label
               	com.vaadin.ui.Link
               	com.vaadin.ui.ListSelect
               	com.vaadin.ui.MenuBar
               	com.vaadin.ui.NativeButton
               	com.vaadin.ui.NativeSelect
               	com.vaadin.ui.OptionGroup
               	com.vaadin.ui.OrderedLayout
               	com.vaadin.ui.Panel
               	com.vaadin.ui.PasswordField
               	com.vaadin.ui.PopupView
               	com.vaadin.ui.ProgressIndicator
               	com.vaadin.ui.RichTextArea
               	com.vaadin.ui.Select
               	com.vaadin.ui.Slider
               	com.vaadin.ui.SplitPanel
               	com.vaadin.ui.TabSheet
               	com.vaadin.ui.Table
               	com.vaadin.ui.TextArea
               	com.vaadin.ui.TextField
               	com.vaadin.ui.Tree
               	com.vaadin.ui.TwinColSelect
               	com.vaadin.ui.Upload
               	com.vaadin.ui.UriFragmentUtility
               	com.vaadin.ui.VerticalLayout
               	com.vaadin.ui.VerticalSplitPanel
               	com.vaadin.ui.Window
               [b]
com.widget.test.MyComponent
[/b]
               Done. (0seconds)
   Scanning for additional dependencies: jar:file:/home/em3/dev/workspace/test-widget/WebContent/WEB-INF/lib/vaadin-6.6.0.jar!/com/vaadin/terminal/gwt/client/ui/dd/VAcceptCriteria.java
      Computing all possible rebind results for 'com.vaadin.terminal.gwt.client.ui.dd.VAcceptCriterionFactory'
         Rebinding com.vaadin.terminal.gwt.client.ui.dd.VAcceptCriterionFactory
            Invoking generator com.vaadin.terminal.gwt.widgetsetutils.AcceptCriteriaFactoryGenerator
               Detecting available criteria ...
               creating mapping for com.vaadin.ui.Tree.TreeDropCriterion
               creating mapping for com.vaadin.ui.Tree.TargetInSubtree
               creating mapping for com.vaadin.event.dd.acceptcriteria.AcceptAll
               creating mapping for com.vaadin.event.dd.acceptcriteria.SourceIsTarget
               creating mapping for com.vaadin.ui.AbstractSelect.AcceptItem
               creating mapping for com.vaadin.event.dd.acceptcriteria.Or
               creating mapping for com.vaadin.event.dd.acceptcriteria.ServerSideCriterion
               creating mapping for com.vaadin.event.dd.acceptcriteria.TargetDetailIs
               creating mapping for com.vaadin.event.dd.acceptcriteria.Not
               creating mapping for com.vaadin.event.dd.acceptcriteria.ContainsDataFlavor
               creating mapping for com.vaadin.event.dd.acceptcriteria.And
               creating mapping for com.vaadin.ui.AbstractSelect.TargetItemIs
               creating mapping for com.vaadin.event.dd.acceptcriteria.SourceIs
               creating mapping for com.vaadin.ui.Table.TableDropCriterion
               Done. (0seconds)
   Compiling 6 permutations
      Compiling permutation 0...
      Process output
         Compiling
            Compiling permutation 1...
      Compiling permutation 2...
         Compiling
            Compiling permutation 3...
      Compiling permutation 4...
         Compiling
            Compiling permutation 5...
   Compile of permutations succeeded
   Linking into WebContent/VAADIN/widgetsets
      Link succeeded
   Compilation succeeded -- 204.024s

I’ve attached the example project. It would be useful for me, if you can import it and try if you get the same result as me. So in that way I can discard that is a plugin issue.

Best!.
M.
11706.zip (6.87 MB)

Without having tested this: this is probably a classpath issue. While I don’t have an answer directly, here is some background information that may help when investigating this and similar issues.

The widgetset compiler requires the compiled server side classes (to scan for @ClientWidget annotations) and the source code of client side classes. Only some of the JARs that are on the classpath are included on the widgetset compiler classpath when using the Eclipse plugin - JARs that contain Vaadin widgetsets or other GWT modules are used.

It could be possible that a JAR is not included on the classpath, the scan for @ClientWidget silently fails for the class as it cannot be loaded (e.g. because of some static fields whose initialization fails), and the widget is not included. As for the “silently” part, using some (non-Vaadin) JARs would flood the logs when compiling a widgetset so some issues are only logged at the FINE level by ClassPathExplorer, and if I remember correctly, this level is not shown when compiling with the Eclipse plugin.

If the problem is caused by JARs missing on the classpath of the widgetset compiler, one option would be to use e.g. an ANT script instead of the Eclipse plugin to compile the widgetset. There are sample scripts available, and probably someone can even point you to one that is compatible with Vaadin 6.6 and GWT 2.3.

Hey Henri,

You are right. It was a classpath problem. I grabbed the Ant script from download/tooling to compile the widgetset and it works like a charm!. :slight_smile:

Regarding to:

Should the Vaadin Eclipse Plugin be responsible to include the JARs on the classpath in order to compile the widgetset?
(It looks like a bug on the vaadin plugin…)

Thanks!
M.

The Eclipse plugin cannot in general include all the Eclipse build path JARs in the widgetset compilation classpath as the GWT compiler cannot handle many common JARs (e.g. some database driver JARs) at all and can be very slow when including some others.

However, the Eclipse plugin could ask the user which JARs to use as suggested in
enhancement request #6886
. Also
#5961
is somewhat related.