Servlet problem after upgrade

109 views
Skip to first unread message

dav...@googlemail.com

unread,
Nov 30, 2024, 11:27:59 AMNov 30
to GWT Users
hi
I'm trying to upgrade from 2.10.0 to 2.12.1.

My app runs in tomcat / java 21 with apache using it as a proxy. It's mostly client code except for a servlet whose sole function is to grab the remote ip and make it available to client code. With the 2.10.0 setup I had to run the server class through the jakartaee migration tool to make it work. With everything ok, if you browse to the servlet you get a 405 as the GET method is not supported,  although that confirms the servlet is running.

With unchanged code everything compiles with 2.12.1,  but the servlet will not run. I've tried both the standard compiled class and its byte enhanced version. Both give a 404 and the ip is not available to client code. The client code itself otherwise runs as expected.

Any pointers towards a fix?


Jens

unread,
Nov 30, 2024, 7:01:12 PMNov 30
to GWT Users
GWT doesn't really have any servlet magic so I doubt that the GWT upgrade has caused the issue. Are you double sure you haven't changed anything else except the GWT library? No Tomcat update? No Apache update? No update of Apache proxy rules? 

It sounds like your servlet is a GWT-RPC service because you used the Jakarta migration tool. If that is true you can now use gwt-servlet-jakarta.jar and skip the migration tool.

-- J.

SHAIK FAYAZ

unread,
Dec 2, 2024, 9:41:09 AMDec 2
to google-we...@googlegroups.com

1. Check How the Servlet is Set Up
Look at the file where your servlet is connected to a URL, like web.xml or in your annotations (comments in the code). Make sure the URL path for your servlet is correct, so it gets triggered when you visit the right link.
2. Ensure You Updated All Java Imports
When you updated from version 2.10.0 to 2.12.1, you need to check if your code is using the updated jakarta.* package instead of javax.*. Some of the old names have changed, so make sure everything is up to date.
3. Make Sure Your Tomcat Version Works with the New Code
If you're using an older version of Tomcat (like version 9 or below), it may not work with the updated jakarta.* code. Make sure you’re using Tomcat version 10 or higher, which supports this newer format.
4. Check if Your Servlet Supports GET or POST Methods
Earlier, you got a "405" error, which means the servlet was not set up to handle certain requests like GET. You need to make sure that your servlet is set up to handle the right type of requests.
5. Check Apache Proxy Settings
If you're using Apache to forward requests to Tomcat, make sure Apache is set up correctly so that it passes the requests properly. A wrong setting could cause the "404" error you're seeing now.
6. Look at Logs for Clues
Check both the Tomcat and Apache logs. They might give you more details about what’s going wrong and help identify the issue.
7. Issues with Code Enhancers
If you’re using tools that automatically modify your code (like Hibernate or other libraries), check to make sure they're compatible with the new version (2.12.1). These tools sometimes cause problems when you upgrade versions.


--
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-tool...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/google-web-toolkit/dda2b7e2-3565-4f79-ac99-b90f8cac9522n%40googlegroups.com.

SHAIK FAYAZ

unread,
Dec 2, 2024, 9:41:12 AMDec 2
to google-we...@googlegroups.com

Almost path problem it would be or check the path names correctly

dav...@googlemail.com

unread,
Dec 3, 2024, 7:04:49 AMDec 3
to GWT Users
Thanks Shaik & Jens for your replies, but I've still got the same problem. To recap the project includes a servlet (yes it is gwt-rpc) that simply grabs the remote IP and makes it available to client code. If I browse to the servlet, I should get a 405 signifying that the servlet is running but GET is not supported; but I still get a 404.

Prompted by your replies, I saw I had neglected  to update the ant build file with gwt-servlet-jakarta.jar instead of gwt-servlet.jar, but nothing else you suggested seems to apply. The web.xml and <project>.gwt.xml files are unchanged  and nothing else on the production server (apache, tomcat) has changed.

I again tried replacing the server class with a byte enhanced version as I need to do with 2.10.0,  but although it does add a few bytes, still  I get the 404. Nothing in either apache or tomcat logs apart from the 404s and 405s

Colin Alworth

unread,
Dec 3, 2024, 10:29:28 AMDec 3
to GWT Users
If you are using jakarta.servlet, you shouldn't need to do any bytecode fixing, provided you are depending on gwt-servlet-jakarta.jar and have changed your servlet implementation to extend from com.google.gwt.user.server.rpc.jakarta.RemoteServiceServlet.

If you aren't getting any error except 404, that suggests to me that the servlet isn't configured to be loaded at all - can you confirm that it is listed in the web.xml? If instead you are using annotations for discovery, confirm it is jakarta.servlet.annotation.WebServlet rather than javax, and consider adding some logging to verify that your servlet is having its constructor and init(config) method called at all. If not, something is probably misconfigured in how you are signaling to your servlet container how it should find and load the required servlets.

dav...@googlemail.com

unread,
Dec 6, 2024, 10:57:26 AMDec 6
to GWT Users
hi Colin

import com.google.gwt.user.server.rpc.jakarta.RemoteServiceServlet;
//import com.google.gwt.user.server.rpc.RemoteServiceServlet;

As above, I replaced the import statement as you suggest. Also I  referenced gwt-servlet-jakarta.jar instead of gwt-servlet.jar in my ant build file; gwt-servlet-deps.jar is also referenced and both do get copied to the WEB-INF/libs.

But now I get a compile error:
   [javac]   class file for jakarta.servlet.http.HttpServlet not found
    [javac] /home/david/projects/gwt-2.12.1/dmatthews.org/src/org/dmatthews/server/RemoteIPServiceImpl.java:7: error: cannot access ServletException
    [javac] public class RemoteIPServiceImpl extends RemoteServiceServlet implements RemoteIPService{

Other than that everything is as in the working 2.10 version. Incidently I get a 404 with that version also *if* the server class file hasn't been byte enhanced, so it's not a good indication that the servlet isn't referenced correctly.

On the development machine javac is v21, but since I've got source="1.8" target="1.8" nowarn="true" in the javac section of the build file, that's neither here nor there?

dav...@googlemail.com

unread,
Dec 6, 2024, 4:11:54 PMDec 6
to GWT Users
fixed

It's now just the old servlet thing of needing servlet jar to compile (but not run) the code. In the ant build file I just added a
<pathelement location to point to the jar in tomcat/lib and everything is fine. No magic byte enhancing needed.

Seems odd I never had to do this in version 2.10 in pre-jakarta days. Probably I shoud have rtfm :-)

Thanks for the pointers from thse who contributed to this thread.
Reply all
Reply to author
Forward
0 new messages