GWT program run problem, please help GWT masters? - gwt

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)

Related

Font file parsing error with GWT (2.8.0) on LibGDX 1.9.5

I wonder if I am doing something wrong, or if I have stumbled upon a bug in LibGDX/GWT. I have a game with desktop/Android/iOS/HTML backends and upgrading to 1.9.5 from 1.9.5-SNAPSHOT from about a month ago made the HTML build stop working. The main change I can see is the upgrade to GWT 2.8.0 from 2.6.0.
When I run my app in a browser (Chrome 56.0.2924.21 beta (64-bit) on Windows 10), I get the following error:
GwtApplication: exception: com.badlogic.gdx.utils.SerializationException: Error reading file: static/uiskin_hd.json
com.badlogic.gdx.utils.SerializationException: Error reading file: static/uiskin_hd.json
Error reading file: static/uiskin_hd.json
Error reading file: static/uiskin_hd.json
Error loading bitmap font: static/helsinki28plain_hd.fnt
Error loading font file: static/helsinki28plain_hd.fnt
Invalid page id:
For input string: ""
The font has been working previously and I get the same result with any font, including default.fnt from LibGDX tests. The top of the font file looks like this:
info face="Helsinki" size=56 bold=0 italic=0 charset="" unicode=0 stretchH=100 smooth=1 aa=1 padding=2,2,8,4 spacing=0,0
common lineHeight=75 base=52 scaleW=512 scaleH=1024 pages=1 packed=0
page id=0 file="helsinki28plain_hd.png"
chars count=141
char id=32 x=0 y=0 width=0 height=0 xoffset=0 yoffset=52 xadvance=22 page=0 chnl=0
char id=92 x=0 y=0 width=24 height=72 xoffset=-2 yoffset=0 xadvance=22 page=0 chnl=0
char id=47 x=24 y=0 width=24 height=72 xoffset=-2 yoffset=0 xadvance=22 page=0 chnl=0
...
Just to make sure the problem isn't with my setup, I checked out the latest master branch of LibGDX and tried to run the GWT tests:
git clone https://github.com/libgdx/libgdx.git
cd libgdx
ant -f fetch
ant
./gradlew tests:gdx-tests-gwt:draftRun
This also seems to fail:
Compiling module com.badlogic.gdx.tests.gwt.GdxTestsGwt
Finding entry point classes
[ERROR] Errors in 'file:/C:/devtools/libgdx/gdx/src/com/badlogic/gdx/Net.java'
[ERROR] Line 80: No source code is available for type java.io.InputStream; did you forget to inherit a required module?
[ERROR] Errors in 'file:/C:/devtools/libgdx/backends/gdx-backends-gwt/src/com/badlogic/gdx/backends/gwt/GwtNet.java'
[ERROR] Line 70: No source code is available for type java.io.InputStream; did you forget to inherit a required module?
[ERROR] Errors in 'file:/C:/devtools/libgdx/backends/gdx-backends-gwt/src/com/badlogic/gdx/backends/gwt/preloader/Preloader.java'
[ERROR] Line 200: No source code is available for type java.io.InputStream; did you forget to inherit a required module?
[ERROR] Line 203: No source code is available for type java.io.ByteArrayInputStream; did you forget to inherit a required module?
[ERROR] Errors in 'file:/C:/devtools/libgdx/backends/gdx-backends-gwt/src/com/badlogic/gdx/backends/gwt/emu/com/badlogic/gdx/files/FileHandle.java'
[ERROR] Line 78: No source code is available for type java.io.InputStream; did you forget to inherit a required module?
[ERROR] Errors in 'file:/C:/devtools/libgdx/gdx/src/com/badlogic/gdx/net/Socket.java'
[ERROR] Line 41: No source code is available for type java.io.InputStream; did you forget to inherit a required module?
[ERROR] Errors in 'file:/C:/devtools/libgdx/backends/gdx-backends-gwt/src/com/badlogic/gdx/backends/gwt/preloader/Blob.java'
[ERROR] Line 38: No source code is available for type java.io.InputStream; did you forget to inherit a required module?
[ERROR] Errors in 'file:/C:/devtools/libgdx/backends/gdx-backends-gwt/src/com/badlogic/gdx/backends/gwt/emu/java/io/BufferedInputStream.java'
[ERROR] Line 19: No source code is available for type java.io.FilterInputStream; did you forget to inherit a required module?
[ERROR] Line 20: No source code is available for type java.io.InputStream; did you forget to inherit a required module?
[ERROR] Errors in 'file:/C:/devtools/libgdx/backends/gdx-backends-gwt/src/com/badlogic/gdx/backends/gwt/emu/java/io/Reader.java'
[ERROR] Line 33: No source code is available for type java.io.Closeable; did you forget to inherit a required module?
[ERROR] Errors in 'file:/C:/devtools/libgdx/backends/gdx-backends-gwt/src/com/badlogic/gdx/backends/gwt/emu/java/io/Writer.java'
[ERROR] Line 30: No source code is available for type java.io.Closeable; did you forget to inherit a required module?
[ERROR] Line 30: No source code is available for type java.io.Flushable; did you forget to inherit a required module?
[ERROR] Unable to find type 'com.badlogic.gdx.tests.gwt.client.GwtTestStarter'
[ERROR] Hint: Previous compiler errors may have made this type unavailable
[ERROR] 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
:tests:gdx-tests-gwt:draftCompileGwt FAILED
Any ideas what is going on here? (My Java SDK is jdk1.8.0_20)
Looks like this is a bug in LibGDX 1.9.5. A couple of people have submitted pull requests to fix it, so I expect there will shortly be a 1.9.6-SNAPSHOT available fixing this issue.
https://github.com/libgdx/libgdx/pull/4475
https://github.com/libgdx/libgdx/pull/4467

GWT compilation fails in eclipse

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)

Failed to resolve class via deferred binding

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

Adding Open CSV reader library to GWT- getting error message

Im using this library to parse CSV files in my GWT app. However, It compiles fine however, Im getting an error at runtime in the console.
In order to include it in my GWT project, I also copied the jar file into my WEB-INF->libfolder.
Then I added the path to my project at project-> rightclick->configurebuildpath...
But now Im seeing these errors on the console when I run the app:
[ERROR] Line 23: No source code is available for type au.com.bytecode.opencsv.CSVReader; did you forget to inherit a required module?
[ERROR] Line 71: No source code is available for type java.io.FileReader; did you forget to inherit a required module?
[ERROR] Line 74: No source code is available for type java.io.FileNotFoundException; did you forget to inherit a required module?
[ERROR] Unable to load module entry point class cs310.client.Main (see associated exception for details)
[ERROR] Failed to load module 'XXXX' from user agent 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_8) AppleWebKit/536.5 (KHTML, like Gecko) Chrome/19.0.1084.56 Safari/536.5' at localhost:59443
Can anyone offer any suggestions on what exactly Ive done wrong and how do I get this to work
GWT apps being browser apps do not have access to the local filesystem, that's why GWT doesn't emulate java.io.FileReader and related exceptions (most of java.io.*, for that matter). If the library insists on filesystem access it won't work with GWT.

GWT and getClass().getPackage()

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.