Monday, April 15, 2024

Re: Help to undrerstand how to use domino-jackson and the annotation JSONMapper

Are you certain, that the annotation processor had ran?
I have not digged into domino-jackson, but I think, the @JsonMapper annotation triggers a annotation processor. The generated classes will be found under  'target/generated-sources/annotatins'

Marco Tenti (IoProgrammo88) schrieb am Montag, 15. April 2024 um 09:16:49 UTC+2:
The problem i cannot find the generate class "Person_MapperImpl" is under the target folder somewhere ?

Il giorno venerdì 12 aprile 2024 alle 18:25:30 UTC+2 Thomas Broyer ha scritto:
Aren't you supposed to directly use the generated class rather than using GWT.create() ? (unless you also added a <replace-with> in your gwt.xml)
On Friday, April 12, 2024 at 1:20:27 PM UTC+2 tenti...@gmail.com wrote:
I'm upgrading a old project and i want to replace the old gwt-jackson (https://dominokit.com/solutions/domino-jackson/v1)  with the domino-jackson project (https://github.com/DominoKit/domino-jackson).

It should be a simple transiction, but i cannot understand how to let the GWT compilation "see" the implementations classes of the ObjectMapper interface.

Here the "old" code from gwt-jackson

public static interface AltriMetadatiDTOMapper extends com.github.nmorel.gwtjackson.client.ObjectMapper<Map<String,List<MetadatoDTOGWT>>> {} 

 ... 

 AltriMetadatiDTOMapper altriMetadatiDTOMapper = GWT.create(AltriMetadatiDTOMapper.class); String jsonAltriMetadati = altriMetadatiDTOMapper.write(object);

Here the "new" code from domino-jackson

@org.dominokit.jackson.annotation.JSONMapper public interface AltriMetadatiDTOMapper extends org.dominokit.jackson.ObjectMapper<Map<String,List<MetadatoDTOGWT>>> {}

 ... 

 AltriMetadatiDTOMapper altriMetadatiDTOMapper = GWT.create(AltriMetadatiDTOMappe.class); String jsonAltriMetadati = altriMetadatiDTOMapper.write(object);

but it give to me this error

[ERROR] Errors in 'xxx.java' [INFO] [ERROR] Line 662: Rebind result 'xxx.AltriMetadatiDTOMapper' must be a class

Did anyone know what i'm doing wrong ?

--
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/b1089cf5-e4fc-4032-a588-b6bbb73a94dfn%40googlegroups.com.

Re: Help to undrerstand how to use domino-jackson and the annotation JSONMapper

Are you certain, that the annotation processor already run?
I have not digged into domino-jackson, but I think, the @JsonMapper annotation triggers a annotation processor. The generated classes will be found under  'target/generated-sources/annotatins'


Marco Tenti (IoProgrammo88) schrieb am Montag, 15. April 2024 um 09:16:49 UTC+2:
The problem i cannot find the generate class "Person_MapperImpl" is under the target folder somewhere ?

Il giorno venerdì 12 aprile 2024 alle 18:25:30 UTC+2 Thomas Broyer ha scritto:
Aren't you supposed to directly use the generated class rather than using GWT.create() ? (unless you also added a <replace-with> in your gwt.xml)
On Friday, April 12, 2024 at 1:20:27 PM UTC+2 tenti...@gmail.com wrote:
I'm upgrading a old project and i want to replace the old gwt-jackson (https://dominokit.com/solutions/domino-jackson/v1)  with the domino-jackson project (https://github.com/DominoKit/domino-jackson).

It should be a simple transiction, but i cannot understand how to let the GWT compilation "see" the implementations classes of the ObjectMapper interface.

Here the "old" code from gwt-jackson

public static interface AltriMetadatiDTOMapper extends com.github.nmorel.gwtjackson.client.ObjectMapper<Map<String,List<MetadatoDTOGWT>>> {} 

 ... 

 AltriMetadatiDTOMapper altriMetadatiDTOMapper = GWT.create(AltriMetadatiDTOMapper.class); String jsonAltriMetadati = altriMetadatiDTOMapper.write(object);

Here the "new" code from domino-jackson

@org.dominokit.jackson.annotation.JSONMapper public interface AltriMetadatiDTOMapper extends org.dominokit.jackson.ObjectMapper<Map<String,List<MetadatoDTOGWT>>> {}

 ... 

 AltriMetadatiDTOMapper altriMetadatiDTOMapper = GWT.create(AltriMetadatiDTOMappe.class); String jsonAltriMetadati = altriMetadatiDTOMapper.write(object);

but it give to me this error

[ERROR] Errors in 'xxx.java' [INFO] [ERROR] Line 662: Rebind result 'xxx.AltriMetadatiDTOMapper' must be a class

Did anyone know what i'm doing wrong ?

--
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/bd148277-b238-46d0-8448-8d3c5f4009bbn%40googlegroups.com.

Re: Really need help getting CodeServer to run with Java 11 and GWT 2.10

Note sure if this will gelp you much - we're a Gradle user, and don't use intellij. But the basic principles are the same.

When we migrated to the latest GWT we also updated our top level gradle build file to have a gwtSuperDev task which does all the heavy lifting for us:

    task gwtSuperDev(dependsOn: 'build') {
        // probably a nicer way of getting these (e.g through project sourcepaths)
        def gwtapi_src = file('tas/gwtapi/src')
        def webui_src = file('webui/src')

        doLast {
            def compilerArgs = [
                        "-strict", "-noincremental", "-noprecompile",
                        "-src", "${gwtapi_src}/",
                        "-src", "${webui_src}/",
                        "com.ascert.webui.vt.VtWebUi-dev"
                        ]

            javaexec {
                main = 'com.google.gwt.dev.codeserver.CodeServer'
                // Leverage the Gradle create classpaths for gwtapi and webui subprojects
                // Make sure GWT build libs are at the front to ensure the vanilla GWT jetty classes are used by codeserver
                classpath += configurations.gwtBuild
                // These classpaths will duplicate some of the above, but doing this way ensures our custom jetty does not get
                // picked up by GWT codeserver, which causes class inconsistencies.
                classpath += project(':proj:webui').configurations.compileClasspath
                classpath += project(':proj:tas:gwtapi').configurations.compileClasspath

                maxHeapSize = "1000m"

                args = compilerArgs.flatten()
            }
        }
    }

Our 2 main source trees are defined by gwtapi_src and webui_src. The com.ascert.webui.vt.VtWebUi-dev is our dev GWT XML file name. It's slightly different to our prod one as it has debug flags on and only creates a single large permutation.

That's really the main part. We also have the source modules on the classpath as :proj:webui and :proj:gwtapi - for reasons as per the comments.

The only other crucial part is the configurations.gwtBuild. This is a gradle configuration with all the JARs needed for codeserver (gwt_dev, gwt_user, various js lib jars such as GXT etc.). It's really just a convenient way of handling classpath JARs and nothing more. If/when we update the versions of any of those, the above automatically pulls in the updated dependency versions.

There's really nothing that special about CodeServer apart from making sure all your own sources and JARs are on the classpath, plus the standard GWT ones and any 3rd party libs you use. Although the above is for Gradle, the same principles and approach ought to apply for MVN or any other build tool.

Good luck!

-Rob


On Monday 15 April 2024 at 10:13:19 UTC+1 Mathias wrote:
Hi Thomas

unfortunately, I'm still stuck. I thought I'd attack the Lombok dependency first, since that's a third-party it depends on. I don't suppose you've ever been exposed to that? 
I tried setting the 
<classpathScope>compile</classpathScope> to the "configuration" setting of the plugin def in pluginmanagement of the root pom. That didn't help. (neither compile+runtime)

In the intellij GWT-plugin I got it working while running by setting the argument "-javaagent:/...path..../lombok-1.16.14.jar=ECJ , not sure if that could change anything. I mean this breaks at compile so I don't know.

I have gone through the configuration line-by line with both your archetype project and the NaluKit Marco tipped me about. I can't see any relevant difference. I don't have <type>gwt-lib</type> on any dependency, but neither does any of the other projects I look at.

I also tried adding lombok dependency to the plugin, it didn't help either.

I am basically stuck, this is not great. Would you have time to look at the plugin config if I pasted it?

On Friday 12 April 2024 at 11:20:01 UTC+2 Thomas Broyer wrote:
On Friday, April 12, 2024 at 7:50:42 AM UTC+2 Mathias wrote:
-My dependencies should be ok since i can build it with the plugin, so i'm a bit at a loss as to how make this work.

Dependencies for gwt:compile and gwt:codeserver aren't the same: https://tbroyer.github.io/gwt-maven-plugin/codeserver.html
You might have to either adjust the <scope> of dependencies (e.g. from provided to compile) or adjust the gwt:codeserver's classpathScope (e.g. from runtime to compile+runtime or compile)
 
as a final aside:
The "neither a gwt-lib or jar" warning messages in the error log below - i still get it if i add the gwt-lib type to the dependency, and the archetype project prints the same error when created.

Note that it's an info, not a warning 😉

--
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/ec616909-c88d-4c00-b164-3f1b7795bd86n%40googlegroups.com.

Re: Really need help getting CodeServer to run with Java 11 and GWT 2.10

Hi Thomas

unfortunately, I'm still stuck. I thought I'd attack the Lombok dependency first, since that's a third-party it depends on. I don't suppose you've ever been exposed to that? 
I tried setting the 
<classpathScope>compile</classpathScope> to the "configuration" setting of the plugin def in pluginmanagement of the root pom. That didn't help. (neither compile+runtime)

In the intellij GWT-plugin I got it working while running by setting the argument "-javaagent:/...path..../lombok-1.16.14.jar=ECJ , not sure if that could change anything. I mean this breaks at compile so I don't know.

I have gone through the configuration line-by line with both your archetype project and the NaluKit Marco tipped me about. I can't see any relevant difference. I don't have <type>gwt-lib</type> on any dependency, but neither does any of the other projects I look at.

I also tried adding lombok dependency to the plugin, it didn't help either.

I am basically stuck, this is not great. Would you have time to look at the plugin config if I pasted it?

On Friday 12 April 2024 at 11:20:01 UTC+2 Thomas Broyer wrote:
On Friday, April 12, 2024 at 7:50:42 AM UTC+2 Mathias wrote:
-My dependencies should be ok since i can build it with the plugin, so i'm a bit at a loss as to how make this work.

Dependencies for gwt:compile and gwt:codeserver aren't the same: https://tbroyer.github.io/gwt-maven-plugin/codeserver.html
You might have to either adjust the <scope> of dependencies (e.g. from provided to compile) or adjust the gwt:codeserver's classpathScope (e.g. from runtime to compile+runtime or compile)
 
as a final aside:
The "neither a gwt-lib or jar" warning messages in the error log below - i still get it if i add the gwt-lib type to the dependency, and the archetype project prints the same error when created.

Note that it's an info, not a warning 😉

--
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/7ae59c63-c4a1-44a2-8d96-f1734a52708cn%40googlegroups.com.

Re: NoClassDefFoundError on a particular class while running gwt:codeserver

Hi everyone,

@Tbroyer : I ended up change the scope of my hibernate dependencies to runtime and now it is working fine.
@Jens, just by changing the scope to runtime, with the version I specified. it is working.

thanks all for the tips.


Mnamo Ijumaa, 5 Aprili 2024 saa 10:06:46 UTC-3 Thomas Broyer aliandika:
On Thursday, April 4, 2024 at 9:29:21 PM UTC+2 dja...@gmail.com wrote:
Hi,

I can't seem to be able to point out what dependency I am missing while trying to run my gwt application in Devmode with gwt:codeserver.
I can  build the program, compile it and deploy it without a problem. However when I am trying to run it in devmode I am having this error :
java.lang.NoClassDefFoundError: Could not initialize class org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl

I have included all dependencies related to hibernate in my pom.xml with the right versions of dependency I believe. 
What am I missing?

If it builds but does not "run" then it's likely a dependency scoping issue: https://tbroyer.github.io/gwt-maven-plugin/codeserver.html
Your Hibernate dependencies have <scope>provided</scope> so I would bet on that.

--
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/87200c4c-5ad6-4c11-9462-3f586321051fn%40googlegroups.com.

Re: Problems moving JsInterop from GWT 2.7 to 2.8

" I also solved the problem of List and Map with an own Interface, which is an ArrayList/HashMap on serverside and an own implemented native List/Map on gwt side" can you share the solution ?

Il giorno venerdì 29 settembre 2017 alle 14:00:12 UTC+2 Ignacio Baca Moreno-Torres ha scritto:
We have been using this technique for more than a year and it works perfectly. We call it "Java Notation Object", hehe and you should understand the limitations, which more or less you are currently fulfilling. Just a few changes...

The most important, yes, you should use @JsType(isNative=true,namespace=GLOBAL,name="Object"), so you are actually ignoring any kind of typing, so this is more a "scheme" of where to find things than an actual typed object. This is pretty important! This is pretty similar to JSON but in Java, and these classes are not actually Java classes, are just a scheme. All these limitations are the common intersection of the feature between Java and JS.

You can do some tricks to use collections but we end up removing all of them and using arrays instead. But, to make it easy to work with, we added some @JsOverlay to return or set the Collection. For example if you have "String[] roles" you can add "@JsOverlay getRoleSet() { return Stream.of(roles).collecto(toSet()); }". Overlays are ok bc there are just like extension method or static method, so no behavior is added to the object.

This work perfectly on both sides, but there is a small annoying difference between GWT and Java, in java new Foo() will initialize primitive types and in GWT (js) will not. So we never use constructor directly, in the kind of classes we always add a static factory method and we initialize any non-nullable field, even primitives! So in java you are actually creating the object of the specified type, but in JS you are just calling "new Object()", but it is ok, bc where are using a scheme, no a type. And we never use instanceof on these schemes! This will work on the Java side, but I strongly discourage, you should not need to do that.

Finally, we never use getter and setter, don't make sense, you "cannot use inheritance" (you can use with some ticks too, for example using some int or string field as the type indicator and using, for example, the visitor pattern to traverse, this is what actually people need to do in JS so, no magic just the common intersection of features between java and json), almost everything is like final and you must not add behavior, so it is much explicit and easier to just make all field public.

I think the first you should do is removing getters and setters, and add @JsType(native,Object) to all your types, this refactor can be done almost instantly in your IDE (inline method). Then stop using Collection might not be so easy to refactor. So you might continue using it either using overlays or creating a custom jsinterop-compatible type. In this case, I recommend to not to use the whole java.util API bc it will force you to export the whole API and use generateJsInteropExports. If you are really interested or need help there just ask, but just try out avoiding maps, and using arrays. Anyways, the "Map/List own interface" should work too, just neet to make it work.

On Fri, Sep 29, 2017 at 12:53 PM Thomas Broyer <t.br...@gmail.com> wrote:


On Friday, September 29, 2017 at 11:09:42 AM UTC+2, Jürgen Beringer wrote:
Hey,

currently  I tried the 2. time to move our application from gwt 2.7 to gwt 2.8, but I have big problems with the changes of JsInterop.

The application contains a serverside java part, running in a jetty and the client part, build with gwt, so I can reuse many software on server and client side. (It is the main part of the website  www.spreadshirt.com )
To use also the same data classes (containing only fields with getter and setter, no other methods) on both sides, I used JsInterop and it works very well with gwt 2.7 and exchanged the data as json.

Example Data class:

@JsType
public class MyObject {
   
private String id;
   
   
@JsProperty
   
public String getId() {
       
return id;
   
}
   
@JsProperty
   
public void setId(String id) {
       
this.id = id;
   
}
}


The class can be used on server side like any normal java class with any REST Framework. On gwt side I was able to convert a transmitted json to the class with:


MyObject myObject = getJsTypeObject(JsonUtils.safeEval(jsonString));
//use getter and setter to access fields

public static native <T> T getJsTypeObject(JavaScriptObject result)/*-{
    return result;
}-*/
;


And to create Objects on gwt side and send them to the server as json:

MyObject myObject = new MyObject();
myObject
.setId("1");
String jsonString = stringify(myObject);


public static final native String stringify(Object result) /*-{
    return JSON.stringify(result);
}-*/
;


I also solved the problem of List and Map with an own Interface, which is an ArrayList/HashMap on serverside and an own implemented native List/Map on gwt side.

The application has more than 100 such Objects which are heavily used on server and client side in many methods which are also be used on both sides. So implementing them twice for server and client side would be a big overhead.
Now is my question, how can I convert this gwt 2.7 code to gwt 2.8 (mainly to be able to use Java8 syntax in future). I tried multiple variants, but it seems for me, JsInterop in gwt 2.8 is not planned for such usecases which were possible in gwt 2.7 withou any problems.
I can either use a native Javascript Object in gwt (native=true) or a in GWT created Object in Javascript. But I see no solution to do both with the same Type.

I get 2 Problems
  • Casting issues: I can't use native=true because I also want to create such Objects on gwt side, so on every assignment (jsonString to typed variable) I get a cast exception and at least in superdev mode I can't deactivate the cast exceptions
If you never do "instanceof" (or expect cast exceptions) on client-side, you could probably use isNative=true,namespace=GLOBAL,name="Object"; that way, all your objects are plain old JS objects (no specific class/constructor is generated in JS), which is actually exactly what you'd expect from JSON.parse().
  • field name problems: The jsonString of the last example is {"id_g_$3":"1"} and not {"id":"1"} because the JsProperty for getter and setter works only fine with native objects. If I add JsProperty to the field itself, I can't do have JsProperty for the getter and setter, so I have to add JsIgnore to them. But then when I work with native Objects I can't use the getter and setter on gwt side. I would need JsProperty on getter, setter and the field itself, but this is also not allowed.

The "id_g_$3" is probably because you don't -generateJsInteropExports; contrary to 2.7, in 2.8, the "don't obfuscate @JsProperty/@JsMethod names" only applies when you -generateJsInteropExports.
But if you switch to isNative=true,namespace=GLOBAL,name="Object", you don't even need it.

--
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-tool...@googlegroups.com.
To post to this group, send email to google-we...@googlegroups.com.
Visit this group at https://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/d/optout.

--
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/86e08739-184f-45fa-82e1-0c9965f65e2en%40googlegroups.com.

Re: Help to undrerstand how to use domino-jackson and the annotation JSONMapper

I also try to use the external approach described here https://dominokit.com/solutions/domino-jackson/v1/docs/getting-started/define-mappers but it should be the same i must have the XXMapperImpl somewhere , but the java compiler tell me that class do not exists. Maybe there is some maven configuration to add somewehre ?

Il giorno lunedì 15 aprile 2024 alle 09:16:49 UTC+2 Marco Tenti (IoProgrammo88) ha scritto:
The problem i cannot find the generate class "Person_MapperImpl" is under the target folder somewhere ?

Il giorno venerdì 12 aprile 2024 alle 18:25:30 UTC+2 Thomas Broyer ha scritto:
Aren't you supposed to directly use the generated class rather than using GWT.create() ? (unless you also added a <replace-with> in your gwt.xml)
On Friday, April 12, 2024 at 1:20:27 PM UTC+2 tenti...@gmail.com wrote:
I'm upgrading a old project and i want to replace the old gwt-jackson (https://dominokit.com/solutions/domino-jackson/v1)  with the domino-jackson project (https://github.com/DominoKit/domino-jackson).

It should be a simple transiction, but i cannot understand how to let the GWT compilation "see" the implementations classes of the ObjectMapper interface.

Here the "old" code from gwt-jackson

public static interface AltriMetadatiDTOMapper extends com.github.nmorel.gwtjackson.client.ObjectMapper<Map<String,List<MetadatoDTOGWT>>> {} 

 ... 

 AltriMetadatiDTOMapper altriMetadatiDTOMapper = GWT.create(AltriMetadatiDTOMapper.class); String jsonAltriMetadati = altriMetadatiDTOMapper.write(object);

Here the "new" code from domino-jackson

@org.dominokit.jackson.annotation.JSONMapper public interface AltriMetadatiDTOMapper extends org.dominokit.jackson.ObjectMapper<Map<String,List<MetadatoDTOGWT>>> {}

 ... 

 AltriMetadatiDTOMapper altriMetadatiDTOMapper = GWT.create(AltriMetadatiDTOMappe.class); String jsonAltriMetadati = altriMetadatiDTOMapper.write(object);

but it give to me this error

[ERROR] Errors in 'xxx.java' [INFO] [ERROR] Line 662: Rebind result 'xxx.AltriMetadatiDTOMapper' must be a class

Did anyone know what i'm doing wrong ?

--
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/226c4807-d150-4d8b-8baa-9426c0686e08n%40googlegroups.com.