GWT compiler error - Vaadin Charts using Maven and IntelliJ

Hi

I’m trying to evaluate the charts add-on in a simple prototype application using the Maven application archetype within IntelliJ IDEA 13 and have run into a problem trying to run the install goal. Although following the steps in the Book of Vaadin and building the widget set using the maven goal appears to be successful, attempts to compile and deploy fail with an annoyingly cryptic GWT internal error that doesn’t give me enough information to track the bug down. I’m sure I have done something wrong but despite cleaning and then rebuilding the project from scratch I can’t seem to escape from the error. If anyone is able to help I’d be very grateful!

Console output (install goal):

Information:Compilation completed with 20 errors and 0 warnings in 9 sec
Information:20 errors
Information:0 warnings
Error:GWT Compiler: Unexpected internal compiler error
Error:GWT Compiler: at com.google.gwt.dev.javac.CompilationStateBuilder.doBuildFrom(CompilationStateBuilder.java:464)
Error:GWT Compiler: at com.google.gwt.dev.javac.CompilationStateBuilder.buildFrom(CompilationStateBuilder.java:423)
Error:GWT Compiler: at com.google.gwt.dev.cfg.ModuleDef.getCompilationState(ModuleDef.java:373)
Error:GWT Compiler: at com.google.gwt.dev.Precompile.precompile(Precompile.java:246)
Error:GWT Compiler: at com.google.gwt.dev.Precompile.precompile(Precompile.java:229)
Error:GWT Compiler: at com.google.gwt.dev.Precompile.precompile(Precompile.java:141)
Error:GWT Compiler: at com.google.gwt.dev.Compiler.run(Compiler.java:232)
Error:GWT Compiler: at com.google.gwt.dev.Compiler.run(Compiler.java:198)
Error:GWT Compiler: at com.google.gwt.dev.Compiler$1.run(Compiler.java:170)
Error:GWT Compiler: at com.google.gwt.dev.CompileTaskRunner.doRun(CompileTaskRunner.java:88)
Error:GWT Compiler: at com.google.gwt.dev.CompileTaskRunner.runWithAppropriateLogger(CompileTaskRunner.java:82)
Error:GWT Compiler: at com.google.gwt.dev.Compiler.main(Compiler.java:177)
Error:GWT Compiler: at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
Error:GWT Compiler: at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
Error:GWT Compiler: at java.security.AccessController.doPrivileged(Native Method)
Error:GWT Compiler: at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
Error:GWT Compiler: at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
Error:GWT Compiler: at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
Error:GWT Compiler: at java.lang.ClassLoader.loadClass(ClassLoader.java:358)

POM file:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>uk.co.ravingmonkey</groupId>
    <artifactId>mcp</artifactId>
    <packaging>war</packaging>
    <version>1.0-SNAPSHOT</version>
    <name>Vaadin Web Application</name>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <vaadin.version>7.1.10</vaadin.version>
        <vaadin.plugin.version>${vaadin.version}</vaadin.plugin.version>
    </properties>
    <repositories>
        <repository>
            <id>vaadin-addons</id>
            <url>http://maven.vaadin.com/vaadin-addons</url>
        </repository>
        <repository>
            <id>vaadin-snapshots</id>
            <url>http://oss.sonatype.org/content/repositories/vaadin-snapshots/</url>
            <releases>
                <enabled>false</enabled>
            </releases>
            <snapshots>
                <enabled>true</enabled>
            </snapshots>
        </repository>
    </repositories>
    <pluginRepositories>
        <pluginRepository>
            <id>vaadin-snapshots</id>
            <url>http://oss.sonatype.org/content/repositories/vaadin-snapshots/</url>
            <releases>
                <enabled>false</enabled>
            </releases>
            <snapshots>
                <enabled>true</enabled>
            </snapshots>
        </pluginRepository>
    </pluginRepositories>
    <dependencies>
        <dependency>
            <groupId>com.vaadin</groupId>
            <artifactId>vaadin-server</artifactId>
            <version>${vaadin.version}</version>
        </dependency>
        <dependency>
            <groupId>com.vaadin</groupId>
            <artifactId>vaadin-client-compiled</artifactId>
            <version>${vaadin.version}</version>
        </dependency>
        <!--
          Needed when using the widgetset optimizer (custom ConnectorBundleLoaderFactory).
          
          For widgetset compilation, vaadin-client-compiler is automatically added on the
          compilation classpath by vaadin-maven-plugin so normally there is no need for an
          explicit dependency.
        -->
        <!--
        <dependency>
            <groupId>com.vaadin</groupId>
            <artifactId>vaadin-client-compiler</artifactId>
            <version>${vaadin.version}</version>
            <scope>provided</scope>
        </dependency>
        -->
        <dependency>
            <groupId>com.vaadin</groupId>
            <artifactId>vaadin-client</artifactId>
            <version>${vaadin.version}</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.vaadin</groupId>
            <artifactId>vaadin-push</artifactId>
            <version>${vaadin.version}</version>
        </dependency>
        <dependency>
            <groupId>com.vaadin</groupId>
            <artifactId>vaadin-themes</artifactId>
            <version>${vaadin.version}</version>
        </dependency>
        <dependency>
            <groupId>com.vaadin.addon</groupId>
            <artifactId>vaadin-charts</artifactId>
            <version>1.1.4</version>
        </dependency>
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>javax.servlet-api</artifactId>
            <version>3.0.1</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-validator</artifactId>
            <version>5.0.2.Final</version>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>2.5.1</version>
                <configuration>
                    <source>1.6</source>
                    <target>1.6</target>
                </configuration>
            </plugin>
            <!-- As we are doing "inplace" GWT compilation, ensure the widgetset -->
            <!-- directory is cleaned properly -->
            <plugin>
                <artifactId>maven-clean-plugin</artifactId>
                <version>2.4.1</version>
                <configuration>
                    <filesets>
                        <fileset>
                            <directory>src/main/webapp/VAADIN/widgetsets</directory>
                        </fileset>
                    </filesets>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-war-plugin</artifactId>
                <version>2.2</version>
                <configuration>
                    <failOnMissingWebXml>false</failOnMissingWebXml>
                </configuration>
            </plugin>
            <plugin>
                <groupId>com.vaadin</groupId>
                <artifactId>vaadin-maven-plugin</artifactId>
                <version>${vaadin.plugin.version}</version>
                <configuration>
                    <extraJvmArgs>-Xmx512M -Xss1024k</extraJvmArgs>
                    <!-- <runTarget>mobilemail</runTarget> -->
                    <!-- We are doing "inplace" but into subdir VAADIN/widgetsets. This 
                        way compatible with Vaadin eclipse plugin. -->
                    <webappDirectory>${basedir}/src/main/webapp/VAADIN/widgetsets
                    </webappDirectory>
                    <hostedWebapp>${basedir}/src/main/webapp/VAADIN/widgetsets
                    </hostedWebapp>
                    <noServer>true</noServer>
                    <!-- Remove draftCompile when project is ready -->
                    <draftCompile>false</draftCompile>
                    <compileReport>true</compileReport>
                    <style>OBF</style>
                    <strict>true</strict>
                    <runTarget>http://localhost:8080/</runTarget>
                </configuration>
                <executions>
                    <execution>
                        <configuration>
                            <!-- if you don't specify any modules, the plugin will find them -->
                            <!-- <modules> <module>com.vaadin.demo.mobilemail.gwt.ColorPickerWidgetSet</module> 
                                </modules> -->
                        </configuration>
                        <goals>
                            <goal>clean</goal>
                            <goal>resources</goal>
                            <goal>update-theme</goal>
                            <goal>update-widgetset</goal>
                            <goal>compile-theme</goal>
                            <goal>compile</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.mortbay.jetty</groupId>
                <artifactId>jetty-maven-plugin</artifactId>
            </plugin>
        </plugins>
        <pluginManagement>
            <plugins>
                <!--This plugin's configuration is used to store Eclipse m2e settings only. It has no influence on the Maven build itself.-->
                <plugin>
                    <groupId>org.eclipse.m2e</groupId>
                    <artifactId>lifecycle-mapping</artifactId>
                    <version>1.0.0</version>
                    <configuration>
                        <lifecycleMappingMetadata>
                            <pluginExecutions>
                                <pluginExecution>
                                    <pluginExecutionFilter>
                                        <groupId>com.vaadin</groupId>
                                        <artifactId>
                                            vaadin-maven-plugin
                                        </artifactId>
                                        <versionRange>
                                            [7.1.10,)
                                        </versionRange>
                                        <goals>
                                            <goal>resources</goal>
                                            <goal>update-widgetset</goal>
                                            <goal>compile</goal>
                                            <goal>update-theme</goal>
                                            <goal>compile-theme</goal>
                                        </goals>
                                    </pluginExecutionFilter>
                                    <action>
                                        <ignore></ignore>
                                    </action>
                                </pluginExecution>
                            </pluginExecutions>
                        </lifecycleMappingMetadata>
                    </configuration>
                </plugin>
            </plugins>
        </pluginManagement>
    </build>
</project>

Finally, the chart class I’m trying to instantiate:

public class EventsPerMonthChart extends Chart {

    public EventsPerMonthChart() {
        super(ChartType.PIE);

        setCaption("Events per month");
        getConfiguration().setTitle("");
        getConfiguration().getChart().setType(ChartType.PIE);
        setWidth("100%");
        setHeight("90%");

        DataSeries series = new DataSeries();

        ArrayList<Evnt> events = (ArrayList)MockDataProvider.getEvntCollection();
        Calendar cal = Calendar.getInstance();
        HashMap<String, Integer> eventsPerMonth = new HashMap<String, Integer>();
        Long id = 1L;
        String month;
        for (Evnt e: events) {
            cal.setTime(e.getStartDateTime());
            month = cal.getDisplayName(Calendar.MONTH, Calendar.LONG, Locale.ENGLISH);
            // TODO bugged!
            if (eventsPerMonth.get(month) != null) {
            eventsPerMonth.put(month, eventsPerMonth.get(month) + 1);
            } else
            {
                eventsPerMonth.put(month, 1);
            }
        }
        Set<String> monthsOfYear = eventsPerMonth.keySet();
        for (String m: monthsOfYear) {
            series.add(new DataSeriesItem(m, eventsPerMonth.get(m)));
        }
        getConfiguration().setSeries(series);
    }

}

Fixed! As is so often the case with these things, a simple typo can leave you tearing your hair out. The Vaadin Charts version number in the pom.xml file was incorrect! I have no idea where I got 1.1.4 from (time travelling perhaps?) but replacing it with 1.0.0 sorted the problem and it works fine with the latest version (1.1.3 as of Jan 2014).

It isn’t the first time I’ve been tripped up by such a trivial error and I’m sure it won’t be the last!

Oh, and forgot to mention that as I wasn’t using the default widgetset, I needed to change the POM file to ensure compilation.

Original Maven archetype snippet:

....
        <dependency>
            <groupId>com.vaadin</groupId>
            <artifactId>vaadin-client-compiled</artifactId>
            <version>${vaadin.version}</version>
        </dependency>
.....

Change to:

....
        <dependency>
            <groupId>com.vaadin</groupId>
            <artifactId>vaadin-client-compiler</artifactId>
            <version>${vaadin.version}</version>
        </dependency>
....

It might have said this somewhere in the Book of Vaadin but I must have missed it. This meant several hours spent scratching my head and getting rather frustrated!

Hi,

You shouldn’t need either of those dependencies. The “…-compiled” contains just the precompiled “default widgetset” for very simple Vaadin apps without client side extensions. The “…-client” dependency is needed only for client side development (~ when you develop components with client side extensions). Also then, you should just add it as “provided”, so it don’t end up to your war files.

Here is everything you’ll need:
https://github.com/mstahv/app-with-charts/blob/master/pom.xml#L44

cheers,
matti

Hi Matti

Thanks for the explanation. Interestingly the compilation problem arises with the “bare” application archetype before I’ve started tinkering with it. It does add a AppWidgetset.gwt.xml file and a corresponding widgetset link in the servlet configuration which I don’t recall seeing in the tutorials I’ve been through. Is this the souce of the problem or is it purely a pom.xml issue? Apologies if this is a stupid question - I’m very new to the framework and haven’t even started looking at how the widget side of things works yet (as I wasn’t planning on making up my own components any time soon!)

Cheers
Adrian

Hi,

There are no stupid questions. Our widgetset related docs should definitely be better, there are too many questions recarding those :slight_smile:

I didn’t see the full stacktrace to see the error, so hard to say what is causing that exception for you. I haven’t recently used maven directly from command line, but via Eclipse or NetBeans I haven’t had any issues. Our just published video shows you how it should work.

http://www.youtube.com/watch?v=P9YupaOpsMk&list=UUsGakFIbOsj-fgPFLf1QlQA&feature=share

I haven’t used IntelliJ myself, it I have heard nothing but good about it.

cheers,
matti

Hi Matti

I’ve created a fresh project using the Maven vaadin-application-archetype 7.1.9 which gives me the pom.xml from the my original post (excluding the charts add-on of course). I’ve attached a screenshot of the project structure but here are is the default UI class…

@Theme("mytheme")
@SuppressWarnings("serial")
public class MyVaadinUI extends UI
{

    @WebServlet(value = "/*", asyncSupported = true)
    @VaadinServletConfiguration(productionMode = false, ui = MyVaadinUI.class, widgetset = "uk.co.ravingmonkey.AppWidgetSet")
    public static class Servlet extends VaadinServlet {
    }

    @Override
    protected void init(VaadinRequest request) {
        final VerticalLayout layout = new VerticalLayout();
        layout.setMargin(true);
        setContent(layout);
        
        Button button = new Button("Click Me");
        button.addClickListener(new Button.ClickListener() {
            public void buttonClick(ClickEvent event) {
                layout.addComponent(new Label("Thank you for clicking"));
            }
        });
        layout.addComponent(button);
    }

}

…and the stack trace when I attempt make/build/deploy (to Glassfish V4 using IDEA13)

Information:Compilation completed with 20 errors and 0 warnings in 4 sec
Information:20 errors
Information:0 warnings
Error:GWT Compiler: Unexpected internal compiler error
Error:GWT Compiler: at com.google.gwt.dev.javac.CompilationStateBuilder.doBuildFrom(CompilationStateBuilder.java:464)
Error:GWT Compiler: at com.google.gwt.dev.javac.CompilationStateBuilder.buildFrom(CompilationStateBuilder.java:423)
Error:GWT Compiler: at com.google.gwt.dev.cfg.ModuleDef.getCompilationState(ModuleDef.java:373)
Error:GWT Compiler: at com.google.gwt.dev.Precompile.precompile(Precompile.java:246)
Error:GWT Compiler: at com.google.gwt.dev.Precompile.precompile(Precompile.java:229)
Error:GWT Compiler: at com.google.gwt.dev.Precompile.precompile(Precompile.java:141)
Error:GWT Compiler: at com.google.gwt.dev.Compiler.run(Compiler.java:232)
Error:GWT Compiler: at com.google.gwt.dev.Compiler.run(Compiler.java:198)
Error:GWT Compiler: at com.google.gwt.dev.Compiler$1.run(Compiler.java:170)
Error:GWT Compiler: at com.google.gwt.dev.CompileTaskRunner.doRun(CompileTaskRunner.java:88)
Error:GWT Compiler: at com.google.gwt.dev.CompileTaskRunner.runWithAppropriateLogger(CompileTaskRunner.java:82)
Error:GWT Compiler: at com.google.gwt.dev.Compiler.main(Compiler.java:177)
Error:GWT Compiler: at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
Error:GWT Compiler: at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
Error:GWT Compiler: at java.security.AccessController.doPrivileged(Native Method)
Error:GWT Compiler: at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
Error:GWT Compiler: at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
Error:GWT Compiler: at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
Error:GWT Compiler: at java.lang.ClassLoader.loadClass(ClassLoader.java:358)

If I make the corrections to the pom.xml file, everything proceeds fine. Any ideas?

Cheers
Adrian

13419.png

Hi Matti

If I understood your earlier post correctly, the ‘-client’ dependency is not required. If I delete this and leave the ‘-compiled’ dependancy as it is, compilation fails with the following message “GWT Compiler: Unable to find ‘com/vaadin/DefaultWidgetSet.gwt.xml’ on your classpath; could be a typo, or maybe you forgot to include a classpath entry for source?” Of course, I wouldn’t expect it to find this file as the archetype has created ‘AppWidgetSet.gwt.xml’ in the application root so even if I renamed this file, the compiler still wouldn’t find ‘com/vaadin/DefaultWidgetSet.gwt.xml’!

I think there’s something wrong with this Maven archetype but no one else appears to have a problem (or they’re not saying). It’s all a bit frustrating really as I don’t understand what I’m doing wrong.

Cheers
Adrian

This fixed the exact same issue for me too. Using IntelliJ and Vaadin 7.1.9

And for me, using IntelliJ 13.1.1, Vaadin 7.1.12

I think something might have changed from going from IntelliJ 13.0.1 to 13.1.1. In 13.0.1 I didn’t experience the issue that the others are experiencing with the vaadin-client-compiled dependency, but when upgrading to IntelliJ 13.1.1, I can no longer run the app with out first changing to the vaadin-client-compiler dependency. I get that same GWT internal error.

Just bumping this as still no fix other than the workaround that I suggested several months back, Currently using Vaadin Archetype 7.2.6 and trialing IDEA 14 EAP. I’m not nearly clued up enough on Maven or GWT to understand why this issue should exist but it appears to be an IntelliJ issue based on Dan’s comments above. Any ideas?

For me changing it to

<dependency> <groupId>com.vaadin</groupId> <artifactId>vaadin-client-compiler</artifactId> <version>${vaadin.version}</version> </dependency> fixed it, too. Using IntelliJ 13.1.6.

Same here. I had spent at least 3-4 hours trying to figure out what was going on and I couldn’t get anywhere until I luckily found this forum post.

I’m using Vaadin 8.0.7 and Intellij 2017.2 so unfortunately this is still an issue.