How to inherit java.sql.Connection in GWT? - gwt

[ERROR] Line 29: No source code is available for type
java.sql.Connection; did you forget to inherit a required module?
[ERROR] Line 35: No source code is available for type java.sql.Statement; did you forget to inherit a required module?
[ERROR] Line 45: No source code is available for type java.sql.ResultSet; did you forget to inherit a required module?
[ERROR] Line 52: No source code is available for type java.text.SimpleDateFormat; did you forget to inherit a required
module?
[ERROR] Line 68: No source code is available for type java.util.GregorianCalendar; did you forget to inherit a required
module?
[ERROR] Line 90: No source code is available for type java.sql.SQLException; did you forget to inherit a required module?

You can't just put any code in GWT client side. GWT Java code is compiled into Javascript and deployed on your browser, so only a subset (*) of Java is supported, and java.SQL is not part of it. Besides SQL connections are something you don't want to put client side. Maybe you can use a native Javascript framework to accomplish this (but likely you still don't want it ;-)

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

socket.io source code for GWT

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.

Error while compling GWT (Sencha Framework) Project

I am developing a simple web application. I am using sencha(gxt) framework to display chart to user.
When I am compiling the project, I am getting following errors.
[ERROR] Errors in 'file:/E:/eclipse%20Workspace/Chart_Demo/src/com/project/client/Chart_Demo.java'
[ERROR] Line 74: No source code is available for type com.sencha.gxt.chart.client.chart.Chart<M>; did you forget to inherit a required module?
[ERROR] Line 78: No source code is available for type com.sencha.gxt.chart.client.draw.Gradient; did you forget to inherit a required module?
[ERROR] Line 79: No source code is available for type com.sencha.gxt.chart.client.draw.RGB; did you forget to inherit a required module?
[ERROR] Line 84: No source code is available for type com.sencha.gxt.chart.client.chart.axis.CategoryAxis<M,V>; did you forget to inherit a required module?
[ERROR] Line 85: No source code is available for type com.sencha.gxt.chart.client.chart.Chart<M>.Position; did you forget to inherit a required module?
[ERROR] Line 87: No source code is available for type com.sencha.gxt.chart.client.draw.sprite.TextSprite; did you forget to inherit a required module?
[ERROR] Line 102: No source code is available for type com.sencha.gxt.chart.client.chart.series.BarSeries<M>; did you forget to inherit a required module?
[ERROR] Unable to find type 'com.project.client.Chart_Demo'
[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
Exception in thread "pool-1-thread-1" java.lang.RuntimeException: Unable to read from byte cache
Please help me to resolve this issue.
wilome is right. The <inherits>-tags in the module descriptor are missing.
But it looks like Ranjeet is using GXT 3.
In this case it schould be:
<inherits name='com.sencha.gxt.ui.GXT'/>
<inherits name='com.sencha.gxt.chart.Chart' />
You need to inherit the GXT modules in your main module (yourapp.gwt.xml)
<inherits name="com.extjs.gxt.ui.GXT" />
<inherits name="com.extjs.gxt.themes.Themes" />
<inherits name="com.extjs.gxt.charts.Chart" />

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)

GWT - XML parser

I am trying to use GWT xml parser but the compiler throws next
[ERROR] Line 62: No source code is available for type
com.google.gwt.xml.client.Document; did you forget to inherit a
required module?
[ERROR] Line 62: No source code is available for type com.google.gwt.xml.client.XMLParser; did you forget to inherit a
required module?
[ERROR] Line 63: No source code is available for type com.google.gwt.xml.client.Element; did you forget to inherit a
required module?
[ERROR] Line 65: No source code is available for type com.google.gwt.xml.client.NodeList; did you forget to inherit a
required module?
[ERROR] Line 69: No source code is available for type com.google.gwt.xml.client.Node; did you forget to inherit a required
module?
I don't get it how to solve the problem because import code gives no errors :( Help
It seems I was to add to my gwt.xml code like a
<inherits name="com.google.gwt.xml.XML"/>
then code compiled :)
I hope this saves one's day