Friday, May 7, 2021

Re: GWT tutorial does not compile

Yes, I won't recommend but it also has an archetype: https://gwt-maven-plugin.github.io/gwt-maven-plugin/user-guide/archetype.html

But again, better to separate the Maven projects "client" / "api" or "shared" / "server" instead of putting them together in one Maven project like the example from the archetype (see the screenshot in that page)...

Actually Maven plugin from TBroyer is also available at Maven Central, the same as the Mojo Codehaus Maven plugin... So your company just need to add "Maven Central" in their repository (Nexus or whatever).

I actually wonder, why doesn't your company integrate Maven Central in their repository... because Maven Central is very trustful. A lot of Java libraries like Tomcat, Jetty and etc. come from Maven Central...

Hope this helps.
Lofi
likejudo schrieb am Freitag, 7. Mai 2021 um 14:52:05 UTC+2:
In the end I have to use the employer repository for my project which does not have the Broyer plugin.
It only has the Mojo Codehaus Maven plugin. I hope the Mojo plugin will be able to do similar.
I am guessing that perhaps companies are reluctant to use the Broyer plugin because it is private and not from an organization like Codehaus which will support their plugin.


On Thursday, May 6, 2021 at 4:24:07 PM UTC-5 lofid...@gmail.com wrote:
Then just do this Maven archetype from TBroyer:

mvn archetype:generate -DarchetypeGroupId=net.ltgt.gwt.archetypes -DarchetypeVersion=LATEST -DarchetypeArtifactId=modular-webapp


and then take a look here how to start: https://github.com/tbroyer/gwt-maven-archetypes

......
Start the development mode

Change directory to your generated project and issue the following commands:

  1. In one terminal window: mvn gwt:codeserver -pl *-client -am
  2. In another terminal window: mvn jetty:run -pl *-server -am -Denv=dev

Or if you'd rather use Tomcat than Jetty, use mvn tomcat7:run instead of mvn jetty:run.

Note that the -pl and -am are not strictly necessary, they just tell Maven not to build the client module when you're dealing with the server one, and vice versa.

........

Hope this helps,
Lofi

likejudo schrieb am Donnerstag, 6. Mai 2021 um 23:17:44 UTC+2:
Thank you for your reply.
I need to build the client and server and package as a war using tomcat or jetty. I don't want a separate Spring Boot server.
The Stockbroker tutorial had both server and client in one war file.
Perhaps I should just manually create the war, WEB-INF folders and then change the pom.xml packaging to war - will that work?
As always, appreciate your help.
On Thursday, May 6, 2021 at 2:17:11 PM UTC-5 lofid...@gmail.com wrote:
OK, now the server part 😉👍

For the server part you can just build a standard server project. You should build a new Maven server project. So if you are finished with the client project, just leave it like that... and build a new Maven server project.

For the server part you have some choices:
  • Spring Boot webapp
  • JakartaEE webapp with Tomcat / Jetty
  • Quarkus, Micronaut
  • PHP
  • NodeJS
  • ASP.NET
  • ...
If you want to use Java and Spring Boot you can just build a new Maven Spring Boot project with Spring Initialzr: https://start.spring.io
 
After that you need to take care of the communication between web browser client with GWT,  which you've done before and the Spring Boot server part... remember this is a "remote call" since your web browser is on a different machine than your Spring Boot server.

Your choices: 
Today everyone use REST but IMHO GWT RPC is very nice for Java developers.

REST example using Domino REST: https://github.com/gwtboot/domino-rest-enum-date
Here you can see 3 Maven projects: "client", "api" and "server". So far you've done the "client" and now you need the "server" and "api" (also called "shared", because this project is shared between "client "and "server").

Using GWT RPC is actually quite the same. You also need api / shared and server but you will use standard Servlet GWT / RPC instead of REST JSON.

If you need the structure for GWT RPC with Spring Boot just tell me... I have no demo available, but could do this easily.

Another way is just to use JakartaEE web app with Tomcat or Jetty. In this case you could use the TBroyer Maven Archetype to create the project structure: https://github.com/tbroyer/gwt-maven-archetypes

Or you also could use the Maven Archetype GWT Spring Boot from Frank: https://github.com/NaluKit/gwt-maven-springboot-archetype to create the project structure for Spring Boot and GWT. Actually similar to my GWT Spring Boot example above but still different in how it works together...

That's a lot alternatives, ahh... I have to admit, that makes the introduction in GWT a bit difficult because of the alternatives...

My way was and is: 
  • Separate the client, api / shared and server as Maven projects / modules 
  • Build the server part completely independent of GWT like I showed above
  • Build the communication between them with the alternatives above
  • ... and always remember: the result of GWT transpiler is JavaScript, so you could always take the JavaScript with its resources and "copy" it to your server part, so it will be served from your server part. 
  • ... but still remember: JavaScript runs on web browser so you always have remote call to your server part.
Hope this helps,
Lofi
likejudo schrieb am Donnerstag, 6. Mai 2021 um 20:32:48 UTC+2:
I implemented Stockwatcher tutorial using Maven, following the hello app from Lofi and Ibaca's tuorials.
Now I want to implement the server side part of the tutorial. 
In my pom.xml I have
<packaging>gwt-app</packaging>

Do I need to change it to war?

<packaging>war</packaging>

Will that affect things?

On Monday, May 3, 2021 at 11:38:05 AM UTC-5 lofid...@gmail.com wrote:
Great, have fun... and give us your feedback here to see whether GWT fits your requirements... ;-)

likejudo schrieb am Montag, 3. Mai 2021 um 18:13:51 UTC+2:
Ok, I did not realize the Java file was under sourcemaps. It works now. Thanks,

On Monday, May 3, 2021 at 8:40:46 AM UTC-5 lofid...@gmail.com wrote:
<quote>
I am wondering why those in charge of GWT Project do not update the project docs with this better way you all have here.
Even the Eclipse plugin uses the older version of 2.8.1
</quote>

Yes, you are right... Someone has to take care of that. I'll wait for my next holidays to update the docs... Actually I already made a clone but never managed to work on that part... ;-)

<quote>
for debugging, the tutorial says: "... should see the Java file in the browser"
I do not see it at all - only JS files.
</quote>

Did you try in Google Chrome like in this description? https://github.com/lofidewanto/gwt-boot-sample-basic --- Step 3 - Debug the App in your Browser
likejudo schrieb am Montag, 3. Mai 2021 um 02:22:31 UTC+2:
for debugging, the tutorial says: "... should see the Java file in the browser"
I do not see it at all - only JS files.

On Sunday, May 2, 2021 at 2:51:00 PM UTC-5 lofid...@gmail.com wrote:
Great 👍 Have fun... and again you can still follow the tutorial here: http://www.gwtproject.org/doc/latest/tutorial/gettingstarted.html

What different is just the "build tool" and therefore the "project structure". You have a much modern style using Maven GWT plugin from TBroyer... Still you also can use the older Maven GWT Mojo plugin... or also Ant like in the tutorial above... But this is really old 😅

Enjoy!
likejudo schrieb am Sonntag, 2. Mai 2021 um 21:45:05 UTC+2:
Yes! thank you. I moved the plugin to build. It works now.

On Sunday, May 2, 2021 at 2:33:08 PM UTC-5 lofid...@gmail.com wrote:
I think this is the problem:

TBroyer Maven plugin with the extensions using the gwt-app packaging needs to be configured at the 
...
<build>
    <plugins>
        <plugin>
...

<build>
<plugins>

<plugin>
<groupId>net.ltgt.gwt.maven</groupId>
<artifactId>gwt-maven-plugin</artifactId>
<version>1.0.0</version>
<extensions>true</extensions>
<configuration>
<moduleName>me.App</moduleName>
<skipModule>true</skipModule>
</configuration>
</plugin>

In your example above it was defined at 
...
<pluginManagement>
     <plugins>
           <plugin>
...

<pluginManagement><!-- lock down plugins versions to avoid using Maven defaults (may be moved to parent pom) -->
<plugins>
<!-- clean lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#clean_Lifecycle -->
<plugin>
<groupId>net.ltgt.gwt.maven</groupId>
<artifactId>gwt-maven-plugin</artifactId>
<version>1.0.0</version>
<extensions>true</extensions>
<configuration>

The TBroyer plugin needs to be defined at the "build plugins" and not "pluginManagement plugins"

Hope this helps.
lofid...@gmail.com schrieb am Sonntag, 2. Mai 2021 um 21:24:52 UTC+2:
Sorry here is the link of the project: https://github.com/ibaca/gsg-hello-app 

Just download and unzip and build it just like my project above... Does this project give the same error?
lofid...@gmail.com schrieb am Sonntag, 2. Mai 2021 um 21:23:10 UTC+2:
<quote>
At home (on my personal computer not employer workspace, without the restrictions of using only company repository),
I downloaded and ran your example using Broyer plugin. It works. Thank you. 
</quote>

OK, great 👍 

<quote>
At step 3 Package, Run and Debug
I get an error

xxx@xxxx xxxx ~/Documents/Learn/gwt/hello-app
$ mvn package
[INFO] Scanning for projects...
[ERROR] [ERROR] Some problems were encountered while processing the POMs:
[ERROR] Unknown packaging: gwt-app @ line 10, column 14
</quote>

This is the project... you can download and unzip. I downloaded the project, unzip and did: mvn clean package. It works without errors.

My Java version: java -version
openjdk version "12" 2019-03-19
OpenJDK Runtime Environment AdoptOpenJDK (build 12+33)
OpenJDK 64-Bit Server VM AdoptOpenJDK (build 12+33, mixed mode, sharing)

My Maven version: mvn -version
Apache Maven 3.3.9 (bb52d8502b132ec0a5a3f4c09453c07478323dc5; 2015-11-10T17:41:47+01:00)
Maven home: /Users/lofidewanto/Applications/apache-maven-3.3.9
Java version: 12, vendor: AdoptOpenJDK
Java home: /Library/Java/JavaVirtualMachines/adoptopenjdk-12.jdk/Contents/Home
Default locale: de_DE, platform encoding: UTF-8
OS name: "mac os x", version: "10.16", arch: "x86_64", family: "mac"

What Java and Maven version are you using?

Thanks.
likejudo schrieb am Sonntag, 2. Mai 2021 um 20:43:01 UTC+2:
At home (on my personal computer not employer workspace, without the restrictions of using only company repository),
I downloaded and ran your example using Broyer plugin. It works. Thank you. 
Then I tried the Ignacio Baca tutorial with maven (using IntelliJ Community Edition).
At step 3 Package, Run and Debug
I get an error

userr@DESKTOP MINGW64 ~/Documents/Learn/gwt/hello-app
$ mvn package
[INFO] Scanning for projects...
[ERROR] [ERROR] Some problems were encountered while processing the POMs:
[ERROR] Unknown packaging: gwt-app @ line 10, column 14
 @
[ERROR] The build could not read 1 project -> [Help 1]
[ERROR]
[ERROR]   The project me:hello-app:HEAD-SNAPSHOT (C:\Users\user\Documents\Learn\gwt\hello-app\pom.xml) has 1 error
[ERROR]     Unknown packaging: gwt-app @ line 10, column 14
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:


pom.xml
Unfortunately, google groups strips out the xml formatting.

<?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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>me</groupId>
<artifactId>hello-app</artifactId>
<version>HEAD-SNAPSHOT</version>
<packaging>gwt-app</packaging>

<name>hello-app</name>
<!-- FIXME change it to the project's website -->
<url>http://www.example.com</url>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
</properties>

<dependencies>
<dependency>
<groupId>com.google.gwt</groupId>
<artifactId>gwt</artifactId>
<version>2.9.0</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.google.gwt</groupId>
<artifactId>gwt-user</artifactId>
<version>2.9.0</version>
</dependency>
<dependency>
<groupId>com.google.gwt</groupId>
<artifactId>gwt-dev</artifactId>
<version>2.9.0</version>
</dependency>
</dependencies>

<build>
<pluginManagement><!-- lock down plugins versions to avoid using Maven defaults (may be moved to parent pom) -->
<plugins>
<!-- clean lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#clean_Lifecycle -->
<plugin>
<groupId>net.ltgt.gwt.maven</groupId>
<artifactId>gwt-maven-plugin</artifactId>
<version>1.0.0</version>
<extensions>true</extensions>
<configuration>
<moduleName>me.App</moduleName>
<skipModule>true</skipModule>
</configuration>
</plugin>

<plugin>
<artifactId>maven-clean-plugin</artifactId>
<version>3.1.0</version>
</plugin>
<!-- default lifecycle, jar packaging: see https://maven.apache.org/ref/current/maven-core/default-bindings.html#Plugin_bindings_for_jar_packaging -->
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>3.0.2</version>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.1</version>
</plugin>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<version>3.0.2</version>
</plugin>
<plugin>
<artifactId>maven-install-plugin</artifactId>
<version>2.5.2</version>
</plugin>
<plugin>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.8.2</version>
</plugin>
<!-- site lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#site_Lifecycle -->
<plugin>
<artifactId>maven-site-plugin</artifactId>
<version>3.7.1</version>
</plugin>
<plugin>
<artifactId>maven-project-info-reports-plugin</artifactId>
<version>3.0.0</version>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>

I will appreciate suggestions to fix this.
On Friday, April 30, 2021 at 3:15:58 PM UTC-5 lofid...@gmail.com wrote:
Forget something...

It's wise to separate the "client" and the "server" in two Maven projects. Don't use the example of the Mojo Maven plugin because it mixes the client and server on the same Maven project.

I've once used it mixed (see https://github.com/interseroh/demo-gwt-springboot) but at the end I had a lot of troubles with the classpath. 

Here is an example how you could separate the client and server. At the end your result on the client is JavaScript and you can copy the result to the server part using maven-dependency-pluginhttps://github.com/gwtboot/domino-rest-enum-date

Hope this helps.
lofid...@gmail.com schrieb am Freitag, 30. April 2021 um 21:52:56 UTC+2:
... and yes, you can follow the tutorial with the TBroyer Maven plugin or the Mojo Maven plugin.

The code is the same, only the structure is different... You can compare both:
Lofi
lofid...@gmail.com schrieb am Freitag, 30. April 2021 um 21:49:17 UTC+2:
I checked the old Maven GWT Plugin... ok it still works for GWT 2.9 but I won't use it anymore. 

If you have to use it here is an example - just the same demo from my example above but use the old Maven plugin: https://github.com/lofidewanto/gwt-old-maven-sample-basic

The Java code is the same but it uses the structure of the old GWT Maven plugin... just take a look at the README of the project above.

Hope this helps.
likejudo schrieb am Freitag, 30. April 2021 um 20:27:00 UTC+2:
Mojo GWT Maven plugin packages as war.
if I package as war, can I still follow the tutorial?

On Friday, April 30, 2021 at 12:17:13 PM UTC-5 likejudo wrote:
  I don't have a choice. I have to use what is in my employer's repository. Mojo GWT Maven plugin 2.90 is in the repo.  

On Friday, April 30, 2021 at 12:09:28 PM UTC-5 lofid...@gmail.com wrote:
You can use my zip file and follow the tutorial using that zip file Maven project... 

The GWT Java code like in the tutorial doesn't change at all, only the project structure with TBroyer GWT Maven plugin...

lofid...@gmail.com schrieb am Freitag, 30. April 2021 um 19:07:22 UTC+2:
Do not use that old GWT Maven plugin... it makes no sense, it is too old and all of the new stuffs in GWT are using TBroyer GWT Maven plugin 😉

It's very good Maven plugin...

likejudo schrieb am Freitag, 30. April 2021 um 18:51:52 UTC+2:
I was trying to follow the tutorial so I did not try your other sample yet.
I think the reason is, my employer uses Mojo GWT Maven from Codehaus.
Unless I am mistaken, it does not seem to have gwt-app packaging.

On Friday, April 30, 2021 at 11:46:04 AM UTC-5 lofid...@gmail.com wrote:
Hmm wyrd...

Did you try to download the zip (https://github.com/lofidewanto/gwt-boot-sample-basic/archive/refs/heads/main.zip), unpack it and start in the unpack directory?

mvn gwt:generate-module gwt:devmode

or complete:

mvn net.ltgt.gwt.maven:gwt-maven-plugin:generate-module net.ltgt.gwt.maven:gwt-maven-plugin:devmode
likejudo schrieb am Freitag, 30. April 2021 um 17:54:19 UTC+2:
> Try following this tutorial https://dev.to/ibaca/modern-gwt-first-steps-509k
I tried it but when I run mvn package
I get error:
Unknown packaging: gwt-app

On Thursday, April 29, 2021 at 3:39:14 PM UTC-5 aka...@gmail.com wrote:
Try following this tutorial https://dev.to/ibaca/modern-gwt-first-steps-509k

On Thursday, April 29, 2021 at 11:36:02 PM UTC+3 lofid...@gmail.com wrote:
Hi,

today I won't use the GWT plugin for Eclipse anymore... 

I would just use Eclipse / IntelliJ / Visual Studio Code and Maven.

Some introductions:
Hope this helps.
likejudo schrieb am Donnerstag, 29. April 2021 um 19:57:18 UTC+2:
I am learning GWT and was trying to run this tutorial http://www.gwtproject.org/doc/latest/tutorial/index.html

Using the Eclipse GWT plugin 3.0 on Windows 10 and JDK 11

I get this error on the first line Error: There is '1' error in 'gwt-module.dtd'.

I installed the plugin from the marketplace.
I see this error in other tutorials too.

Any suggestions appreciated.

--
You received this message because you are subscribed to the Google Groups "GWT Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-web-toolkit/34eed804-657a-4fa3-ba13-8019a45a38a0n%40googlegroups.com.

No comments:

Post a Comment