I'm getting this error at runtime when I try to use getClass.getPackage().getImplementationVersion(), in my FooterViewImpl class, to show my project's version number (from the pom.xml file) on the web page. I think the error is from the gwt java-to-javascript compiler.
[ERROR] [OnlineGlom] - Line 52: The method getPackage() is undefined for the type Class<capture#1-of ? extends FooterViewImpl>
java.lang.RuntimeException: Deferred binding failed for 'org.glom.web.client.ClientFactory' (did you forget to inherit a required module?)
Should I expect this to work?
No.
getPackage() is not emulated by GWT: https://developers.google.com/web-toolkit/doc/latest/RefJreEmulation. The motto of GWT is to do the maximum at compile-time rather than runtime.
Related
Im making a multiplayer game with GDX. it works on desktop/android but when I want to compile it with GWT I get this Error:
[ERROR] Line 24: No source code is available for type io.socket.client.Socket; did you forget to inherit a required module?
[ERROR] Line 69: No source code is available for type io.socket.client.IO; did you forget to inherit a required module?
[ERROR] Line 79: No source code is available for type io.socket.emitter.Emitter.Listener; did you forget to inherit a required module?
how can I fix this?
Socket.io is not compatible with GWT. Consider using a different framework, such like Atmosphere.
GWT compilation fails in eclipse saying the following reason. This used to happen sometimes. Eclipse project clean would solve the issue. But now it doesn seem to work. Any actual issues that might be present? Thanks.
Compiling module com.kivar.lumina.Application
Validating units:
Ignored 9 units with compilation errors in first pass.
Compile with -strict or with -logLevel set to TRACE or DEBUG to see all errors.
[ERROR] Errors in 'file:/F:/dev/insanity/agni/client/src/main/java/com/kivar/lumina/shared/requestfactory/requestcontext/SearchRequestContext.java'
[ERROR] Line 9: The import com.kivar.lumina.server.filter.FilterConfiguration cannot be resolved
[ERROR] Line 17: FilterConfiguration cannot be resolved to a type
Computing all possible rebind results for 'com.kivar.lumina.shared.requestfactory.ApplicationRequestFactory'
Rebinding com.kivar.lumina.shared.requestfactory.ApplicationRequestFactory
Checking rule <generate-with class='com.google.web.bindery.requestfactory.gwt.rebind.RequestFactoryGenerator'/>
[ERROR] Errors in 'file:/F:/dev/insanity/agni/client/src/main/java/com/kivar/lumina/shared/requestfactory/requestcontext/CampaignRequestContext.java'
[ERROR] Line 9: The import com.kivar.lumina.server.campaign.CampaignsServiceImpl cannot be resolved
[ERROR] Line 18: CampaignsServiceImpl cannot be resolved to a type
[ERROR] Errors in 'file:/F:/dev/insanity/agni/client/src/main/java/com/kivar/lumina/shared/requestfactory/requestcontext/SearchRequestContext.java'
[ERROR] Line 9: The import com.kivar.lumina.server.filter.FilterConfiguration cannot be resolved
[ERROR] Line 17: FilterConfiguration cannot be resolved to a type
[ERROR] Unable to find type 'com.kivar.lumina.shared.requestfactory.ApplicationRequestFactory'
[ERROR] Hint: Previous compiler errors may have made this type unavailable
[ERROR] Hint: Your source appears not to live underneath a subpackage called 'client';.....
From the error it is visibly seen that there is something wrong with the import with specifically below :
[ERROR] Errors in 'file:/F:/dev/insanity/agni/client/src/main/java/com/kivar/lumina/shared/requestfactory/requestcontext/SearchRequestContext.java'
[ERROR] Line 9: The import com.kivar.lumina.server.filter.FilterConfiguration cannot be resolved
Please either add the jar if you want to use FilterConfiguration. Or else, choose the src folder of the project >> Right Click >> Go to Source >> Click on unorganized imports.
It will remove all the imports which are not required for project.
From the log I can't say for sure but I can guess that in your RequestContext definitions you are declaring the service implementation. You should declare the service interface instead.
EDIT:
If a member of the Steering Committee says my answer is not clear it is probably true.
Apologies and I'll try to be more explicit.
From the log looks like there is some server class (i.e. a class that is executed on the application server; given that the log shows an error from the RequestFactory I presume we are in the middle of some client-server communication here) which is declared in the RequestFactory definition file: ApplicationRequestFactory.java.
In particular, I would expect that some parameter in some method of the interface SearchRequestContext is of type FilterConfiguration. This is wrong, you should use the relative proxy instead.
Moreover, looks like in the annotation for SearchRequestContext something like this has been declared:
#Service(value=CampaignsServiceImpl.class"...
interface SearchRequestContext extends RequestContext{
...
This is also wrong because instead of using the service implementation (i.e. CampaignsServiceImpl) you have to use an interface that is implemented by CampaingsServiceImpl (i.e. the service interface) and that exposes the methods defined in SearchRequestContext, obviously with the necessary translation for the request factory receivers.
This implementation details you can find in the request factory documentation available here: look up for the paragraph RequestFactory interface.
I hope this all makes sense to you. Please feel free to get back with questions. In case please post your RequestFactory definition file (i.e. the java interface that extends RequestFactory)
// ...some imports
public class Menu {
final MenuMaker myClass = GWT.create(MenuMaker.class); // ERROR
My ...gwt.xml:
...
<generate-with class="com.gwt.rebind.MenuGenerator">
<when-type-assignable class="com.gwt.client.MenuMaker" />
</generate-with>
...
All work perfectly when I run compile in DevMode but when I "Build the project with the GWT compiler" I get this error:
[ERROR] Line 15: Failed to resolve 'com.gwt.client.MenuMaker' via deferred binding
Scanning for additional dependencies: jar:file:/C:/eclipse/plugins/com.google.gwt.eclipse.sdkbundle_2.4.0.v201208080121-rel-r42/gwt-2.4.0/gwt-user.jar!/com/google/gwt/dom/client/DOMImpl.java
[WARN] For the following type(s), generated source was never committed (did you forget to call commit()?)
[WARN] com.gwt.client.MenuMakerGen
[ERROR] Cannot proceed due to previous errors
At the end of com.gwt.rebind.MenuGenerator:
sourceWriter.commit(logger);
Check if all your client classes have default, zero-parameter constructor. I had the same "deferred binding" issue, and it turned out that one of my classes hadn't had default constructor. It was strange, because this class wasn't even mentioned in GWT compiler log.
Check for gwt-compile problems. The message
[ERROR] Line 15: Failed to resolve '...' via deferred binding
can result from compile problems in your gwt code. In my case it was a class, which was only available on the server side of the application, but was referenced in a class belonging to 'shared' part of the application.
In Java it compiled well, so I had no error in eclipse. The above error-message only showed up when building it with maven. Still it remained somewhat difficult to find the real problem, as the message text was not very helpful.
It turned out, that running the app on com.google.gwt.dev.DevMode would produce a more detailed logfile of the gwt-compilation (probably one could configure maven to do the same?).
Right at the beginning of this more detailed log, there were entries, which pointed me to the problem described above. After correcting these problems, the "Failed to resolve ... via deferred binding"-error was gone.
Check your model/ Pojo Class should implements Serializable
interface and also
Class have default constructor(No argument constructor).
In my case, some of the model classes were not implementing com.google.gwt.user.client.rpc.IsSerializable, that's why I got the error mentioned in the question.
In my case, a key in Resource Bundle properties file which corresponds the method name was missing and the problem resolved after adding it.
It's been about 5 hrs since I decided to use JSR 303 Bean Validation in my GWT project and I gotta say I can't even express (politely) how deeply unsatisfied I am with lame documentation on the subject on Google's website.
I really hope you guys can help me.
I followed this blog post to add client-side bean validation to my project. Unfortunately it worked only once and threw an exception in runtime saying that I need to add Hibernate Validation sources to class path. I fixed that and decided to remassage my dependencies a little too (biggest mistake of my life) but I couldn't make it work ever again.
I can't play with Validation sample from GWT SDK either because it's uncompilable because it has two implementations of class ServerValidator. Weird.
So to simplify my question I created dummy GWT application using project wizard of IntelliJ IDEA.
I added following elements to module xml:
<inherits name="org.hibernate.validator.HibernateValidator"/>
<replace-with class="com.mySampleApplication.client.ClientValidatorFactory">
<when-type-is class="javax.validation.ValidatorFactory"/>
</replace-with>
Created ClientValidatorFactory:
package com.mySampleApplication.client;
import com.google.gwt.core.client.GWT;
import com.google.gwt.validation.client.AbstractGwtValidatorFactory;
import com.google.gwt.validation.client.GwtValidation;
import com.google.gwt.validation.client.impl.AbstractGwtValidator;
import javax.validation.Validator;
import javax.validation.groups.Default;
public class ClientValidatorFactory extends AbstractGwtValidatorFactory
{
#GwtValidation(value = {Organization.class}, groups = {Default.class, ClientGroup.class})
public interface GwtValidator extends Validator
{
}
#Override
public AbstractGwtValidator createValidator()
{
return GWT.create(GwtValidator.class);
}
}
And in onModuleLoad() method I added this single line which causes compiler to blow up
Validator validator = Validation.buildDefaultValidatorFactory().getValidator();
And finally I used following jars which I copied from Validation sample of GWT SDK.
hibernate-validator-4.1.0.Final-sources.jar
hibernate-validator-4.1.0.Final.jar
log4j-1.2.16.jar
slf4j-api-1.6.1.jar
slf4j-log4j12-1.6.1.jar
validation-api-1.0.0.GA-sources.jar
validation-api-1.0.0.GA.jar
But when I compile my project it gives following meaningless error:
In detailed GWT compiler log I see this:
Loaded 2315 units from persistent store.
Found 2282 cached units. Used 2282 / 2282 units from cache.
Added 0 units to persistent cache.
Validating newly compiled units
Errors in 'jar:file:/C:/work/externals/gwt/gwt-user.jar!/org/hibernate/validator/engine/ConstraintViolationImpl_CustomFieldSerializer.java'
Line 33: No source code is available for type org.hibernate.validator.engine.ConstraintViolationImpl<T>; did you forget to inherit a required module?
Errors in 'jar:file:/C:/work/externals/gwt/gwt-user.jar!/org/hibernate/validator/engine/ValidationSupport.java'
Line 43: No source code is available for type org.hibernate.validator.engine.ConstraintViolationImpl<T>; did you forget to inherit a required module?
Errors in 'jar:file:/C:/work/externals/gwt/gwt-user.jar!/org/hibernate/validator/super/org/hibernate/validator/constraints/impl/EmailValidator.java'
Line 25: No source code is available for type org.hibernate.validator.constraints.Email; did you forget to inherit a required module?
Errors in 'jar:file:/C:/work/externals/gwt/gwt-user.jar!/org/hibernate/validator/super/org/hibernate/validator/constraints/impl/ScriptAssertValidator.java'
Line 26: No source code is available for type org.hibernate.validator.constraints.Email; did you forget to inherit a required module?
Errors in 'jar:file:/C:/work/externals/gwt/gwt-user.jar!/org/hibernate/validator/super/org/hibernate/validator/constraints/impl/URLValidator.java'
Line 26: No source code is available for type org.hibernate.validator.constraints.URL; did you forget to inherit a required module?
Errors in 'jar:file:/C:/work/externals/gwt/gwt-user.jar!/org/hibernate/validator/super/org/hibernate/validator/engine/PathImpl.java'
Line 72: No source code is available for type org.hibernate.validator.engine.NodeImpl; did you forget to inherit a required module?
Why can't it find classses? I have hibernate-validator-4.1.0.Final-sources.jar in my classpath.
Any thoughts ?
I uploaded my project here if you guys want to play with it.
Case closed, guys. Error was caused by lack of hibernate validation sources in classpath because of bug in IntelliJ IDEA. Details are here.
I try to run a example code from a book and it gives errors like:
[DEBUG] [rpc] - Validating newly compiled units
[ERROR] [rpc] - Errors in 'file:/D:/UserData/ge000001/workspace/RPC/src/rpc/client/HelloService.java'
[ERROR] [rpc] - Line 8: No source code is available for type rpc.server.Person; did you forget to inherit a required module?
[ERROR] [rpc] - Errors in 'file:/D:/UserData/ge000001/workspace/RPC/src/rpc/client/HelloServiceAsync.java'
[ERROR] [rpc] - Line 9: No source code is available for type rpc.server.Person; did you forget to inherit a required module?
[ERROR] [rpc] - Errors in 'file:/D:/UserData/ge000001/workspace/RPC/src/rpc/client/RPC.java'
[ERROR] [rpc] - Line 106: No source code is available for type rpc.server.Person; did you forget to inherit a required module?
[TRACE] [rpc] - Finding entry point classes
[ERROR] [rpc] - Unable to find type 'rpc.client.RPC'
[ERROR] [rpc] - Hint: Previous compiler errors may have made this type unavailable
[ERROR] [rpc] - Hint: Check the inheritance chain from your module; it may not be inheriting a required module or a module may not be adding its source path entries properly
[ERROR] [rpc] - Failed to load module 'rpc' from user agent 'Mozilla/5.0 (Windows NT 5.1; rv:2.0.1) Gecko/20100101 Firefox/4.0.1' at localhost:1802
these type errors occurs tomany times with tdifferent project and I cannot get the reason why?
Do you have any idea or suggestion?
It means that for some reason GWT cannot find a class you're including in your code.
These errors usually occurs, and can be quite confusing, when something is fundamentally wrong with the configuration; usually something small and silly that breaks everything.
As the error message suggest it may be because its not included using <inherits name="com.yourcompany.project.SomeClass"/> or because java cannot find it (it's in a different path and not in the classpath or something like that).
It could also be that the classes include other classes/packages that cannot be converted to GWT code, and is ignored by GWT (stuff not in the core java packages). (Also if you use eclipse: it has an annoying habit of automatically add java import statements for stuff you mistype, see the problems tab and see if there are unused imports. You may have to change the preferences; setting "Unused imports" to "Warning", if it's not on by default.)
Try commenting out some of the includes and recompile, it may narrow down where the problem is. Use an IDE like Eclipse, and see if it reports errors. (I cannot give you any more specific help with the current data)