Thursday, January 30, 2025

Re: GWT Development workflow

Danke Jens. Just got around to answering it now.

For context, I'm planning to migrate the whole app to the new tbroyer mvn plugin and was looking for some quick interim solution. I've tested the tbroyer mvn plugin in the past and need to familiarise myself with it again.

By "SuperDevMode" do you mean the CodeServer, don't you?

Cheers,
Thomas 

On Saturday, January 25, 2025 at 11:54:42 PM UTC+8 Jens wrote:
You should definitely move to the tbroyer maven plugin if you use maven.

In general the CodeServer class has a parameter named "-launcherDir". It should point to your exploded war directory or, if not, the content of configured folder should be included in the war file you build for development. CodeServer produces a special *.nocache.js file which automatically triggers recompilation in the browser whenever you reload the page.

Other than that the workflow is pretty much what you have described:
- Launch SuperDevMode
- Launch a servlet container, e.g. Jetty, Tomcat, whatever (local installation, docker container, ...)
- Use an exploded war directory or a package war file which includes the output of SuperDevMode
- If you make code changes you have to either redeploy your app, reload the page to trigger a GWT recompile or do both.

Personally I use Gradle to launch SuperDevMode and to build the development war file. Then I use exactly the same stack as in production via docker images to deploy and serve the war file. This minimizes differences between development and production and thus minimizes surprises. 

-- J.

tbb schrieb am Freitag, 24. Januar 2025 um 00:39:14 UTC+1:
Thanks @tekkyru and and @Craig. I'm using maven, but with the old mojo plugin, not the tbroyer one. I'll check out what the tbroyer one does. My plan is to move to that one anyway.

On Thursday, January 23, 2025 at 3:34:24 PM UTC+8 Craig Mitchell wrote:
I switched to use Maven.

I created a template from  https://github.com/NaluKit/gwt-maven-springboot-archetype  and merged that framework to my project.


On Thursday, 23 January 2025 at 2:38:42 pm UTC+11 tekkyru wrote:
Hi Thomas

In my development cycle I had to get rid of Jetty and GWT Eclipse plugin (I use Eclipse) because of "JAR hell" caused by different tools running in same classloader (Eclipse GWT plugin, GWT code server, my Spring web app, Jetty)
To do that I have created a Gradle task (I use Gradle) running GWT dev server targeting an Eclipse WTP plugin folder (for Tomcat in my case). It took time to configure separate classpaths but finally it worked.
Then I run my web app the standard way as Eclipse/Tomcat server of my choice, run the Gradle GWT code server task (as Eclipse external tool) and use my webapp as if it was deployed on production - just open my index page and the GWT code server  (in SuperDev mode) does the magic of compiling on the fly.
GWT code server points to working folder of the Eclipse WTP plugin synched with my sources. This way I don't need to compile anything explicitly, I just shortly see the GWT compilation page before my main app page is loaded.

On Thursday, January 23, 2025 at 1:30:13 AM UTC+1 tbb wrote:
Hi all,

I've been a long-time user of GWT, and I'm working on a fairly large project based on GWT 2.8.2.

Our dev workflow is using GWT's DevMode with the built-in Jetty server. We're about to upgrade our stack for newer GWT and Java versions. As mentioned in this group many times, DevMode is no longer recommended and doesn't work for our setup in newer GWT/JDK combinations. So I want/need to use a webserver + codeserver. I've now got Tomcat/Cargo with Codeserver working, but I'm not 100% on the typical dev cycle.

As I understand it, it would be:
- Build the (exploded) WAR, which includes a GWT compile (1 permutation for dev). I've read that Codeserver only works with a compiled GWT app. 
- Run Cargo/Tomcat 
- Run GWT Codeserver
- In the browser, click on bookmarklet to compile
- Refresh the page for GWT compile

It's more involved than previously just starting gwt:debug, so maybe I'm missing some best practice?

What's your dev workflow?

Cheers,
Thomas

--
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 visit https://groups.google.com/d/msgid/google-web-toolkit/cf895ae6-74df-4a44-a58f-6dff72d2d056n%40googlegroups.com.

Re: GWT Dev Conflict with Spring Boot 3.4 and Google GSON

fyi:  Springboot 3.4.2 fixed the Gson conflict issue.  https://github.com/spring-projects/spring-boot/issues/43442

On Saturday, 11 January 2025 at 3:36:00 am UTC+11 Khun Yee Fung wrote:
Oh that is perfect. Thanks Colin. I never had gwt-user.jar on my server side classpath. But to get my GWT 2.12.1 app working with jetty 12 inside IntelliJ, I thought I had to do that because it has com.google.gwt.user.server.rpc.RPC and gwt-servlet-jakarta.jar does not have that class. It is still in gwt-user.jar though. Your message got me looking for RPC in other places. Sure enough, it is now com.google.gwt.user.server.rpc.jakarta.RPC in gwt-servlet-jakarta.jar. (From here you can tell I still have server, client, and share code mixed up. That is a 15-plus year legacy.)

That is the last remaining piece for me to get the program running inside IntelliJ with Jetty 12 properly without gwt-user.jar on the server side. It has been a multi-month long struggle, but I think I can safely deploy all my GWT programs with jetty 12 in production soon.

Thanks again.


On Thursday, January 9, 2025 at 8:14:09 PM UTC-5 Colin Alworth wrote:
Can you confirm that? XsrfTokenServiceServlet and Md5Utils are definitely in gwt-servlet.jar:

$ unzip -l ~/.m2/repository/org/gwtproject/gwt-servlet/2.12.1/gwt-servlet-2.12.1.jar| grep XsrfTokenServiceServlet
     2692  2024-11-11 08:46   com/google/gwt/user/server/rpc/XsrfTokenServiceServlet.class

$ unzip -l ~/.m2/repository/org/gwtproject/gwt-servlet/2.12.1/gwt-servlet-2.12.1.jar| grep Md5Utils
     1108  2024-11-11 08:45   com/google/gwt/util/tools/shared/Md5Utils$1.class
     1115  2024-11-11 08:45   com/google/gwt/util/tools/shared/Md5Utils.class

Neither gwt-user nor gwt-dev should be on your server classpath. If you're using GWT-RPC, only gwt-servlet (or gwt-servlet-jakarta) should be necessary.

Using @UnsafeNativeLong in shared code doesn't make sense to me, perhaps you can share what you're trying to do (though you said it was factored out, so maybe it doesn't actually apply here). My general expectation would be to see this only in client-only code.
On Thursday, January 9, 2025 at 7:04:46 PM UTC-6 tequil...@gmail.com wrote:
Hi Colin,

> That said... you should not have gwt-dev on the same classpath as your server.

Unfortunately in my case I could not avoid it.
I use com.google.gwt.user.server.rpc.XsrfTokenServiceServlet (from gwt-user) and it refers com.google.gwt.util.tools.shared.Md5Utils from gwt-dev (GWT 2.12.1)
So I have to keep gwt-dev in classpath
There's another class I need, com.google.gwt.core.client.UnsafeNativeLong also in gwt-dev, but it can be factored out so it's not that critical. It's just useless to do that while XsrfTokenServiceServlet  still needs gwt-dev

On Thursday, January 9, 2025 at 3:36:33 AM UTC+1 Colin Alworth wrote:
Update the GSON version as you're doing - Ahmad is in the process of making this change in GWT itself:

In the next GWT release, we'll default to using 2.11.0.

That said... you should not have gwt-dev on the same classpath as your server, and you should not remove gson from gwt-dev, or you may have compilation issues with sourcemaps.

The tweak you're making is totally acceptable to make to gwt-servlet (or gwt-servlet-jakarta) though - either exclude if you don't use the stack trace deobfuscator with sourcemaps, or just update to 2.11.0.

On Wednesday, January 8, 2025 at 8:28:39 PM UTC-6 ma...@craig-mitchell.com wrote:
When upgrading from Spring Boot 3.3 to 3.4, my app still compiles, but when I run it, crashes with:

Error starting ApplicationContext. To display the condition evaluation report re-run your application with 'debug' enabled.
[2025-01-09 12:36:47.028] - 13568 SEVERE [restartedMain] --- org.springframework.boot.SpringApplication: Application run failed
java.lang.NoClassDefFoundError: com/google/gson/Strictness

Others have reported the same issue, but with different causes:  https://github.com/spring-projects/spring-boot/issues/43442

When I look at who is using GSON, it's gwt-dev.jar:

[INFO] teamdrift:drift-team-client:gwt-app:1.0-SNAPSHOT
[INFO] +- org.gwtproject:gwt-dev:jar:2.12.1:compile
[INFO] |  +- com.google.code.gson:gson:jar:2.6.2:compile

I can fix it by adding the newer version to my server:
<dependency>
  <groupId>com.google.code.gson</groupId>
  <artifactId>gson</artifactId>
  <version>2.11.0</version>
</dependency>

And optionally, to clean up so the old version, remove it from my client gwt-dev:
<dependency>
  <groupId>org.gwtproject</groupId>
  <artifactId>gwt-dev</artifactId>
  <exclusions>
    <exclusion>
      <groupId>com.google.code.gson</groupId>
      <artifactId>gson</artifactId>
    </exclusion>
  </exclusions>
</dependency>

Is this the best fix?  Or is there something better?

Thanks.

--
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 visit https://groups.google.com/d/msgid/google-web-toolkit/782c0865-b6d9-40dd-8671-efd9fdfa7828n%40googlegroups.com.

Monday, January 27, 2025

Re: Contribute emulation of org.apache.log4j?

Yes, I can make it into a separate library, but I am thinking users may not
realize it exists.  If it is included in GWT, they will get it automatically.


GWT SDK will only ship JRE emulation out of the box. Emulation for third party libraries must be provided externally. 

GWT maintainers will not maintain emulation code for all kinds of third party libaries and keep it up-to-date. 

-- J.

--
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 visit https://groups.google.com/d/msgid/google-web-toolkit/c6c2b6b6-ab6b-4977-8f52-5319949187ban%40googlegroups.com.

Saturday, January 25, 2025

Re: GWT Development workflow

You should definitely move to the tbroyer maven plugin if you use maven.

In general the CodeServer class has a parameter named "-launcherDir". It should point to your exploded war directory or, if not, the content of configured folder should be included in the war file you build for development. CodeServer produces a special *.nocache.js file which automatically triggers recompilation in the browser whenever you reload the page.

Other than that the workflow is pretty much what you have described:
- Launch SuperDevMode
- Launch a servlet container, e.g. Jetty, Tomcat, whatever (local installation, docker container, ...)
- Use an exploded war directory or a package war file which includes the output of SuperDevMode
- If you make code changes you have to either redeploy your app, reload the page to trigger a GWT recompile or do both.

Personally I use Gradle to launch SuperDevMode and to build the development war file. Then I use exactly the same stack as in production via docker images to deploy and serve the war file. This minimizes differences between development and production and thus minimizes surprises. 

-- J.

tbb schrieb am Freitag, 24. Januar 2025 um 00:39:14 UTC+1:
Thanks @tekkyru and and @Craig. I'm using maven, but with the old mojo plugin, not the tbroyer one. I'll check out what the tbroyer one does. My plan is to move to that one anyway.

On Thursday, January 23, 2025 at 3:34:24 PM UTC+8 Craig Mitchell wrote:
I switched to use Maven.

I created a template from  https://github.com/NaluKit/gwt-maven-springboot-archetype  and merged that framework to my project.


On Thursday, 23 January 2025 at 2:38:42 pm UTC+11 tekkyru wrote:
Hi Thomas

In my development cycle I had to get rid of Jetty and GWT Eclipse plugin (I use Eclipse) because of "JAR hell" caused by different tools running in same classloader (Eclipse GWT plugin, GWT code server, my Spring web app, Jetty)
To do that I have created a Gradle task (I use Gradle) running GWT dev server targeting an Eclipse WTP plugin folder (for Tomcat in my case). It took time to configure separate classpaths but finally it worked.
Then I run my web app the standard way as Eclipse/Tomcat server of my choice, run the Gradle GWT code server task (as Eclipse external tool) and use my webapp as if it was deployed on production - just open my index page and the GWT code server  (in SuperDev mode) does the magic of compiling on the fly.
GWT code server points to working folder of the Eclipse WTP plugin synched with my sources. This way I don't need to compile anything explicitly, I just shortly see the GWT compilation page before my main app page is loaded.

On Thursday, January 23, 2025 at 1:30:13 AM UTC+1 tbb wrote:
Hi all,

I've been a long-time user of GWT, and I'm working on a fairly large project based on GWT 2.8.2.

Our dev workflow is using GWT's DevMode with the built-in Jetty server. We're about to upgrade our stack for newer GWT and Java versions. As mentioned in this group many times, DevMode is no longer recommended and doesn't work for our setup in newer GWT/JDK combinations. So I want/need to use a webserver + codeserver. I've now got Tomcat/Cargo with Codeserver working, but I'm not 100% on the typical dev cycle.

As I understand it, it would be:
- Build the (exploded) WAR, which includes a GWT compile (1 permutation for dev). I've read that Codeserver only works with a compiled GWT app. 
- Run Cargo/Tomcat 
- Run GWT Codeserver
- In the browser, click on bookmarklet to compile
- Refresh the page for GWT compile

It's more involved than previously just starting gwt:debug, so maybe I'm missing some best practice?

What's your dev workflow?

Cheers,
Thomas

--
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 visit https://groups.google.com/d/msgid/google-web-toolkit/f01c4e58-7542-4210-8c22-9962d37051d2n%40googlegroups.com.

Thursday, January 23, 2025

Re: GWT Development workflow

Thanks @tekkyru and and @Craig. I'm using maven, but with the old mojo plugin, not the tbroyer one. I'll check out what the tbroyer one does. My plan is to move to that one anyway.

On Thursday, January 23, 2025 at 3:34:24 PM UTC+8 Craig Mitchell wrote:
I switched to use Maven.

I created a template from  https://github.com/NaluKit/gwt-maven-springboot-archetype  and merged that framework to my project.


On Thursday, 23 January 2025 at 2:38:42 pm UTC+11 tekkyru wrote:
Hi Thomas

In my development cycle I had to get rid of Jetty and GWT Eclipse plugin (I use Eclipse) because of "JAR hell" caused by different tools running in same classloader (Eclipse GWT plugin, GWT code server, my Spring web app, Jetty)
To do that I have created a Gradle task (I use Gradle) running GWT dev server targeting an Eclipse WTP plugin folder (for Tomcat in my case). It took time to configure separate classpaths but finally it worked.
Then I run my web app the standard way as Eclipse/Tomcat server of my choice, run the Gradle GWT code server task (as Eclipse external tool) and use my webapp as if it was deployed on production - just open my index page and the GWT code server  (in SuperDev mode) does the magic of compiling on the fly.
GWT code server points to working folder of the Eclipse WTP plugin synched with my sources. This way I don't need to compile anything explicitly, I just shortly see the GWT compilation page before my main app page is loaded.

On Thursday, January 23, 2025 at 1:30:13 AM UTC+1 tbb wrote:
Hi all,

I've been a long-time user of GWT, and I'm working on a fairly large project based on GWT 2.8.2.

Our dev workflow is using GWT's DevMode with the built-in Jetty server. We're about to upgrade our stack for newer GWT and Java versions. As mentioned in this group many times, DevMode is no longer recommended and doesn't work for our setup in newer GWT/JDK combinations. So I want/need to use a webserver + codeserver. I've now got Tomcat/Cargo with Codeserver working, but I'm not 100% on the typical dev cycle.

As I understand it, it would be:
- Build the (exploded) WAR, which includes a GWT compile (1 permutation for dev). I've read that Codeserver only works with a compiled GWT app. 
- Run Cargo/Tomcat 
- Run GWT Codeserver
- In the browser, click on bookmarklet to compile
- Refresh the page for GWT compile

It's more involved than previously just starting gwt:debug, so maybe I'm missing some best practice?

What's your dev workflow?

Cheers,
Thomas

--
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 visit https://groups.google.com/d/msgid/google-web-toolkit/fc09d060-574b-42e4-ba28-bbcbf00fb5abn%40googlegroups.com.

Tuesday, January 21, 2025

Re: GWTDevPluginSetup Install issue

Can you clarify which GWT version and which IE version you are using? Thomas is right of course that the next GWT version won't even be able to start legacy dev mode, and other recent releases have removed specific implementations of UI types that needed IE specialization - but if you use GWT 2.10.1 IE11 should still work, and GWT 2.9 will support IE 8-10.

With that said, the icon and buttons in that error message don't look to me like IE, but chromium - and that error message appears to be a chromium message format. Indeed, here's the constant value in the chromium sources:
https://github.com/chromium/chromium/blob/70c0998f9a2abf76f4083f80fbae94220f7e6e06/components/update_client/update_client_errors.h#L135

Can you confirm that you're running IE11 or earlier, and not Edge?

On Tuesday, January 21, 2025 at 5:15:06 AM UTC-6 Thomas Broyer wrote:
I'm afraid IE has been unsupported by Microsoft for more than 2 years now: https://learn.microsoft.com/en-us/lifecycle/faq/internet-explorer-microsoft-edge
and "dev mode" in GWT has been "legacy" for more than 10 years‼
(and fwiw, GWT 2.13 will completely remove the remaining code associated with IE: https://github.com/gwtproject/gwt/commit/2ec01342d456828078115ea534e9c9309821220d)

On Tuesday, January 21, 2025 at 10:18:47 AM UTC+1 guruda...@gmail.com wrote:
Hi Folks,

I am trying to install GWTDevPluginSetup.exe for IE, but it throws below issue


GWTIssue.PNG

I guess this is online installer, because whenever i execute the exe file, it shows connecting to internet and failed with this image. Somehow this original dump files were removed by GWT. Kindly suggest some ideas or way to fix this as it affects my project work. 

Thank you!

--
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 visit https://groups.google.com/d/msgid/google-web-toolkit/cebac106-e037-43b3-8679-c2b05f30712bn%40googlegroups.com.

Re: GWTDevPluginSetup Install issue

I'm afraid IE has been unsupported by Microsoft for more than 2 years now: https://learn.microsoft.com/en-us/lifecycle/faq/internet-explorer-microsoft-edge
and "dev mode" in GWT has been "legacy" for more than 10 years‼
(and fwiw, GWT 2.13 will completely remove the remaining code associated with IE: https://github.com/gwtproject/gwt/commit/2ec01342d456828078115ea534e9c9309821220d)

On Tuesday, January 21, 2025 at 10:18:47 AM UTC+1 guruda...@gmail.com wrote:
Hi Folks,

I am trying to install GWTDevPluginSetup.exe for IE, but it throws below issue


GWTIssue.PNG

I guess this is online installer, because whenever i execute the exe file, it shows connecting to internet and failed with this image. Somehow this original dump files were removed by GWT. Kindly suggest some ideas or way to fix this as it affects my project work. 

Thank you!

--
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 visit https://groups.google.com/d/msgid/google-web-toolkit/0da5267a-ec4b-44dc-886a-89a7aa2f49b4n%40googlegroups.com.

GWTDevPluginSetup Install issue

Hi Folks,

I am trying to install GWTDevPluginSetup.exe for IE, but it throws below issue


GWTIssue.PNG

I guess this is online installer, because whenever i execute the exe file, it shows connecting to internet and failed with this image. Somehow this original dump files were removed by GWT. Kindly suggest some ideas or way to fix this as it affects my project work. 

Thank you!

--
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 visit https://groups.google.com/d/msgid/google-web-toolkit/509c6988-c6cf-449c-871e-b43c60fffbf4n%40googlegroups.com.

Monday, January 13, 2025

Re: JsInterop consuming JS with a attributes

Interesting. As far as I know it should not have worked. Your above example should map to JavaScript:

{ getUsername: function() { .... }, getProfilePictureUrl: function() { .... } }

At the bottom of the jsinterop page there is a link to the JsInterop spec: https://docs.google.com/document/d/10fmlEYIHcyead_4R1S5wKGs1t2I7Fnp_PaNaa7XTEk0/edit

It states that you need @JsProperty in that case. GWT compiler must know if it should treat the interface method as method or as property.

-- J.

Craig Mitchell schrieb am Montag, 13. Januar 2025 um 23:02:07 UTC+1:
Thanks again Thomas,

Yep, getters worked.  I thought I tried this previously, but obviously not.

I didn't need the JsProperty annotation. maybe because the interface is marked as native:

@JsType(isNative = true, name = "?", namespace = JsPackage.GLOBAL)
public interface CrazyGamesUser {
  String getUsername();
  String getProfilePictureUrl();
}

I'll update https://www.gwtproject.org/doc/latest/DevGuideCodingBasicsJsInterop.html to mention this is how you access attributes using JsInterop.

Cheers.

On Tuesday, 14 January 2025 at 4:19:36 am UTC+11 Thomas Broyer wrote:
On Monday, January 13, 2025 at 10:14:33 AM UTC+1 ma...@craig-mitchell.com wrote:
Hi Thomas,

Can an interface have attributes?  I thought interfaces can only have methods?

Yes, you'd have to make them getters (probably need to annotate them with @JsProperty too)
 
So if I make it:

@JsType(isNative = true, name = "?", namespace = JsPackage.GLOBAL)
public interface CrazyGamesUser {
}

I can't see how I can add the attributes:

public String username;
public String profilePictureUrl;

?

Thanks again.

On Monday, 13 January 2025 at 7:03:43 pm UTC+11 Thomas Broyer wrote:
Use an interface rather than a class.


Rule of thumb is: use a class only if it maps to a "constructor" in JS, i.e. something you'll either create an instance of, or use in an "instanceof" check; for everything else (generally something you get from another API or "receive" in a callback), use an interface.

In this case, I think you could also use name="Object".

On Monday, January 13, 2025 at 7:47:28 AM UTC+1 ma...@craig-mitchell.com wrote:
Overlay types do work, and make it a little better:

public class CrazyGamesUser extends JavaScriptObject {
  protected CrazyGamesUser() {}
  public final native String getUserName() /*-{ return this.username; }-*/;
  public final native String getProfilePictureUrl() /*-{ return this.profilePictureUrl; }-*/;
}

However, it would be great if JsInterop just worked, so I could just do:

@JsType(isNative = true, namespace = JsPackage.GLOBAL)
public static class CrazyGamesUser {
  public String username;
  public String profilePictureUrl;
}

Maybe I'm missing something?
On Monday, 13 January 2025 at 4:02:40 pm UTC+11 Craig Mitchell wrote:
I'm calling some existing JS that returns a JS Object which I've implemented in JsInterop:

@JsType(isNative = true, namespace = "window.CrazyGames.SDK")
public static class JsUser {
    public native Promise<CrazyGamesUser> getUser();
}

I can happily call it:
sdk.user.getUser()
  .then(user -> {
    // Do something with the user
    return null;
  })
  .catch_(error -> {
    return null;
  });

This issue is I'm struggling to work out how to define the return object "CrazyGamesUser".  The actual JS object is just this:
{
    "username": "SingingCheese.TLNU",
    "profilePictureUrl": "https://images.crazygames.com/userportal/avatars/4.png"
}

If I define it like this:

@JsType(isNative = true, namespace = JsPackage.GLOBAL)
public static class CrazyGamesUser {
  public String username;
  public String profilePictureUrl;
}

I get a java.lang.ClassCastException.

So if I set the name to "?":

@JsType(isNative = true, name = "?", namespace = JsPackage.GLOBAL)
public static class CrazyGamesUser {
  public String username;
  public String profilePictureUrl;
}

Then I get a compile error:
'?' can only be used as a name for native interfaces in the global namespace.

But if I make it an interface, I can't have the member variables.

If I do remove the member variables, it does work, and I can access them via some JSNI:

public static native String getUsername(CrazyGamesUser instance) /*-{
  return instance.username;
}-*/;

But that's really ugly.  What's the correct approach here?

Thanks.

--
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 visit https://groups.google.com/d/msgid/google-web-toolkit/b0909a0e-46c5-4717-87c8-15eef025bbb3n%40googlegroups.com.

Re: JsInterop consuming JS with a attributes



On Monday, January 13, 2025 at 10:14:33 AM UTC+1 ma...@craig-mitchell.com wrote:
Hi Thomas,

Can an interface have attributes?  I thought interfaces can only have methods?

Yes, you'd have to make them getters (probably need to annotate them with @JsProperty too)
 
So if I make it:

@JsType(isNative = true, name = "?", namespace = JsPackage.GLOBAL)
public interface CrazyGamesUser {
}

I can't see how I can add the attributes:

public String username;
public String profilePictureUrl;

?

Thanks again.

On Monday, 13 January 2025 at 7:03:43 pm UTC+11 Thomas Broyer wrote:
Use an interface rather than a class.


Rule of thumb is: use a class only if it maps to a "constructor" in JS, i.e. something you'll either create an instance of, or use in an "instanceof" check; for everything else (generally something you get from another API or "receive" in a callback), use an interface.

In this case, I think you could also use name="Object".

On Monday, January 13, 2025 at 7:47:28 AM UTC+1 ma...@craig-mitchell.com wrote:
Overlay types do work, and make it a little better:

public class CrazyGamesUser extends JavaScriptObject {
  protected CrazyGamesUser() {}
  public final native String getUserName() /*-{ return this.username; }-*/;
  public final native String getProfilePictureUrl() /*-{ return this.profilePictureUrl; }-*/;
}

However, it would be great if JsInterop just worked, so I could just do:

@JsType(isNative = true, namespace = JsPackage.GLOBAL)
public static class CrazyGamesUser {
  public String username;
  public String profilePictureUrl;
}

Maybe I'm missing something?
On Monday, 13 January 2025 at 4:02:40 pm UTC+11 Craig Mitchell wrote:
I'm calling some existing JS that returns a JS Object which I've implemented in JsInterop:

@JsType(isNative = true, namespace = "window.CrazyGames.SDK")
public static class JsUser {
    public native Promise<CrazyGamesUser> getUser();
}

I can happily call it:
sdk.user.getUser()
  .then(user -> {
    // Do something with the user
    return null;
  })
  .catch_(error -> {
    return null;
  });

This issue is I'm struggling to work out how to define the return object "CrazyGamesUser".  The actual JS object is just this:
{
    "username": "SingingCheese.TLNU",
    "profilePictureUrl": "https://images.crazygames.com/userportal/avatars/4.png"
}

If I define it like this:

@JsType(isNative = true, namespace = JsPackage.GLOBAL)
public static class CrazyGamesUser {
  public String username;
  public String profilePictureUrl;
}

I get a java.lang.ClassCastException.

So if I set the name to "?":

@JsType(isNative = true, name = "?", namespace = JsPackage.GLOBAL)
public static class CrazyGamesUser {
  public String username;
  public String profilePictureUrl;
}

Then I get a compile error:
'?' can only be used as a name for native interfaces in the global namespace.

But if I make it an interface, I can't have the member variables.

If I do remove the member variables, it does work, and I can access them via some JSNI:

public static native String getUsername(CrazyGamesUser instance) /*-{
  return instance.username;
}-*/;

But that's really ugly.  What's the correct approach here?

Thanks.

--
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 visit https://groups.google.com/d/msgid/google-web-toolkit/efd4a74a-9f08-4b5a-a063-1af5df606bf4n%40googlegroups.com.

Re: JsInterop consuming JS with a attributes

Use an interface rather than a class.

See the note about castability in the javadoc: https://javadoc.io/doc/com.google.jsinterop/jsinterop-annotations/latest/jsinterop/annotations/JsType.html

Rule of thumb is: use a class only if it maps to a "constructor" in JS, i.e. something you'll either create an instance of, or use in an "instanceof" check; for everything else (generally something you get from another API or "receive" in a callback), use an interface.

In this case, I think you could also use name="Object".

On Monday, January 13, 2025 at 7:47:28 AM UTC+1 ma...@craig-mitchell.com wrote:
Overlay types do work, and make it a little better:

public class CrazyGamesUser extends JavaScriptObject {
  protected CrazyGamesUser() {}
  public final native String getUserName() /*-{ return this.username; }-*/;
  public final native String getProfilePictureUrl() /*-{ return this.profilePictureUrl; }-*/;
}

However, it would be great if JsInterop just worked, so I could just do:

@JsType(isNative = true, namespace = JsPackage.GLOBAL)
public static class CrazyGamesUser {
  public String username;
  public String profilePictureUrl;
}

Maybe I'm missing something?
On Monday, 13 January 2025 at 4:02:40 pm UTC+11 Craig Mitchell wrote:
I'm calling some existing JS that returns a JS Object which I've implemented in JsInterop:

@JsType(isNative = true, namespace = "window.CrazyGames.SDK")
public static class JsUser {
    public native Promise<CrazyGamesUser> getUser();
}

I can happily call it:
sdk.user.getUser()
  .then(user -> {
    // Do something with the user
    return null;
  })
  .catch_(error -> {
    return null;
  });

This issue is I'm struggling to work out how to define the return object "CrazyGamesUser".  The actual JS object is just this:
{
    "username": "SingingCheese.TLNU",
    "profilePictureUrl": "https://images.crazygames.com/userportal/avatars/4.png"
}

If I define it like this:

@JsType(isNative = true, namespace = JsPackage.GLOBAL)
public static class CrazyGamesUser {
  public String username;
  public String profilePictureUrl;
}

I get a java.lang.ClassCastException.

So if I set the name to "?":

@JsType(isNative = true, name = "?", namespace = JsPackage.GLOBAL)
public static class CrazyGamesUser {
  public String username;
  public String profilePictureUrl;
}

Then I get a compile error:
'?' can only be used as a name for native interfaces in the global namespace.

But if I make it an interface, I can't have the member variables.

If I do remove the member variables, it does work, and I can access them via some JSNI:

public static native String getUsername(CrazyGamesUser instance) /*-{
  return instance.username;
}-*/;

But that's really ugly.  What's the correct approach here?

Thanks.

--
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 visit https://groups.google.com/d/msgid/google-web-toolkit/f51ee1f0-6254-4b6a-b2b2-50dc9935b993n%40googlegroups.com.

Friday, January 10, 2025

Re: GWT Dev Conflict with Spring Boot 3.4 and Google GSON

Oh that is perfect. Thanks Colin. I never had gwt-user.jar on my server side classpath. But to get my GWT 2.12.1 app working with jetty 12 inside IntelliJ, I thought I had to do that because it has com.google.gwt.user.server.rpc.RPC and gwt-servlet-jakarta.jar does not have that class. It is still in gwt-user.jar though. Your message got me looking for RPC in other places. Sure enough, it is now com.google.gwt.user.server.rpc.jakarta.RPC in gwt-servlet-jakarta.jar. (From here you can tell I still have server, client, and share code mixed up. That is a 15-plus year legacy.)

That is the last remaining piece for me to get the program running inside IntelliJ with Jetty 12 properly without gwt-user.jar on the server side. It has been a multi-month long struggle, but I think I can safely deploy all my GWT programs with jetty 12 in production soon.

Thanks again.


On Thursday, January 9, 2025 at 8:14:09 PM UTC-5 Colin Alworth wrote:
Can you confirm that? XsrfTokenServiceServlet and Md5Utils are definitely in gwt-servlet.jar:

$ unzip -l ~/.m2/repository/org/gwtproject/gwt-servlet/2.12.1/gwt-servlet-2.12.1.jar| grep XsrfTokenServiceServlet
     2692  2024-11-11 08:46   com/google/gwt/user/server/rpc/XsrfTokenServiceServlet.class

$ unzip -l ~/.m2/repository/org/gwtproject/gwt-servlet/2.12.1/gwt-servlet-2.12.1.jar| grep Md5Utils
     1108  2024-11-11 08:45   com/google/gwt/util/tools/shared/Md5Utils$1.class
     1115  2024-11-11 08:45   com/google/gwt/util/tools/shared/Md5Utils.class

Neither gwt-user nor gwt-dev should be on your server classpath. If you're using GWT-RPC, only gwt-servlet (or gwt-servlet-jakarta) should be necessary.

Using @UnsafeNativeLong in shared code doesn't make sense to me, perhaps you can share what you're trying to do (though you said it was factored out, so maybe it doesn't actually apply here). My general expectation would be to see this only in client-only code.
On Thursday, January 9, 2025 at 7:04:46 PM UTC-6 tequil...@gmail.com wrote:
Hi Colin,

> That said... you should not have gwt-dev on the same classpath as your server.

Unfortunately in my case I could not avoid it.
I use com.google.gwt.user.server.rpc.XsrfTokenServiceServlet (from gwt-user) and it refers com.google.gwt.util.tools.shared.Md5Utils from gwt-dev (GWT 2.12.1)
So I have to keep gwt-dev in classpath
There's another class I need, com.google.gwt.core.client.UnsafeNativeLong also in gwt-dev, but it can be factored out so it's not that critical. It's just useless to do that while XsrfTokenServiceServlet  still needs gwt-dev

On Thursday, January 9, 2025 at 3:36:33 AM UTC+1 Colin Alworth wrote:
Update the GSON version as you're doing - Ahmad is in the process of making this change in GWT itself:

In the next GWT release, we'll default to using 2.11.0.

That said... you should not have gwt-dev on the same classpath as your server, and you should not remove gson from gwt-dev, or you may have compilation issues with sourcemaps.

The tweak you're making is totally acceptable to make to gwt-servlet (or gwt-servlet-jakarta) though - either exclude if you don't use the stack trace deobfuscator with sourcemaps, or just update to 2.11.0.

On Wednesday, January 8, 2025 at 8:28:39 PM UTC-6 ma...@craig-mitchell.com wrote:
When upgrading from Spring Boot 3.3 to 3.4, my app still compiles, but when I run it, crashes with:

Error starting ApplicationContext. To display the condition evaluation report re-run your application with 'debug' enabled.
[2025-01-09 12:36:47.028] - 13568 SEVERE [restartedMain] --- org.springframework.boot.SpringApplication: Application run failed
java.lang.NoClassDefFoundError: com/google/gson/Strictness

Others have reported the same issue, but with different causes:  https://github.com/spring-projects/spring-boot/issues/43442

When I look at who is using GSON, it's gwt-dev.jar:

[INFO] teamdrift:drift-team-client:gwt-app:1.0-SNAPSHOT
[INFO] +- org.gwtproject:gwt-dev:jar:2.12.1:compile
[INFO] |  +- com.google.code.gson:gson:jar:2.6.2:compile

I can fix it by adding the newer version to my server:
<dependency>
  <groupId>com.google.code.gson</groupId>
  <artifactId>gson</artifactId>
  <version>2.11.0</version>
</dependency>

And optionally, to clean up so the old version, remove it from my client gwt-dev:
<dependency>
  <groupId>org.gwtproject</groupId>
  <artifactId>gwt-dev</artifactId>
  <exclusions>
    <exclusion>
      <groupId>com.google.code.gson</groupId>
      <artifactId>gson</artifactId>
    </exclusion>
  </exclusions>
</dependency>

Is this the best fix?  Or is there something better?

Thanks.

--
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 visit https://groups.google.com/d/msgid/google-web-toolkit/b332cfe6-2a05-41b5-a3c9-ea22b1bf3b05n%40googlegroups.com.

Re: GWT Dev Conflict with Spring Boot 3.4 and Google GSON

thank you Colin, it helps a lot

I see, historically my codebase included gwt-dev instead of gwt-servlet. Now I'm replacing gwt-dev with gwt-servlet, seems to work OK

As for  @UnsafeNativeLong - the project has single code base for client and server so the class had to be reachable through the common build classpath. Anyway I can factor it out now as I don't need the gwt-dev anymore.

On Friday, January 10, 2025 at 2:14:09 AM UTC+1 Colin Alworth wrote:
Can you confirm that? XsrfTokenServiceServlet and Md5Utils are definitely in gwt-servlet.jar:

$ unzip -l ~/.m2/repository/org/gwtproject/gwt-servlet/2.12.1/gwt-servlet-2.12.1.jar| grep XsrfTokenServiceServlet
     2692  2024-11-11 08:46   com/google/gwt/user/server/rpc/XsrfTokenServiceServlet.class

$ unzip -l ~/.m2/repository/org/gwtproject/gwt-servlet/2.12.1/gwt-servlet-2.12.1.jar| grep Md5Utils
     1108  2024-11-11 08:45   com/google/gwt/util/tools/shared/Md5Utils$1.class
     1115  2024-11-11 08:45   com/google/gwt/util/tools/shared/Md5Utils.class

Neither gwt-user nor gwt-dev should be on your server classpath. If you're using GWT-RPC, only gwt-servlet (or gwt-servlet-jakarta) should be necessary.

Using @UnsafeNativeLong in shared code doesn't make sense to me, perhaps you can share what you're trying to do (though you said it was factored out, so maybe it doesn't actually apply here). My general expectation would be to see this only in client-only code.
On Thursday, January 9, 2025 at 7:04:46 PM UTC-6 tequil...@gmail.com wrote:
Hi Colin,

> That said... you should not have gwt-dev on the same classpath as your server.

Unfortunately in my case I could not avoid it.
I use com.google.gwt.user.server.rpc.XsrfTokenServiceServlet (from gwt-user) and it refers com.google.gwt.util.tools.shared.Md5Utils from gwt-dev (GWT 2.12.1)
So I have to keep gwt-dev in classpath
There's another class I need, com.google.gwt.core.client.UnsafeNativeLong also in gwt-dev, but it can be factored out so it's not that critical. It's just useless to do that while XsrfTokenServiceServlet  still needs gwt-dev

On Thursday, January 9, 2025 at 3:36:33 AM UTC+1 Colin Alworth wrote:
Update the GSON version as you're doing - Ahmad is in the process of making this change in GWT itself:

In the next GWT release, we'll default to using 2.11.0.

That said... you should not have gwt-dev on the same classpath as your server, and you should not remove gson from gwt-dev, or you may have compilation issues with sourcemaps.

The tweak you're making is totally acceptable to make to gwt-servlet (or gwt-servlet-jakarta) though - either exclude if you don't use the stack trace deobfuscator with sourcemaps, or just update to 2.11.0.

On Wednesday, January 8, 2025 at 8:28:39 PM UTC-6 ma...@craig-mitchell.com wrote:
When upgrading from Spring Boot 3.3 to 3.4, my app still compiles, but when I run it, crashes with:

Error starting ApplicationContext. To display the condition evaluation report re-run your application with 'debug' enabled.
[2025-01-09 12:36:47.028] - 13568 SEVERE [restartedMain] --- org.springframework.boot.SpringApplication: Application run failed
java.lang.NoClassDefFoundError: com/google/gson/Strictness

Others have reported the same issue, but with different causes:  https://github.com/spring-projects/spring-boot/issues/43442

When I look at who is using GSON, it's gwt-dev.jar:

[INFO] teamdrift:drift-team-client:gwt-app:1.0-SNAPSHOT
[INFO] +- org.gwtproject:gwt-dev:jar:2.12.1:compile
[INFO] |  +- com.google.code.gson:gson:jar:2.6.2:compile

I can fix it by adding the newer version to my server:
<dependency>
  <groupId>com.google.code.gson</groupId>
  <artifactId>gson</artifactId>
  <version>2.11.0</version>
</dependency>

And optionally, to clean up so the old version, remove it from my client gwt-dev:
<dependency>
  <groupId>org.gwtproject</groupId>
  <artifactId>gwt-dev</artifactId>
  <exclusions>
    <exclusion>
      <groupId>com.google.code.gson</groupId>
      <artifactId>gson</artifactId>
    </exclusion>
  </exclusions>
</dependency>

Is this the best fix?  Or is there something better?

Thanks.

--
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 visit https://groups.google.com/d/msgid/google-web-toolkit/aea3382f-22f7-4c54-b154-1f291a5b0151n%40googlegroups.com.

Thursday, January 9, 2025

Re: GWT Dev Conflict with Spring Boot 3.4 and Google GSON

Can you confirm that? XsrfTokenServiceServlet and Md5Utils are definitely in gwt-servlet.jar:

$ unzip -l ~/.m2/repository/org/gwtproject/gwt-servlet/2.12.1/gwt-servlet-2.12.1.jar| grep XsrfTokenServiceServlet
     2692  2024-11-11 08:46   com/google/gwt/user/server/rpc/XsrfTokenServiceServlet.class

$ unzip -l ~/.m2/repository/org/gwtproject/gwt-servlet/2.12.1/gwt-servlet-2.12.1.jar| grep Md5Utils
     1108  2024-11-11 08:45   com/google/gwt/util/tools/shared/Md5Utils$1.class
     1115  2024-11-11 08:45   com/google/gwt/util/tools/shared/Md5Utils.class

Neither gwt-user nor gwt-dev should be on your server classpath. If you're using GWT-RPC, only gwt-servlet (or gwt-servlet-jakarta) should be necessary.

Using @UnsafeNativeLong in shared code doesn't make sense to me, perhaps you can share what you're trying to do (though you said it was factored out, so maybe it doesn't actually apply here). My general expectation would be to see this only in client-only code.
On Thursday, January 9, 2025 at 7:04:46 PM UTC-6 tequil...@gmail.com wrote:
Hi Colin,

> That said... you should not have gwt-dev on the same classpath as your server.

Unfortunately in my case I could not avoid it.
I use com.google.gwt.user.server.rpc.XsrfTokenServiceServlet (from gwt-user) and it refers com.google.gwt.util.tools.shared.Md5Utils from gwt-dev (GWT 2.12.1)
So I have to keep gwt-dev in classpath
There's another class I need, com.google.gwt.core.client.UnsafeNativeLong also in gwt-dev, but it can be factored out so it's not that critical. It's just useless to do that while XsrfTokenServiceServlet  still needs gwt-dev

On Thursday, January 9, 2025 at 3:36:33 AM UTC+1 Colin Alworth wrote:
Update the GSON version as you're doing - Ahmad is in the process of making this change in GWT itself:

In the next GWT release, we'll default to using 2.11.0.

That said... you should not have gwt-dev on the same classpath as your server, and you should not remove gson from gwt-dev, or you may have compilation issues with sourcemaps.

The tweak you're making is totally acceptable to make to gwt-servlet (or gwt-servlet-jakarta) though - either exclude if you don't use the stack trace deobfuscator with sourcemaps, or just update to 2.11.0.

On Wednesday, January 8, 2025 at 8:28:39 PM UTC-6 ma...@craig-mitchell.com wrote:
When upgrading from Spring Boot 3.3 to 3.4, my app still compiles, but when I run it, crashes with:

Error starting ApplicationContext. To display the condition evaluation report re-run your application with 'debug' enabled.
[2025-01-09 12:36:47.028] - 13568 SEVERE [restartedMain] --- org.springframework.boot.SpringApplication: Application run failed
java.lang.NoClassDefFoundError: com/google/gson/Strictness

Others have reported the same issue, but with different causes:  https://github.com/spring-projects/spring-boot/issues/43442

When I look at who is using GSON, it's gwt-dev.jar:

[INFO] teamdrift:drift-team-client:gwt-app:1.0-SNAPSHOT
[INFO] +- org.gwtproject:gwt-dev:jar:2.12.1:compile
[INFO] |  +- com.google.code.gson:gson:jar:2.6.2:compile

I can fix it by adding the newer version to my server:
<dependency>
  <groupId>com.google.code.gson</groupId>
  <artifactId>gson</artifactId>
  <version>2.11.0</version>
</dependency>

And optionally, to clean up so the old version, remove it from my client gwt-dev:
<dependency>
  <groupId>org.gwtproject</groupId>
  <artifactId>gwt-dev</artifactId>
  <exclusions>
    <exclusion>
      <groupId>com.google.code.gson</groupId>
      <artifactId>gson</artifactId>
    </exclusion>
  </exclusions>
</dependency>

Is this the best fix?  Or is there something better?

Thanks.

--
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 visit https://groups.google.com/d/msgid/google-web-toolkit/f6fe9bf8-8d96-4801-9305-16cd7f88b55an%40googlegroups.com.