Error with gin trunk: Unable to load ginjector type, maybe you haven't compiled your client java sources?

158 views
Skip to first unread message

Pierre

unread,
Jan 29, 2011, 5:10:30 PM1/29/11
to google-gin
Hi,

I have a project (Mvp4g) where I use a GWT generator to generate an
GInjector. The generator creates this java code:

public class Mvp4gModuleImpl implements Mvp4gModule {

...
@GinModules({com.mvp4g.example.client.Mvp4gGinModule.class})
public interface com_mvp4g_client_Mvp4gModuleGinjector extends
Ginjector {
com.mvp4g.example.client.main.MainPresenter
getcom_mvp4g_example_client_main_MainPresenter();
com.mvp4g.example.client.main.MainView
getcom_mvp4g_example_client_main_MainPresenterView();
com.mvp4g.client.history.ClearHistory
getcom_mvp4g_client_history_ClearHistory();

com.mvp4g.example.client.main.historyConverter.MenuHistoryConverter
getcom_mvp4g_example_client_main_historyConverter_MenuHistoryConverter();
}

...

public void createAndStartModule(){
final com_mvp4g_client_Mvp4gModuleGinjector injector =
GWT.create( com_mvp4g_client_Mvp4gModuleGinjector.class );

This works fine with gin-1.0 but when I try it with the gin trunk, I
got this error:
16:55:04.235 [ERROR] [mvp4gmodules] Unable to load ginjector type
[com.mvp4g.client.Mvp4gModuleImpl.com_mvp4g_client_Mvp4gModuleGinjector],
maybe you haven't compiled your client java sources?
java.lang.ClassNotFoundException: com$mvp4g$client$Mvp4gModuleImpl
$com_mvp4g_client_Mvp4gModuleGinjector
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:169)
at
com.google.gwt.inject.rebind.reflect.ReflectUtil.loadClass(ReflectUtil.java:
363)
at
com.google.gwt.inject.rebind.GinjectorGenerator.getGinjectorType(GinjectorGenerator.java:
57)
at
com.google.gwt.inject.rebind.GinjectorGenerator.generate(GinjectorGenerator.java:
36)
at
com.google.gwt.core.ext.GeneratorExtWrapper.generate(GeneratorExtWrapper.java:
48)
at
com.google.gwt.core.ext.GeneratorExtWrapper.generateIncrementally(GeneratorExtWrapper.java:
60)
at
com.google.gwt.dev.javac.StandardGeneratorContext.runGeneratorIncrementally(StandardGeneratorContext.java:
662)

Did something change in gin that prevents this to work?

Thanks,
Pierre

Peter Schmitt

unread,
Feb 2, 2011, 6:27:40 PM2/2/11
to googl...@googlegroups.com
Hi Pierre,

can you please make sure that your checked out version of Gin is at r161? There was a file naming bug in r159 that was fixed in r161 and that could cause an error as you describe below.

Hope this helps!

Peter


--
You received this message because you are subscribed to the Google Groups "google-gin" group.
To post to this group, send email to googl...@googlegroups.com.
To unsubscribe from this group, send email to google-gin+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-gin?hl=en.


Ben Chambers

unread,
Feb 2, 2011, 6:43:36 PM2/2/11
to googl...@googlegroups.com
I was also thinking it could be related to the move to Java reflection.  It seems like reflection may not know about the classes from other GWT generators (ie, they may not be compiled at the time the Ginjector generator is running), which could lead to this error...

If it doesn't work with the post r161 revesion, you may want to check whether it works at r158 (prior to the move to reflection).

Thomas Broyer

unread,
Feb 2, 2011, 7:45:53 PM2/2/11
to googl...@googlegroups.com


On Thursday, February 3, 2011 12:43:36 AM UTC+1, Ben Chambers wrote:
I was also thinking it could be related to the move to Java reflection.  It seems like reflection may not know about the classes from other GWT generators (ie, they may not be compiled at the time the Ginjector generator is running), which could lead to this error...

Actually, how could they be compiled? they didn't existed when you run javac prior to GWT Compiler.
 
If it doesn't work with the post r161 revesion, you may want to check whether it works at r158 (prior to the move to reflection).

Nasty side-effect; time to add a test case?

(I told you the move to Java reflection wasn't a good idea... it'd have been easier to package 2 versions of GIN: one for GWT until 2.1.x and one for 2.2.x onwards)

That being said, Pierre could probably rewrite its generator to take advantage of deferred binding (replace the code that pulls objects from the now-generated Ginjector with a generated class that would be resolved through GWT.create fallback in GIN and a replace-with or generate-with rule in the Mvp4g gwt.xml) and the code under review for issue 129 (i.e. use a single, predefined Ginjector with a method to retrieve the generated class I talked about earlier that "starts" the module, and use a configuration-property instead of his @Events annotation value; that'd probably rule out using multiple EventBus in the same app though).

But the incompatibilities between GWT 2.1 and 2.2 are very limited actually:
  • http://code.google.com/p/google-gin/source/detail?r=155 could be solved using reflection
  • the com.google.gwt.core.ext.typeinfo classes becoming interfaces, which introduces binary incompatibility, could be solved by compiling and packaging GIN twice, one for each version (GWT until 2.1 on the one hand, GWT 2.2+ on the other hand). Not ideal but workable I guess.

Thomas Broyer

unread,
Feb 4, 2011, 5:17:39 PM2/4/11
to googl...@googlegroups.com


On Thursday, February 3, 2011 1:45:53 AM UTC+1, Thomas Broyer wrote:
But the incompatibilities between GWT 2.1 and 2.2 are very limited actually:
  • http://code.google.com/p/google-gin/source/detail?r=155 could be solved using reflection
  • the com.google.gwt.core.ext.typeinfo classes becoming interfaces, which introduces binary incompatibility, could be solved by compiling and packaging GIN twice, one for each version (GWT until 2.1 on the one hand, GWT 2.2+ on the other hand). Not ideal but workable I guess.

The dual packaging is still needed apparently. I'm unable to use gin-1.1-SNAPSHOT from Jeff Larsen with gwt-*-2.2-rc1 (mislabeled GWT 2.2 M1 in Maven central)

Jeff Larsen

unread,
Feb 4, 2011, 5:22:58 PM2/4/11
to googl...@googlegroups.com

Good to know. I'll get a 2.2 compatible maven build out sometime this weekend.

Thomas Broyer

unread,
Feb 4, 2011, 6:32:17 PM2/4/11
to googl...@googlegroups.com


On Friday, February 4, 2011 11:22:58 PM UTC+1, Jeff Larsen wrote:

Good to know. I'll get a 2.2 compatible maven build out sometime this weekend.


Sorry, my bad. Bad Maven configuration: groupId first (you're using com.googlecode.gwt.inject as a groupId while GIN in Maven central is at com.google.gwt.inject), then repository URL (the issue seems to be that GitHub rewrites .../raw/master/... to .../tree/master/...?raw=true which then breaks.navigation; I still haven't the right repo URL to use, so I downloaded the POM and JAR and put them manually in my local repo, but then your repo becomes useless and I could compile GIN myself to deploy it in our own Artifactory, and using the "correct" groupId)

I now have another issue, with GIN and java generics and JSNI in the generated GinjectorImpl, where GIN generates "com.example.Foo<com.example.Bar>::new(Lcom/example/Baz;)(_0)" instead of "com.example.Foo::new(Lcom/example/Baz;)(_0)"

Peter Schmitt

unread,
Feb 4, 2011, 6:35:39 PM2/4/11
to googl...@googlegroups.com
I now have another issue, with GIN and java generics and JSNI in the generated GinjectorImpl, where GIN generates "com.example.Foo<com.example.Bar>::new(Lcom/example/Baz;)(_0)" instead of "com.example.Foo::new(Lcom/example/Baz;)(_0)"

Can you file a separate bug for that? Looks like we mess up generics for JNI.

Thomas Broyer

unread,
Feb 4, 2011, 6:53:25 PM2/4/11
to googl...@googlegroups.com
Done: http://code.google.com/p/google-gin/issues/detail?id=136

After a few minutes of investigation, it looks like SourceWriteUtil.getJsniSignature should use method.getRawDeclaringType() instead of method.getDeclaringType().

Pierre

unread,
Feb 5, 2011, 11:27:49 AM2/5/11
to google-gin
Hi,

I tried with r163 I still have the same issue but with r158,
everything works fine. It seems the Java reflection creates the
problem.

I think what Thomas suggested may not work in my case because I also
need to dynamically generate the methods inside the GInjector.

Is there any workaround for this issue?

Thanks,
Pierre

On Feb 2, 6:43 pm, Ben Chambers <bchamb...@google.com> wrote:
> I was also thinking it could be related to the move to Java reflection.  It
> seems like reflection may not know about the classes from other GWT
> generators (ie, they may not be compiled at the time the Ginjector generator
> is running), which could lead to this error...
>
> If it doesn't work with the post r161 revesion, you may want to check
> whether it works at r158 (prior to the move to reflection).
>
>
>
> On Wed, Feb 2, 2011 at 3:27 PM, Peter Schmitt <ara...@gmail.com> wrote:
> > Hi Pierre,
>
> > can you please make sure that your checked out version of Gin is at r161<http://code.google.com/p/google-gin/source/detail?r=161>?
> > There was a file naming bug in r159 that was fixed in r161 and that could
> > cause an error as you describe below.
>
> > Hope this helps!
>
> > Peter
>
> >> com.google.gwt.inject.rebind.GinjectorGenerator.getGinjectorType(GinjectorG­enerator.java:
> >> 57)
> >>    at
>
> >> com.google.gwt.inject.rebind.GinjectorGenerator.generate(GinjectorGenerator­.java:
> >> 36)
> >>    at
>
> >> com.google.gwt.core.ext.GeneratorExtWrapper.generate(GeneratorExtWrapper.ja­va:
> >> 48)
> >>    at
>
> >> com.google.gwt.core.ext.GeneratorExtWrapper.generateIncrementally(Generator­ExtWrapper.java:
> >> 60)
> >>    at
>
> >> com.google.gwt.dev.javac.StandardGeneratorContext.runGeneratorIncrementally­(StandardGeneratorContext.java:
> >> 662)
>
> >> Did something change in gin that prevents this to work?
>
> >> Thanks,
> >> Pierre
>
> >> --
> >> You received this message because you are subscribed to the Google Groups
> >> "google-gin" group.
> >> To post to this group, send email to googl...@googlegroups.com.
> >> To unsubscribe from this group, send email to
> >> google-gin+...@googlegroups.com<google-gin%2Bunsubscribe@googlegrou­ps.com>
> >> .
> >> For more options, visit this group at
> >>http://groups.google.com/group/google-gin?hl=en.
>
> >  --
> > You received this message because you are subscribed to the Google Groups
> > "google-gin" group.
> > To post to this group, send email to googl...@googlegroups.com.
> > To unsubscribe from this group, send email to
> > google-gin+...@googlegroups.com<google-gin%2Bunsubscribe@googlegrou­ps.com>
> > .
> > For more options, visit this group at
> >http://groups.google.com/group/google-gin?hl=en.- Hide quoted text -
>
> - Show quoted text -

Pierre

unread,
Feb 11, 2011, 7:30:44 AM2/11/11
to google-gin
Is there any update on this error? Will this be considered blocking
for the gin release (ie it will be fixed or a workaround will be
provided for the final release)? By the way, should I create an issue
for this?

Thanks,
Pierre
> > >http://groups.google.com/group/google-gin?hl=en.-Hide quoted text -
>
> > - Show quoted text -- Hide quoted text -

Pierre

unread,
Feb 12, 2011, 2:11:41 PM2/12/11
to google-gin
I created an issue for this error: issue 137.
> > > >http://groups.google.com/group/google-gin?hl=en.-Hidequoted text -

Peter Schmitt

unread,
Feb 12, 2011, 5:51:24 PM2/12/11
to googl...@googlegroups.com
Hi Pierre,

my apologies for the delay answering this question. For better or worse I changed the logic in Gin to simplify the codebase and caused this regression. I'm already working on a fix that allows your use case on the changed system but it's not trivial and as such might take a while to implement. Unless there is a large argument for it, I'm not going to consider this regression release blocking although I'd be willing to cut a new release once it's fixed (the fix would mainly require changes in GWT anyways).

Thanks for your patience!

Peter


To unsubscribe from this group, send email to google-gin+...@googlegroups.com.

Pierre

unread,
Feb 13, 2011, 11:44:40 AM2/13/11
to google-gin
Hi Peter,

Thanks for the update and thanks for already working on a solution.

Does it mean that GIN based on Java reflection can't fully work except
if a new version of GWT is released? If it's the case, shouldn't you
wait for this GWT release before moving GIN to reflection? Also does
moving to Java reflection bring any new feature to GIN (but the fact
it's compatible with any version of GWT)? If not, maybe the idea
suggested by Thomas to have 2 versions could be followed.

I'm concerned that if we have to wait for changes in GWT, the fix
won't occur before a few months. this issue is blocking for Mvp4g so
it would be great if it could fix before the next release.

Thanks,
Pierre

On Feb 12, 5:51 pm, Peter Schmitt <ara...@gmail.com> wrote:
> Hi Pierre,
>
> > > > >http://groups.google.com/group/google-gin?hl=en.-Hidequoted text -
>
> > > > - Show quoted text -- Hide quoted text -
>
> > > - Show quoted text -
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "google-gin" group.
> > To post to this group, send email to googl...@googlegroups.com.
> > To unsubscribe from this group, send email to
> > google-gin+...@googlegroups.com.
> > For more options, visit this group at
> >http://groups.google.com/group/google-gin?hl=en.- Hide quoted text -
Reply all
Reply to author
Forward
0 new messages