SDM + gin + generated GinModule not working well together

312 views
Skip to first unread message

Nicolas Morel

unread,
Nov 16, 2014, 3:56:20 PM11/16/14
to google-web-tool...@googlegroups.com
Hi, 

I'm currently testing GWT 2.7.0-rc1 and one of my project using GWTP Rest-Dispatch is not working under SDM. 
The compilation fails with this error : 

                  [ERROR] Unable to load gin module type [com.gwtplatform.dispatch.rest.client.RestGinModule], maybe you haven't compiled your client java sources?
java.lang.ClassNotFoundException: com$gwtplatform$dispatch$rest$client$RestGinModule
at com.google.gwt.inject.rebind.GinBridgeClassLoader.findClass(GinBridgeClassLoader.java:150)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at com.google.gwt.inject.rebind.GinBridgeClassLoader.loadClass(GinBridgeClassLoader.java:108)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:340)
at com.google.gwt.inject.rebind.GinjectorGenerator.loadClass(GinjectorGenerator.java:223)
at com.google.gwt.inject.rebind.GinjectorGenerator.getPropertyModuleClasses(GinjectorGenerator.java:137)
at com.google.gwt.inject.rebind.GinjectorGenerator.getModuleClasses(GinjectorGenerator.java:116)
at com.google.gwt.inject.rebind.GinjectorGenerator.generate(GinjectorGenerator.java:72)
at com.google.gwt.core.ext.IncrementalGenerator.generateNonIncrementally(IncrementalGenerator.java:40)

The full stack trace is available in attachment.

The problem has been reported to the GWTP team here. The "normal" compilation works but not the incremental compile from SDM.

I made a simple example available here.

From what I saw, the RestGinModule that gin is trying to load is generated by a GWT generator (VelocityGenerator.generateRestGinModule()) and passed to gin through the property "gin.ginjector.modules". 
It seems unconventional but was working before.
Any ideas what is going on please ?



SDM_error.txt

confile

unread,
Nov 17, 2014, 7:48:22 AM11/17/14
to google-web-tool...@googlegroups.com
I can confirm that this problem occurs to me too.

Michael

Christopher Viel

unread,
Nov 17, 2014, 5:05:22 PM11/17/14
to google-web-tool...@googlegroups.com
Hi,

I'm gonna add some more background here.

The generator generates a bunch of file and binds the interfaces using GIN. I would't say this is strictly necessary, but it brings the advantages of DI to the generated code. So we have an Entry Point that is an interface and a rebind rule. UserAgentAsserter uses a similar technique. What we also do is generate a Ginjector interface and put a GWT.create(GeneratedGinjector.class) call inside the generated entry point. That way GIN's generator is called after and everything should be resolvable. The generated ginjector is setup to look at a specific property to load additional gin modules. Here it happens  that one of them is also generated. So all of that actually work with 2.7.

What no longer works is if the entry point and the ginjector are no longer generated. If there is a GWT.create() call that resolves to a Ginjector from an explicit entry point, it fails. I'm not sure I'm being very clear here so here's an example:

MyModule.gwt.xml:
<module>
   
<entry-point class="com.project.EntryPointToGenerate"/>
   
<entry-point class="com.project.ExplicitEntryPoint"/>

   
<extend-configuration-property name="gin.ginjector.modules"
           
value="com.project.GeneratedGinModule"/>

   
<generate-with class="com.project.EntryPointGenerator">
       
<when-type-is class="com.project.EntryPointToGenerate"/>
   
</generate-with>
</module>

EntryPointToGenerate:
public interface EntryPointToGenerate extends EntryPoint {}

EntryPointGenerator: Generates com.project.GeneratedGinModule and an implementation of EntryPointToGenerate

ExplicitEntryPoint
public class ExplicitEntryPoint implements EntryPoint {
   
private static final ExplicitGinjector GINJECTOR = GWT.create(ExplicitGinjector.class);

   
@Override
   
public void onModuleLoad() {}
}

ExplicitGinjector:
@GinModules( value = ExplicitGinModule.class, properties = "gin.ginjector.modules" )
public interface ExplicitGinjector extends Ginjector {
   
/* snip */
}

With this code in a regular compilation, EntryPointToGenerate is generated before ExplicitEntryPoint is traversed. With incremental compilation, ExplicitEntryPoint is traversed (and incidentally GINs generator is called) before EntryPointGenerator is called. I would expect the first entry point to be traversed at first, even if it means calling a generator.

John Stalcup

unread,
Nov 20, 2014, 6:04:03 PM11/20/14
to google-web-tool...@googlegroups.com
Though we do not make a promise to process GWT.create() of entry point types before any other GWT.create() calls, it was easy to restore this behavior in incremental, so I went ahead and did it (https://gwt-review.googlesource.com/#/c/10410/).

You should probably find a way not to depend on this in the future, as it is not promised and may change again.


--
You received this message because you are subscribed to the Google Groups "GWT Contributors" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit-co...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-web-toolkit-contributors/57be9c00-e1f2-4c99-ad20-40c0c86943aa%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Nicolas Morel

unread,
Nov 26, 2014, 4:15:11 AM11/26/14
to google-web-tool...@googlegroups.com
Thanks for the patch, it works on the hello world project I made.
However, it is still not enough for the bigger project I'm working on. I'll try to investigate and determine what's going on or reproduce it via a more complex example. 
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit-contributors+unsubscribe@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages