djasy3
djasy3

Reputation: 35

How to set up gwt super dev mode with the new gwt maven plugin with a web application using Errai framework?

I am attempting to reconfigure a web application that was created with GWT, using the Errai framework and the Mojo GWT Maven plugin. To migrate to at least version 2.9 of GWT, I want to use the Tbroyer plugin. This is because the latest version of Errai still uses GWT version 2.9. When I execute the codeserver command, I encounter a ClassNotFoundException with javax servlet. mvn gwt:codeserver -pl *-client -am

This is the error I am getting :

[INFO] Turning off precompile in incremental mode.
[INFO] Super Dev Mode starting up
[INFO]    workDir: C:\Users\Dev\webapp\myapp\target\gwt\codeserver
[WARNING] java.lang.NoClassDefFoundError: javax/servlet/Servlet
[WARNING]       at com.google.gwt.dev.codeserver.SourceHandler.<clinit>(SourceHandler.java:63)
[WARNING]       at com.google.gwt.dev.codeserver.Recompiler.loadModule(Recompiler.java:500)
[WARNING]       at com.google.gwt.dev.codeserver.Recompiler.initWithoutPrecompile(Recompiler.java:204)
[WARNING]       at com.google.gwt.dev.codeserver.Outbox.maybePrecompile(Outbox.java:89)
[WARNING]       at com.google.gwt.dev.codeserver.Outbox.<init>(Outbox.java:61)
[WARNING]       at com.google.gwt.dev.codeserver.CodeServer.makeOutboxTable(CodeServer.java:192)
[WARNING]       at com.google.gwt.dev.codeserver.CodeServer.start(CodeServer.java:151)
[WARNING]       at com.google.gwt.dev.codeserver.CodeServer.main(CodeServer.java:104)
[WARNING]       at com.google.gwt.dev.codeserver.CodeServer.main(CodeServer.java:55)
[WARNING] Caused by: java.lang.ClassNotFoundException: javax.servlet.Servlet
[WARNING]       at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:581)
[WARNING]       at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
[WARNING]       at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:527)
[WARNING]       ... 9 more
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary for myapp 2.0-SNAPSHOT:
[INFO]
[INFO] myapp ............................................. FAILURE [ 10.244 s]
[INFO] myapp-shared ...................................... SKIPPED
[INFO] myapp-client ...................................... SKIPPED
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  11.483 s
[INFO] Finished at: 2024-03-21T15:42:39-03:00
[INFO] ------------------------------------------------------------------------

[ERROR] Failed to execute goal net.ltgt.gwt.maven:gwt-maven-plugin:1.1.0:codeserver (default-cli) on project myapp: GWT exited with status 1 -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal net.ltgt.gwt.maven:gwt-maven-plugin:1.1.0:codeserver (default-cli) on project myapp: GWT exited with status 1
    at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute2 (MojoExecutor.java:333)
    at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute (MojoExecutor.java:316)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:212)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:174)
    at org.apache.maven.lifecycle.internal.MojoExecutor.access$000 (MojoExecutor.java:75)
    at org.apache.maven.lifecycle.internal.MojoExecutor$1.run (MojoExecutor.java:162)
    at org.apache.maven.plugin.DefaultMojosExecutionStrategy.execute (DefaultMojosExecutionStrategy.java:39)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:159)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:105)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:73)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:53)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:118)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:261)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:173)
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:101)
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:906)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:283)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:206)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
    at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:566)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:283)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:226)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:407)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:348)
Caused by: org.apache.maven.plugin.MojoExecutionException: GWT exited with status 1
    at net.ltgt.gwt.maven.CommandLine.execute (CommandLine.java:73)
    at net.ltgt.gwt.maven.AbstractDevModeMojo.execute (AbstractDevModeMojo.java:272)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:126)
    at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute2 (MojoExecutor.java:328)
    at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute (MojoExecutor.java:316)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:212)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:174)
    at org.apache.maven.lifecycle.internal.MojoExecutor.access$000 (MojoExecutor.java:75)
    at org.apache.maven.lifecycle.internal.MojoExecutor$1.run (MojoExecutor.java:162)
    at org.apache.maven.plugin.DefaultMojosExecutionStrategy.execute (DefaultMojosExecutionStrategy.java:39)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:159)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:105)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:73)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:53)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:118)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:261)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:173)
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:101)
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:906)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:283)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:206)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
    at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:566)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:283)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:226)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:407)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:348)
[ERROR]

And this is part of the the main pom.xml

  <properties>
    ...
    <gwt.version>2.9.0</gwt.version>
    .....
  </properties>
 <dependencyManagement>
    <dependencies>
      <dependency>
        <groupId>org.jboss.errai.bom</groupId>
        <artifactId>errai-bom</artifactId>
        <version>${errai.version}</version>
        <type>pom</type>
        <scope>import</scope>
      </dependency>
      <dependency>
        <groupId>com.google.gwt</groupId>
        <artifactId>gwt</artifactId>
        <version>${gwt.version}</version>
        <type>pom</type>
        <scope>import</scope>
      </dependency>
    </dependencies> 
  </dependencyManagement>
  <build>
    <plugins>
      <plugin>
        <groupId>net.ltgt.gwt.maven</groupId>
        <artifactId>gwt-maven-plugin</artifactId>
        <inherited>false</inherited>
        <extensions>true</extensions>
        <configuration>
          <launcherDir>${project.build.directory}/gwt/launcherDir</launcherDir>
          <!-- To be able to use gwt:devmode (useful on Windows where Ctrl+C won't kill gwt:codeserver)-->
          <warDir>${project.build.directory}/gwt/launcherDir</warDir>
          <devmodeArgs>
            <!-- GWT Super Dev Mode: Replace default backend by WildFly -->
            <arg>-server</arg>
            <arg>org.jboss.errai.cdi.server.gwt.EmbeddedWildFlyLauncher</arg>
            <arg>-startupUrl</arg>
            <arg>${project.basedir}/myapp-server/src/main/webapp/index.html</arg>
          </devmodeArgs>
          <systemProperties>
            <!-- GWT Super Dev Mode: which WildFly to use 
            got this example on stack overflow -->
            <errai.jboss.home>${wildfly.home}</errai.jboss.home>
          </systemProperties>
        </configuration>
      </plugin>
    </plugins>
    <pluginManagement>
      <plugins>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-compiler-plugin</artifactId>
          <version>3.12.1</version>
          <configuration>
            <release>11</release>
          </configuration>
        </plugin>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-resources-plugin</artifactId>
          <version>3.3.1</version>
        </plugin>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-surefire-plugin</artifactId>
          <version>3.2.5</version>
        </plugin>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-war-plugin</artifactId>
          <version>3.4.0</version>
        </plugin>
        <plugin>
          <groupId>org.eclipse.jetty</groupId>
          <artifactId>jetty-maven-plugin</artifactId>
          <version>11.0.19</version>
        </plugin>
        <plugin>
          <groupId>net.ltgt.gwt.maven</groupId>
          <artifactId>gwt-maven-plugin</artifactId>
          <version>1.1.0</version>
          <extensions>true</extensions>
          <configuration>
            <sourceLevel>11</sourceLevel>
            <failOnError>true</failOnError>
          </configuration>
        </plugin>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-source-plugin</artifactId>
          <version>3.3.0</version>
          <executions>
            <execution>
              <id>attach-sources</id>
              <phase>package</phase>
              <goals>
                <goal>jar-no-fork</goal>
              </goals>
            </execution>
          </executions>
        </plugin>
        <!-- Unpack jboss-as from maven. Remove this if you wish to use your own jboss/wildfly instance. -->
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-dependency-plugin</artifactId>
          <executions>
            <execution>
              <id>unpack</id>
              <phase>process-resources</phase>
              <goals>
                <goal>unpack</goal>
              </goals>
              <configuration>
                <artifactItems>
                  <artifactItem>
                    <groupId>org.jboss.errai</groupId>
                    <artifactId>wildfly-dist</artifactId>
                    <version>${as.version}</version>
                    <type>zip</type>
                    <overWrite>false</overWrite>
                    <outputDirectory>${project.build.directory}</outputDirectory>
                  </artifactItem>
                </artifactItems>
              </configuration>
            </execution>
          </executions>
        </plugin>
      </plugins>
    </pluginManagement>
  </build>
  <modules>
    <module>myapp-client</module>
    <module>myapp-shared</module>
    <module>myapp-server</module> 
  </modules>
</project>

And this is the part of the client module pom as well :

<packaging>gwt-app</packaging>

  <dependencies>
    <dependency>
      <groupId>${project.groupId}</groupId>
      <artifactId>myapp-shared</artifactId>
      <version>${project.version}</version>
    </dependency>
    <dependency>
      <groupId>${project.groupId}</groupId>
      <artifactId>myapp-shared</artifactId>
      <version>${project.version}</version>
      <classifier>sources</classifier>
    </dependency>
    <dependency>
      <groupId>com.google.gwt</groupId>
      <artifactId>gwt-user</artifactId>
    </dependency>
    <dependency>
      <groupId>com.google.gwt</groupId>
      <artifactId>gwt-dev</artifactId>
      <exclusions>
        <exclusion>
          <!-- Contains a ServletContainerInitializer that breaks the EmbeddedWildFlyLauncher during GWT Super Dev Mode -->
          <groupId>org.eclipse.jetty</groupId>
          <artifactId>apache-jsp</artifactId>
        </exclusion>
      </exclusions>
    </dependency>
    <dependency>
      <!-- Only used for EmbeddedWildFlyLauncher during GWT Super Dev Mode -->
      <groupId>org.jboss.errai</groupId>
      <artifactId>errai-cdi-jboss</artifactId>
      <scope>runtime</scope>
    </dependency>
    <dependency>
      <groupId>org.jboss.errai</groupId>
      <artifactId>errai-javaee-all</artifactId>
      <version>${errai.version}</version>
    </dependency>
    <dependency>
      <groupId>org.jboss.spec.javax.ejb</groupId>
      <artifactId>jboss-ejb-api_3.2_spec</artifactId>
      <version>2.0.0.Final</version>
      <scope>runtime</scope>
    </dependency>
  </dependencies>

  <build>
    <plugins>
      <plugin>
        <groupId>net.ltgt.gwt.maven</groupId>
        <artifactId>gwt-maven-plugin</artifactId>
        <configuration>
          <moduleName>com.example.myapp.App</moduleName>
          <moduleShortName>myapp</moduleShortName>
        </configuration>
      </plugin>
    </plugins>
  </build>
</project>

I realize that the error start to come up as soon as I start importing the Errai framework.

Please Advise

Before I start trying the migration with the new plugin, I wanted to run an empty project and slowly adding the errai framework to it. I couldn't get any result either. As soon as I was adding to the GWT module this line : <inherits name="org.jboss.errai.enterprise.All" />

To begining with I am expecting to run an empty project with just printing a word to the console and build from there. I was able to do that before adding anything Errai related.

Upvotes: 0

Views: 144

Answers (0)

Related Questions