Wednesday, December 18, 2024

Re: Digest for google-web-toolkit@googlegroups.com - 18 updates in 5 topics

I agree with Leon and I can only add that there is also libapache2-mod-jk to directly proxy from apache to tomcat. The elevator's pitch is about speed but I think that is also simpler to understand and setup.

On Thu, Dec 19, 2024 at 8:50 AM Leon <leon.pennings@gmail.com> wrote:
Hi Neil,

If you hardcode an url in your GWT calls, it will be tied to that specific url. Local testing will not be possible (outside of hacking your own hosts file) and if you modify your servername you'll need to update your source code.

The webserver is the perfect place to forward your request to the tomcat instance.
For apache webserver you can do this with the mod_proxy module. Nginx has the same with proxy_forward (or something similar, don't know by heart).

rg,

Leon.

On Wed, Dec 18, 2024 at 9:56 PM <google-web-toolkit@googlegroups.com> wrote:
Neil Aggarwal <neil@propfinancing.com>: Dec 17 05:43PM -0600

Now, when I call my service, I am getting this error:
500 500 The call failed on the server; see server log for details
 
Here is the code in my service:
public Puzzle getPuzzle(String category) {
try {
Puzzle puzzle =
(Puzzle)FileUtil.deSerialize(PathUtil.PUZZLES_DIR+"/DiagonalSlitherlink/Ch
allenging/DiagonalSlitherlink-00001-3.ser");
LogManager.getLogger(getClass()).warn("Loaded puzzle "+puzzle);
return puzzle;
} catch( Exception e ) {
LogManager.getLogger(getClass()).error(e);
return null;
}
}
 
My server log has this:
WARN: Loaded puzzle
com._3dmathpuzzles.slitherlink.RectangularWithDiagonalsPuzzle@3f8ef4a0
 
The only code after that line is the return.
 
Does GWT not like that I am returning a subclass which is referenced by a
superclass reference?
 
Thank you,
Neil
 
--
Neil Aggarwal, (972) 834-1565, http://www.propfinancing.com
We offer 30 year loans on single family houses!
Neil Aggarwal <neil@propfinancing.com>: Dec 17 10:48PM -0600

It does not seem related to the reference being a superclass.
 
I added a second servlet which uses a reference to
RectangularWithDiagonalsPuzzle
directly.
 
@WebServlet(urlPatterns="/DiagonalSlitherlink/GetDiagonalSlitherlink")
public class GetDiagonalSlitherlinkImpl extends RemoteServiceServlet
implements GetDiagonalSlitherlink {
private static final long serialVersionUID = 1L;
 
public RectangularWithDiagonalsPuzzle getPuzzle(String category) {
try {
RectangularWithDiagonalsPuzzle puzzle =
(RectangularWithDiagonalsPuzzle)FileUtil.deSerialize(PathUtil.PUZZLES_DIR+
"/DiagonalSlitherlink/Challenging/DiagonalSlitherlink-00001-3.ser");
LogManager.getLogger(getClass()).warn("In DiagonalSlitherlinkImpl,
Loaded puzzle "+puzzle);
return puzzle;
} catch( Exception e ) {
LogManager.getLogger(getClass()).error(e);
return null;
}
}
}
 
And I see this in the server log:
 
WARN: In DiagonalSlitherlinkImpl, Loaded puzzle
com._3dmathpuzzles.slitherlink.RectangularWithDiagonalsPuzzle@76c929a9
 
Thank you,
Neil
 
--
Neil Aggarwal, (972) 834-1565, http://www.propfinancing.com
We offer 30 year loans on single family houses!
 
> public Puzzle getPuzzle(String category) {
> try {
> Puzzle puzzle =
 
(Puzzle)FileUtil.deSerialize(PathUtil.PUZZLES_DIR+"/DiagonalSlitherlink/Ch
allengi
> com._3dmathpuzzles.slitherlink.RectangularWithDiagonalsPuzzle@3f8ef4a0
 
> The only code after that line is the return.
 
> Does GWT not like that I am returning a subclass which is referenced by
a
> Neil
 
> --
> Neil Aggarwal, (972) 834-1565, http://www.propfinancing.com We offer 30
year
Jens <jens.nehlmeier@gmail.com>: Dec 18 04:33AM -0800

What is the exception logged on the server that caused the HTTP 500 error?
 
Generally your classes and their field references must implement
Serializable, have a default constructor (can be private) and should not
have final fields. Is that the case for RectangularWithDiagonalsPuzzle and
its super classes?
 
-- J.
 
Neil Aggarwal schrieb am Mittwoch, 18. Dezember 2024 um 00:44:06 UTC+1:
 
Neil Aggarwal <neil@propfinancing.com>: Dec 18 10:19AM -0600

> What is the exception logged on the server that caused the HTTP 500 error?
 
 
 
That is the problem. I am not seeing any error on the server.
 
 
 
> should not have final fields
 
 
 
I did not realize this limitation. I am pretty sure there are some.
 
Looking at the docs, I will add transient to them.
 
 
 
Thank you,
 
Neil
 
 
 
--
 
Neil Aggarwal, (972) 834-1565, http://www.propfinancing.com
 
We offer 30 year loans on single family houses!
Colin Alworth <colin@colinalworth.com>: Dec 18 08:25AM -0800

If there was a serialization error, it would be written out using your
servlet container's own logging system - but your own service call could
have had an error too and be written via your
`LogManager.getLogger(getClass()).error(e); `. Can you confirm with your
debugger that the call is being made correctly, and serializing properly?
It might also make sense to deliberately throw an exception (both within
and outside of your try/catch) and see where that log ends up.
 
Note that final fields are supported in gwt-rpc, but you need to set
rpc.XserializeFinalFields to true in your .gwt.xml file:
<set-property name="rpc.XserializeFinalFields" value="true" />
 
On Wednesday, December 18, 2024 at 10:20:43 AM UTC-6
Neil Aggarwal <neil@propfinancing.com>: Dec 18 10:55AM -0600

Looking at the final comment in
 
https://github.com/gwtproject/gwt/issues/1062#issuecomment-210347324
 
 
 
It says GWT RPC is being deprecated.
 
 
 
Is that true?
 
 
 
Thank you,
 
Neil
 
 
 
--
 
Neil Aggarwal, (972) 834-1565, http://www.propfinancing.com
 
We offer 30 year loans on single family houses!
Colin Alworth <colin@colinalworth.com>: Dec 18 09:00AM -0800

That is a very old comment, by a former Googler who didn't follow through
on the various porting things that were proposed.
 
It also is incorrect, porting gwt-rpc to work with annotation processors is
finished with the "hard parts", and is has been deployed to production for
many years. It isn't perfect for all use cases, but the hard parts weren't
as big of a deal as they were suspected to be.
 
And, it was wrong as written - final support was added a year and a half
before it was written, see
https://github.com/gwtproject/gwt/commit/580db4248fc38f9721d0a920cabfc2b17e10d73f.
 
On Wednesday, December 18, 2024 at 10:55:58 AM UTC-6
Neil Aggarwal <neil@propfinancing.com>: Dec 18 11:04AM -0600

OK, that is good to know. It might be a good idea to add a follow-up
on that comment which clarifies that GWT RPC is not deprecated.
 
 
 
Thank you,
 
Neil
 
 
 
--
 
Neil Aggarwal, (972) 834-1565, http://www.propfinancing.com
 
We offer 30 year loans on single family houses!
Colin Alworth <colin@colinalworth.com>: Dec 18 09:05AM -0800

Forgot to link the updated project: https://github.com/Vertispan/gwt-rpc/
 
On Wednesday, December 18, 2024 at 11:00:25 AM UTC-6 Colin Alworth wrote:
 
Neil Aggarwal <neil@propfinancing.com>: Dec 18 11:54AM -0600

> If there was a serialization error, it would be written out using your
servlet container's own logging system
 
 
 
You are correct, it is a serialization error and it was in a different log.
 
 
 
Here is the error message:
 
 
 
Exception while dispatching incoming RPC call
 
com.google.gwt.user.client.rpc.SerializationException:
 
Type 'com._3dmathpuzzles.slitherlink.RectangularWithDiagonalsPuzzle' was
not assignable to
 
'com.google.gwt.user.client.rpc.IsSerializable' and did not have a custom
field serializer.
 
For security purposes, this type will not be serialized.:
 
instance =
com._3dmathpuzzles.slitherlink.RectangularWithDiagonalsPuzzle@703902c0
 
 
 
That is a bit cryptic and does not give details on which field was causing
the problem.
 
 
 
I am pretty sure I am not going to be the only person who is trying to learn
GWT and runs into it. Can we add a warning to the GWT compiler which alerts
the user that they have a final field which could cause a problem?
 
 
 
Thank you,
 
Neil
 
 
 
--
 
Neil Aggarwal, (972) 834-1565, http://www.propfinancing.com
 
We offer 30 year loans on single family houses!
Neil Aggarwal <neil@propfinancing.com>: Dec 18 12:34PM -0600

> Note that final fields are supported in gwt-rpc, but you need to set
rpc.XserializeFinalFields to true in your .gwt.xml file:
 
> <set-property name="rpc.XserializeFinalFields" value="true" />
 
 
 
I set that property, but I am still getting this serialization error:
 
 
 
Exception while dispatching incoming RPC call
 
com.google.gwt.user.client.rpc.SerializationException:
 
Type 'com._3dmathpuzzles.slitherlink.RectangularWithDiagonalsPuzzle' was
not assignable to
 
'com.google.gwt.user.client.rpc.IsSerializable' and did not have a custom
field serializer.
 
For security purposes, this type will not be serialized.:
 
instance =
com._3dmathpuzzles.slitherlink.RectangularWithDiagonalsPuzzle@23a80ce8
 
 
 
Is there a way to find out more specifically what GWT RPC does not like
about
my class?
 
 
 
Thank you,
 
Neil
 
 
 
--
 
Neil Aggarwal, (972) 834-1565, http://www.propfinancing.com
 
We offer 30 year loans on single family houses!
Vassilis Virvilis <vasvir2@gmail.com>: Dec 18 10:09AM +0200

I also would like to extend my thanks to current GWT maintainers.
 
Your work is greatly appreciated.
 
I am also glad to see this mailing list shows life signs again after a long
time of slow traffic.
 
Merry Christmas and a happy new year.
 
 
On Wed, Dec 11, 2024 at 10:07 PM Juan Pablo Gardella <
 
--
Vassilis Virvilis
Venky <venkata.sai.vishwanath@gmail.com>: Dec 18 12:03AM -0800

Thank you everyone for the help 😊
 
On Monday, December 16, 2024 at 11:27:42 PM UTC+5:30 Jens wrote:
 
Craig Mitchell <mail@craig-mitchell.com>: Dec 17 04:29PM -0800

In my car racing game, I do the logic on both client and server. The
player does the car race all in the browser, and at the end of the race,
their inputs are sent to the server via GWT RPC, that then also runs the
race logic, to make sure they didn't cheat.
 
GWT is fantastic for this. The same code runs in both the client and the
server. Although, I have to be careful not to use things like floats, as
they are floats in Java, but when compiled to JavaScript, they become
doubles.
 
It's https://drift.team/ if interested.
 
On Tuesday, 17 December 2024 at 1:26:23 am UTC+11 Tim Macpherson wrote:
 
Neil Aggarwal <neil@propfinancing.com>: Dec 17 09:54PM -0600

> In my car racing game,
 
 
 
Wow, that is a nice game. Very impressive!
 
 
 
Great idea to run it again on the server to prevent cheating.
 
 
 
So far, I am very impressed with GWT. It is so nice to be able
to write only Java code instead of having the learn the nuances
of JavaScript.
 
 
 
Thank you,
 
Neil
 
 
 
--
 
Neil Aggarwal, (972) 834-1565, http://www.propfinancing.com
 
We offer 30 year loans on single family houses!
Neil Aggarwal <neil@propfinancing.com>: Dec 17 03:38PM -0600

Hello all:
 
I am having a problem with an RPC call.
 
My server side is available and responds to requests. I put a doGet
method in the implementation class and you can see its response
at this url:
https://dev.3dmathpuzzles.com/3dmp/DiagonalSlitherlink/GetPuzzle
 
When I load my client code:
https://dev.3dmathpuzzles.com/3dmp/diagonalSlitherlink.html
The RPC call fails with a 404 error.
 
I think the RPC call is using a different URL than what my server is
expecting.
 
I called GWT.getModuleBaseURL() and it gave me
https://dev.3dmathpuzzles.com/play/DiagonalSlitherlink/
 
So I think it might be trying to access the RPC at
https://dev.3dmathpuzzles.com/play/DiagonalSlitherlink/GetPuzzle
 
That is not going to work since that request will only go to Apache
and not make it to Tomcat.
 
Is there a way to force the base URL for the RPC call?
 
Thank you,
Neil
 
--
Neil Aggarwal, (972) 834-1565, http://www.propfinancing.com
We offer 30 year loans on single family houses!
Colin Alworth <colin@colinalworth.com>: Dec 17 01:49PM -0800

You can cast your async service instance in client code to
ServiceDefTarget, then invoke setServiceEntryPoint(...) on it with the
desired URL.
 
https://www.gwtproject.org/javadoc/latest/com/google/gwt/user/client/rpc/ServiceDefTarget.html
 
On Tuesday, December 17, 2024 at 3:39:07 PM UTC-6 ne...@propfinancing.com
wrote:
 
Neil Aggarwal <neil@propfinancing.com>: Dec 17 05:36PM -0600

> You can cast your async service instance in client code to
ServiceDefTarget, then invoke setServiceEntryPoint(...) on it with the
desired URL.
 
 
 
That worked, now my servlet is getting called and I can see entries in the
tomcat log.
 
 
 
Thank you!
 
 
 
Neil
 
 
 
--
 
Neil Aggarwal, (972) 834-1565, http://www.propfinancing.com
 
We offer 30 year loans on single family houses!
You received this digest because you're subscribed to updates for this group. You can change your settings on the group membership page.
To unsubscribe from this group and stop receiving emails from it send an email to google-web-toolkit+unsubscribe@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "GWT Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/google-web-toolkit/CABjQu7RymD-YNDY28hNLMp4zUfo8jZpV717SGjPyD%2B3gT144Nw%40mail.gmail.com.


--
Vassilis Virvilis

--
You received this message because you are subscribed to the Google Groups "GWT Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/google-web-toolkit/CAKbOjEwz5ot4JCuf28bPwYXgg1ATcJEy9wKaLZNfowNLYtqRMw%40mail.gmail.com.

No comments:

Post a Comment