Groups keyboard shortcuts have been updated
Dismiss
See shortcuts

GWT Dev Conflict with Spring Boot 3.4 and Google GSON

285 views
Skip to first unread message

Craig Mitchell

unread,
Jan 8, 2025, 9:28:39 PMJan 8
to GWT Users
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.

Craig Mitchell

unread,
Jan 8, 2025, 9:33:50 PMJan 8
to GWT Users
Woops, spoke a little too soon.  It's not possible to clean up and remove it from gwt-dev, as the code server needs it.

So, I need 2 versions of Google GSON.  2.6.2 for GWT, and 2.11.0 for Spring Boot.

Colin Alworth

unread,
Jan 8, 2025, 9:36:33 PMJan 8
to GWT Users
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.

Craig Mitchell

unread,
Jan 8, 2025, 9:44:26 PMJan 8
to GWT Users
Awesome!  Thanks Colin and Ahmad!

> 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.

Apologies, it isn't.  I was incorrect when I sait it could be removed.  I removed it, started the code server, and everything looked good.  It wasn't until after I posted my message, I realised the code server couldn't compile the JS without it.

> 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.

Excellent.  Thanks again.  :)

tekkyru

unread,
Jan 9, 2025, 8:04:46 PMJan 9
to GWT Users
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

Colin Alworth

unread,
Jan 9, 2025, 8:14:09 PMJan 9
to GWT Users
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.

tekkyru

unread,
Jan 10, 2025, 5:26:11 AMJan 10
to GWT Users
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.

Khun Yee Fung

unread,
Jan 10, 2025, 11:36:00 AMJan 10
to GWT Users
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.

Craig Mitchell

unread,
Jan 30, 2025, 8:35:37 PMJan 30
to GWT Users
fyi:  Springboot 3.4.2 fixed the Gson conflict issue.  https://github.com/spring-projects/spring-boot/issues/43442
Reply all
Reply to author
Forward
0 new messages