• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Strange issue with Tomcat / Springboot

 
Bartender
Posts: 1971
17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a REST service (Springboot) where a particular method works OK if the service is started standalone, but not when the service is started from the Windows (2019 Windows Server) Tomcat service in Windows services.

I have the memory set for 1024 MB initially and max memory of 4096, but I've tried max up to 12224 MB.

It may be that the code is taking more resources somehow than my AWS instance allows or something.

I'm using a t3a.xlarge instance.

No errors in any of the Tomcat logs or the application logs.

Would really appreciate some other things to try. I'm baffled.

Thanks,

-- mike
 
Saloon Keeper
Posts: 15510
363
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
ItDoesntWorkIsUseless. Please tell us what happened and what your expected to happen.

Maybe your endpoints are at a different URL than you expect them to be?
 
Marshal
Posts: 4499
572
VSCode Eclipse IDE TypeScript Redhat MicroProfile Quarkus Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Mike London wrote:No errors in any of the Tomcat logs or the application logs.


Is there any information in the logs? Is there any evidence that the requests are at least hitting Springboot/Tomcat?
 
Mike London
Bartender
Posts: 1971
17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
There is no information in the log that indicates anything is wrong.

The basic code runs some python code by doing a shell exec(). With smaller examples, it works fine.

This library has all the dependencies installed.

The method should return the output from the "Gensim" analysis, but it returns nothing on Windows under the Windows service. When I walk through the code in the debugger, connected to Tomcat, frustratingly, it works then. It also works when Tomcat is standalone.

Same code, same Tomcat version, same endpoints, work perfectly on the Mac (though that's standalone Tomcat).
Same code, same Tomcat version (running as service), same endpoints, work perfectly on Windows 10.

We've had trouble with Python Gensim models in the past. On PythonAnywhere, they would crash and they told us we would need a $149/month special server. We then setup a Linux AWS instance and used Flask (web service for python) and after bumping up the instance, it worked there, too.

Since I can't debug this code and get it to fail (it only fails with the service running normally), not sure what to try next.

Thanks,
 
Mike London
Bartender
Posts: 1971
17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The two lines in question are here:

process = Runtime.getRuntime().exec(cmdArray);
reader = new BufferedReader(new InputStreamReader(process.getInputStream()));

(On Windows Server 2019, Tomcat running as service "reader" is null. Works Otherwise -- on Mac and regular Windows 10.).

The "cmdArray" variable has three values:

1. "python" (for Windows)
2. The path to the python program to run.
3. The path to the data file to read.

Not sure this is a readily solvable problem.

Will try to have the client bump up the Windows server on AWS.

 
Ron McLeod
Marshal
Posts: 4499
572
VSCode Eclipse IDE TypeScript Redhat MicroProfile Quarkus Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Mike London wrote:
reader = new BufferedReader(new InputStreamReader(process.getInputStream()));

(On Windows Server 2019, Tomcat running as service "reader" is null. Works Otherwise -- on Mac and regular Windows 10.).


You should probably check the exit code.  If it was non-zero, you may want to be checking the ErrorStream rather than the InputStream.

Also, do you really need a reader? I normally just use something like this to get the returned information:
 
Ron McLeod
Marshal
Posts: 4499
572
VSCode Eclipse IDE TypeScript Redhat MicroProfile Quarkus Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm not sure if this helps at all, but I would typically do something like this to execute something in the OS environment:
 
Mike London
Bartender
Posts: 1971
17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks! Your suggestion about the errorstream (why do I keep forgetting this?!) was the key.

Some of the NLTK libraries were still not installed.

And, although the "stop words" were in the correct location this was still reported as an error until a reboot.

Thanks again for your splendid help!

-- mike
 
Sheriff
Posts: 22783
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If something works when starting it yourself but doesn't work when it's run as a service, then it's often rights (the service account doesn't have the same rights you do) or environment settings (the service account usually doesn't have the same path, etc.).
 
I've got no option but to sell you all for scientific experiments. Or a tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic