Lukas Dakado

+ Follow
since Feb 11, 2021
Cows and Likes
Total received
In last 30 days
Total given
Total received
Received in last 30 days
Total given
Given in last 30 days
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Lukas Dakado

Thank you, by using @Scheduled annotation above the method instead of java.util.Timer everything works as it should. Also needed to add @EnableScheduling to spring config class.
9 months ago


I have Spring core 5 application + hibernate core (5.4.9.Final), to access database I use single hibernate session factory initialized when spring loads and then I get SessionFactory instance by using spring's @Autowired in all my @org.springframework.stereotype.Repository classes.


When this code gets called by Spring Controller or REST controller, it works fine, but I need to check something periodically so I used java.util.Timer and java.util.TimerTask for that, however when this same code gets called from timer thread I get following error:

Why the session is closed when accesing it from Timer thread ? Spring already by default processes controller requests in many threads and there is not a problem with that.

Messy solution:
I have been able to supress this error by doing following, but this is really messy (+ not even using try-with-resources), however I have not been able to find any solution nor reason why calling this from a timer completely breaks SessionFactory.

The code above works only when call "s = sf.getCurrentSession();" is made first that always throws HibernateException and after that sf.openSession() works for some strange reason.

If I try to add finally block where I try to do s.close() it starts throwing the same error again. So the only messy solution is to never close the session apparently which is really bad.

9 months ago

Tim Holloway wrote:Looks like :mydomain" is actually "". It seems to have tried to deploy, but the webapp's web.xml version was 4.0 and you're running Tomcat 8. You need Tomcat 9 to run web 4.0.

These domains work fine, I am trying to add a different one same way but its not even in the log.

here is my entire server.yml config, the domain that does not load at all is

9 months ago

Tim Holloway wrote:Can you post a copy of the catalina.out log here? Also check the my.domain.log file.

Domain log is not even created, this is catalina.out:

9 months ago

Tim Holloway wrote:Welcome to the Ranch, Lukas!

If you expect to put webapps from the primary host in TOMCAT_HOME/webapps, but put webapps from a virtual host in TOMCAT_HOME/webapps/lab, then it doesn't work that way. The "webapps" directory has no magic powers. It's just a directory that the primary Tomcat host has been told to use. To deploy apps from the alternate virtual host, make a TOMCAT_HOME/lab diirectory and copy WARs into it the same way you'd copy WARs into TOMCAT_HOME/webapps.

I am sorry I probably described it badly.

My folder structure is as you described it:

TOMCAT_HOME/webapps <- in this folder there is no problem with deploymend
TOMCAT_HOME/lab <- .WAR inside this folder is never deployed
9 months ago

I have defined another host in my server.xml:

Then I have uploaded my .WAR file into the folder "lab" that is in the same folder as default "webapps". But even after restarting tomcat several times the WAR is never unpacked nor deployed.

Could anyone hint my what I am doing wrong ? Thanks.
9 months ago