Re: tomcats starting with 200 threads
hi Christopher, Configuration follows: On Mon, Sep 19, 2022 at 7:45 PM Christopher Schultz < ch...@christopherschultz.net> wrote: > Jon, > > On 9/19/22 10:46, Jonathan Yom-Tov wrote: > > Sometimes one of our production Tomcats will start with the maximum (200) > > number of threads in the https pool. That is, it doesn't start with some > > minimum and works its way up to the maximum, it immediately starts with > the > > maximum. There's no reason for it since most of the threads stay idle > > through the lifetime of the Tomcat. The issue is that this takes up > memory > > and eventually something pushes the Tomcat over the edge and it dies with > > an out of memory error. Any ideas on how to debug or solve this? > > > > The Tomcat version is 9.0.64.0, running on Amazon Linux 2 (amd64) and > Java > > Corretto 1.8.0_312-b07. > > Can you post your configuration? > > -chris > > - > To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org > For additional commands, e-mail: users-h...@tomcat.apache.org > >
tomcats starting with 200 threads
hi, Sometimes one of our production Tomcats will start with the maximum (200) number of threads in the https pool. That is, it doesn't start with some minimum and works its way up to the maximum, it immediately starts with the maximum. There's no reason for it since most of the threads stay idle through the lifetime of the Tomcat. The issue is that this takes up memory and eventually something pushes the Tomcat over the edge and it dies with an out of memory error. Any ideas on how to debug or solve this? The Tomcat version is 9.0.64.0, running on Amazon Linux 2 (amd64) and Java Corretto 1.8.0_312-b07. Thanks, Jon.
Re: thread pool count never goes down
Got it, thanks. Happy holidays ! On Thu, 23 Dec 2021, 17:02 Christopher Schultz, < ch...@christopherschultz.net> wrote: > Jon, > > On 12/21/21 04:55, Jonathan Yom-Tov wrote: > > When I look at the source (and docs) I can see that the > > StandardThreadExecutor, which is the default, has a max idle time of 60 > > seconds, after which the threads should be reaped. I can see in our > > monitoring that for most Tomcats the thread count for the TLS connector > > pool does decrease sometimes. So I wonder what could be causing the > > executor to decide not to decrease the count in this specific instance? > > Oh, perhaps that has changed over the years. I'm sorry if I was wrong. > > Using a manually-configured executor should, of course, give you better > control over everything as the attributes don't fully-cover > what you can configure for an explicitly-configured executor. > > Thanks, > -chris > > > On Mon, Dec 20, 2021 at 9:47 PM Christopher Schultz < > > ch...@christopherschultz.net> wrote: > > > >> Jon, > >> > >> On 12/19/21 12:19, Jonathan Yom-Tov wrote: > >>> hi Chris, > >>> > >>> Sorry for the late reply, I didn't see your reply for some reason. > Here's > >>> the relevant connector configuration: > >>> > >>> >>> connectionTimeout="2" redirectPort="8443" maxHttpHeaderSize="8192" > >>> scheme="https" secure="true" proxyPort="443" relaxedQueryChars=" { } > >>> " /> > >>> >>> relaxedQueryChars=" { } " > >>> connectionTimeout="2" > >>> > >>> redirectPort="8443" maxHttpHeaderSize="8192" /> > >> > >> You are allowing Tomcat to automatically-configure an "Executor" for > >> you, and that executor will never shed threads. > >> > >> You need to change your configuration so that you have this: > >> > >> > >> > >> >> ... > >> /> > >> > >> >> executor="name-of-executor" > >> ... /> > >> > >> >> executor="name-of-executor" > >> ... /> > >> > >> You can read more about the configuration of executors here: > >> https://tomcat.apache.org/tomcat-9.0-doc/config/executor.html > >> > >> Note that your current configuration has separate thread-pools, one for > >> each . If you specify the "executor" configuration attribute, > >> you can choose to share a single or have separate ones for > >> each . If you want them separate, just define two of them and > >> reference them appropriately. > >> > >> Hope that helps, > >> -chris > >> > >>> On Tue, Dec 7, 2021 at 10:28 PM Christopher Schultz < > >>> ch...@christopherschultz.net> wrote: > >>> > >>>> Jon, > >>>> > >>>> On 12/6/21 10:28, Jonathan Yom-Tov wrote: > >>>>> I have a single instance of Tomcat (version 9.0.54) in which the > thread > >>>>> count on a connector thread pool doesn't reduce despite most of the > >>>> threads > >>>>> (198/200) being idle. If I understand correctly the default idle time > >>>>> before a thread is reaped is 60 seconds, but this situation persists > >> for > >>>>> hours. Any ideas for why this could happen? > >>>> > >>>> Maybe. Can you post your configuration? > >>>> > >>>> -chris > >>>> > >>>> - > >>>> To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org > >>>> For additional commands, e-mail: users-h...@tomcat.apache.org > >>>> > >>>> > >>> > >> > >> - > >> To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org > >> For additional commands, e-mail: users-h...@tomcat.apache.org > >> > >> > > > > - > To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org > For additional commands, e-mail: users-h...@tomcat.apache.org > >
Re: thread pool count never goes down
hi Chris, Thanks for your reply. When I look at the source (and docs) I can see that the StandardThreadExecutor, which is the default, has a max idle time of 60 seconds, after which the threads should be reaped. I can see in our monitoring that for most Tomcats the thread count for the TLS connector pool does decrease sometimes. So I wonder what could be causing the executor to decide not to decrease the count in this specific instance? On Mon, Dec 20, 2021 at 9:47 PM Christopher Schultz < ch...@christopherschultz.net> wrote: > Jon, > > On 12/19/21 12:19, Jonathan Yom-Tov wrote: > > hi Chris, > > > > Sorry for the late reply, I didn't see your reply for some reason. Here's > > the relevant connector configuration: > > > >> connectionTimeout="2" redirectPort="8443" maxHttpHeaderSize="8192" > > scheme="https" secure="true" proxyPort="443" relaxedQueryChars=" { } > > " /> > > > relaxedQueryChars=" { } " > > connectionTimeout="2" > > > > redirectPort="8443" maxHttpHeaderSize="8192" /> > > You are allowing Tomcat to automatically-configure an "Executor" for > you, and that executor will never shed threads. > > You need to change your configuration so that you have this: > > > > ... > /> > > executor="name-of-executor" > ... /> > > executor="name-of-executor" > ... /> > > You can read more about the configuration of executors here: > https://tomcat.apache.org/tomcat-9.0-doc/config/executor.html > > Note that your current configuration has separate thread-pools, one for > each . If you specify the "executor" configuration attribute, > you can choose to share a single or have separate ones for > each . If you want them separate, just define two of them and > reference them appropriately. > > Hope that helps, > -chris > > > On Tue, Dec 7, 2021 at 10:28 PM Christopher Schultz < > > ch...@christopherschultz.net> wrote: > > > >> Jon, > >> > >> On 12/6/21 10:28, Jonathan Yom-Tov wrote: > >>> I have a single instance of Tomcat (version 9.0.54) in which the thread > >>> count on a connector thread pool doesn't reduce despite most of the > >> threads > >>> (198/200) being idle. If I understand correctly the default idle time > >>> before a thread is reaped is 60 seconds, but this situation persists > for > >>> hours. Any ideas for why this could happen? > >> > >> Maybe. Can you post your configuration? > >> > >> -chris > >> > >> --------- > >> To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org > >> For additional commands, e-mail: users-h...@tomcat.apache.org > >> > >> > > > > - > To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org > For additional commands, e-mail: users-h...@tomcat.apache.org > > -- [image: -] <http://www.sysaid.com/?utm_source=signature_medium=email_campaign=sysaid-logo> [image: -] Jonathan Yom-Tov Senior Architect jonathan.yom...@sysaid.com Phone (IL): +972 (3) 533-3675 Ext. 932 Mobile (IL): +972549174862 [image: -] <https://www.facebook.com/SysAidIT> [image: -] <https://twitter.com/sysaid> [image: -] <https://www.linkedin.com/company/sysaid-technologies-ltd> [image: -] <https://www.youtube.com/user/SysAidIT> [image: -] <https://www.instagram.com/sysaid_technologies/> [image: Banner] <https://www.sysaid.com/sig-link>
Re: thread pool count never goes down
hi Chris, Sorry for the late reply, I didn't see your reply for some reason. Here's the relevant connector configuration: On Tue, Dec 7, 2021 at 10:28 PM Christopher Schultz < ch...@christopherschultz.net> wrote: > Jon, > > On 12/6/21 10:28, Jonathan Yom-Tov wrote: > > I have a single instance of Tomcat (version 9.0.54) in which the thread > > count on a connector thread pool doesn't reduce despite most of the > threads > > (198/200) being idle. If I understand correctly the default idle time > > before a thread is reaped is 60 seconds, but this situation persists for > > hours. Any ideas for why this could happen? > > Maybe. Can you post your configuration? > > -chris > > - > To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org > For additional commands, e-mail: users-h...@tomcat.apache.org > > -- [image: -] <http://www.sysaid.com/?utm_source=signature_medium=email_campaign=sysaid-logo> [image: -] Jonathan Yom-Tov Senior Architect jonathan.yom...@sysaid.com Phone (IL): +972 (3) 533-3675 Ext. 932 Mobile (IL): +972549174862 [image: -] <https://www.facebook.com/SysAidIT> [image: -] <https://twitter.com/sysaid> [image: -] <https://www.linkedin.com/company/sysaid-technologies-ltd> [image: -] <https://www.youtube.com/user/SysAidIT> [image: -] <https://www.instagram.com/sysaid_technologies/> [image: Banner] <https://www.sysaid.com/sig-link>
thread pool count never goes down
hi, I have a single instance of Tomcat (version 9.0.54) in which the thread count on a connector thread pool doesn't reduce despite most of the threads (198/200) being idle. If I understand correctly the default idle time before a thread is reaped is 60 seconds, but this situation persists for hours. Any ideas for why this could happen?
Re: Implementing Store and getting java.io.StreamCorruptedException
For posterity's sake: the issue was that I hadn't noticed that StoreBase has the method getObjectInputStream which should be used instead of new ObjectInputStream. So while the session was serialized correctly using StandardSession's mechanism, it didn't deserialize correctly. On Fri, May 22, 2020 at 6:02 PM Christopher Schultz < ch...@christopherschultz.net> wrote: > -BEGIN PGP SIGNED MESSAGE- > Hash: SHA256 > > Jonathan, > > On 5/20/20 10:55, Jonathan Yom-Tov wrote: > > I implemented my own Store which uses Redis to persist sessions > > (I'm using Jedis as the interface library). I copied most of the > > load()/save() code from FileStore. When my Store loads the session > > from Redis I consistently get java.io.StreamCorruptedException: > > Inconsistent vector internals. Any ideas on why this might be > > happening? > > Does everything work if you don't have a java.util.Vector in your sessio > n? > > Possibly relevant: https://bugs.openjdk.java.net/browse/JDK-8216331 > > - -chris > > > > > Here's the relevant code: @Override public Session load(String > > sessionId) throws ClassNotFoundException, IOException { > > System.out.println("JEDIS load " + sessionId); String key = > > getKey(sessionId); byte[] bytes = jedis.get(key.getBytes(UTF8)); > > System.out.println("JEDIS loaded " + bytes.length + " bytes"); > > > > ClassLoader oldThreadContextCL = > > manager.getContext().bind(Globals.IS_SECURITY_ENABLED, null); try > > (ByteArrayInputStream bis = new ByteArrayInputStream(bytes); > > ObjectInputStream ois = new ObjectInputStream(bis)) { > > StandardSession session = (StandardSession) > > manager.createEmptySession(); session.readObjectData(ois); > > session.setManager(manager); > > > > return session; } catch (Exception e) { > > System.err.println(e.getMessage()); e.printStackTrace(); return > > null; } finally { > > manager.getContext().unbind(Globals.IS_SECURITY_ENABLED, > > oldThreadContextCL); } } > > > > @Override public void save(Session session) throws IOException { > > System.out.println("JEDIS save " + session.getId()); String key = > > getKey(session.getId()); try (ByteArrayOutputStream bos = new > > ByteArrayOutputStream(); ObjectOutputStream oos = new > > ObjectOutputStream(bos)) { > > ((StandardSession)session).writeObjectData(oos); > > jedis.set(key.getBytes(UTF8), bos.toByteArray()); } } > > > -BEGIN PGP SIGNATURE- > Comment: Using GnuPG with Thunderbird - https://www.enigmail.net/ > > iQIzBAEBCAAdFiEEMmKgYcQvxMe7tcJcHPApP6U8pFgFAl7H6Y0ACgkQHPApP6U8 > pFinPxAAitgiD5+T/KfdmKdRuwgUjT+mZi94HaajY9gRmkcFYSvTp3Dp7f1fJIfz > nPb/TlzfzCnhqeJLMNcTGB5AH7UG/SrQRftBdb/sTcxW3M4+WNklhfwAw3OrjnQG > GbHVF8O38T6dfHhc7WonXY90Cs1qZ0c1jtsQUStPZHdvD7cee3vO69RYyxH8AB1D > dc6m5Yp15MdK3l18iCawotvNXqtSHEiWQtArKRh/xWtv/O+0H5EqanzWgKdc0tWf > e2UqDL7w+pMuD9gTP5yYtSfaYjXyJoT3Yf9yqfGlaKizvsceTFImU1e4/cj9x1fK > 9sds6G0SPRVBcdT2yhzN/qLeXWlcpDh8+TImqtVL1lEJzVXQgol5aWzDJivyLv62 > t5Xp+RB9YdA9cbY2OP5lDQI5sD6p7FP1TeZMdsd49ns4TkkTQBffTmX4jwlP0Mrh > zJPJg88u1lGsmJ/TRxLPHMgyEDU2VSduYMzcFYiLcYweYfYxlyFhIcZvGxj1+knq > dEe3CfYKG1IHBvhcR5maXV7cjUr5bf5dLOWbme+XT+Qd9i2Lnd1p9aVm/lGDieOi > C3L67vS+vQ7s1cly96vMMtDjnuPHyKsmBpyMMjGJV3WsYl5nuPxKzyywbKjWHa2l > m7ouCRI39pf3zUYbbWs52qEGg2uDjax+BDnvAkj6V+HI7mLdqsQ= > =p/9Q > -END PGP SIGNATURE- > > - > To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org > For additional commands, e-mail: users-h...@tomcat.apache.org > > -- [image: SysAid Technologies] <http://www.sysaid.com/?utm_source=signature_medium=email_campaign=sysaid-logo> Jonathan Yom-Tov Senior Architect jonathan.yom...@sysaid.com Phone (IL): +972 (3) 533-3675 Ext. 932 [image: SysAid Technologies] <https://www.sysaid.com/?utm_source=signature_medium=email_campaign=sysaid-logo-icon> [image: SysAid on Facebook] <https://www.facebook.com/SysAidIT> [image: SysAid on Twitter] <https://twitter.com/sysaid> [image: SysAid on Linked-in] <https://www.linkedin.com/company/sysaid-technologies-ltd> [image: SysAid on YouTube] <https://www.youtube.com/user/SysAidIT> [image: SysAid on Instagram] <https://www.instagram.com/sysaid_technologies/> [image: Banner] <https://www.sysaid.com/sig-link>
Implementing Store and getting java.io.StreamCorruptedException
I implemented my own Store which uses Redis to persist sessions (I'm using Jedis as the interface library). I copied most of the load()/save() code from FileStore. When my Store loads the session from Redis I consistently get java.io.StreamCorruptedException: Inconsistent vector internals. Any ideas on why this might be happening? Here's the relevant code: @Override public Session load(String sessionId) throws ClassNotFoundException, IOException { System.out.println("JEDIS load " + sessionId); String key = getKey(sessionId); byte[] bytes = jedis.get(key.getBytes(UTF8)); System.out.println("JEDIS loaded " + bytes.length + " bytes"); ClassLoader oldThreadContextCL = manager.getContext().bind(Globals.IS_SECURITY_ENABLED, null); try (ByteArrayInputStream bis = new ByteArrayInputStream(bytes); ObjectInputStream ois = new ObjectInputStream(bis)) { StandardSession session = (StandardSession) manager.createEmptySession(); session.readObjectData(ois); session.setManager(manager); return session; } catch (Exception e) { System.err.println(e.getMessage()); e.printStackTrace(); return null; } finally { manager.getContext().unbind(Globals.IS_SECURITY_ENABLED, oldThreadContextCL); } } @Override public void save(Session session) throws IOException { System.out.println("JEDIS save " + session.getId()); String key = getKey(session.getId()); try (ByteArrayOutputStream bos = new ByteArrayOutputStream(); ObjectOutputStream oos = new ObjectOutputStream(bos)) { ((StandardSession)session).writeObjectData(oos); jedis.set(key.getBytes(UTF8), bos.toByteArray()); } }
Re: persistentmanager loads only part of session?
I don't think that can happen. I'm using sticky session so the first server gets all requests, then I kill it and only then are requests routed to the second server. On Mon, 18 May 2020, 21:15 Christopher Schultz, < ch...@christopherschultz.net> wrote: > -BEGIN PGP SIGNED MESSAGE- > Hash: SHA256 > > Jonathan, > > On 5/18/20 12:52, Jonathan Yom-Tov wrote: > > I see the persisted copy in the file and it has two keys, so I > > don't think that's it. It's probably some sort of parallelism issue > > since it happens only occasionally, but the map is a > > ConcurrentHashMap, so I can't see how it would be overwritten. > > What happens if both servers write the file at the same time? > > - -chris > > > On Mon, 18 May 2020, 19:47 Mark Thomas, wrote: > > > >> On 18/05/2020 15:23, Jonathan Yom-Tov wrote: > >>> Here's my setup: I have two Tomcats using PersistentManager > >>> with > >> FileStore > >>> to store sessions on a NFS they both have access to. Inside the > >>> session there's an object which contains a map. I also have a > >>> request listener > >> that > >>> logs the contents of the map on every request. > >>> > >>> I kill one Tomcat and I can see in the session file that the > >>> map contains two keys. I then make a request to the remaining > >>> Tomcat and I can see the map contains only one key. > >>> > >>> The only way I can think of that that would happen is if the > >>> map was only partially loaded from the file. Is that even > >>> possible? Any good ideas on how to debug this? > >> > >> Best guess you add the Map containing one key to the session and > >> then later add a second key the Map. Tomcat doesn't consider the > >> session to be updated when the second key is added so the > >> persisted copy doesn't get updated. > >> > >> Mark > >> > >> > >> - > >> > >> > To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org > >> For additional commands, e-mail: users-h...@tomcat.apache.org > >> > >> > > > -BEGIN PGP SIGNATURE- > Comment: Using GnuPG with Thunderbird - https://www.enigmail.net/ > > iQIzBAEBCAAdFiEEMmKgYcQvxMe7tcJcHPApP6U8pFgFAl7C0MgACgkQHPApP6U8 > pFh8MQ/7BXrjQ9dpvDIbXBaWXXF+1jAXHccOCn471SjN4rqkn5zuyQcPASEI0Gxs > bgfVnKRJu6ZCc5yQhkISLB4l2aE7/+duL8SRFygcaZRrVeBtRi+LSOyQQRAYqGyJ > PbVgO0eAp823+ii93tkWgUxpRgKERmlyM+6M5R22OKHW5Erck+DLLK1xeEn8HYOU > DvNMxS2/eawoxl811JwGfhUX/01tazV9kjeaRmVucUuqZWYQfX3qmCTAHyBDrT5b > hu76BkZQ5/aB+sZUClZu0/PuGQ3Q8vNJjDh+FlYjpuxzm7wotJxCp682+RgkfriK > bLE9a2Fn7Lzr2OZt2ZmPXnvMO0/Ai9Pb4Z+fMF/vWkMs6ZtH5RwxYiLfl/uzQrFj > oH9+bNj/WXOSOLLOOFE16UZc7P59G5NvI1iEpRtzOJOSZRVDchq9nff6sSfEhK1z > 9cOSVuBpvRSyKAhAC62G5q0eSHQ9GEJGwBREqkFAift0qn8MtjRe+XzPR9CBwcZ2 > HPwFTZ+Bs5ohqpCXijc9nwg0UwiAFefUdPEpVJHDJoRsv4IC06fagdAZaqAWeaEu > LiY0lPWFj+7YnQ4oV9mfho19B8y1hwA6eGKaU3BSHfyc67knqZFtZYyfFVITXHh1 > E/SuOlXM3gci3vbhpHV6JqDeItmkB810Dx4McbsRUNFqu9982pc= > =Y5dx > -END PGP SIGNATURE- > > - > To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org > For additional commands, e-mail: users-h...@tomcat.apache.org > >
Re: persistentmanager loads only part of session?
I see the persisted copy in the file and it has two keys, so I don't think that's it. It's probably some sort of parallelism issue since it happens only occasionally, but the map is a ConcurrentHashMap, so I can't see how it would be overwritten. On Mon, 18 May 2020, 19:47 Mark Thomas, wrote: > On 18/05/2020 15:23, Jonathan Yom-Tov wrote: > > Here's my setup: I have two Tomcats using PersistentManager with > FileStore > > to store sessions on a NFS they both have access to. Inside the session > > there's an object which contains a map. I also have a request listener > that > > logs the contents of the map on every request. > > > > I kill one Tomcat and I can see in the session file that the map contains > > two keys. I then make a request to the remaining Tomcat and I can see the > > map contains only one key. > > > > The only way I can think of that that would happen is if the map was only > > partially loaded from the file. Is that even possible? Any good ideas on > > how to debug this? > > Best guess you add the Map containing one key to the session and then > later add a second key the Map. Tomcat doesn't consider the session to > be updated when the second key is added so the persisted copy doesn't > get updated. > > Mark > > > - > To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org > For additional commands, e-mail: users-h...@tomcat.apache.org > >
persistentmanager loads only part of session?
Here's my setup: I have two Tomcats using PersistentManager with FileStore to store sessions on a NFS they both have access to. Inside the session there's an object which contains a map. I also have a request listener that logs the contents of the map on every request. I kill one Tomcat and I can see in the session file that the map contains two keys. I then make a request to the remaining Tomcat and I can see the map contains only one key. The only way I can think of that that would happen is if the map was only partially loaded from the file. Is that even possible? Any good ideas on how to debug this?
Re: ClassNotFoundException when loading session from disk
Regarding the deployment location, you're right, it's unusual, but it's a legacy application. I found out the reason for the class not being visible. There was a Context element with docBase defined in server.xml which I hadn't noticed. Nesting the Manager element inside that (rather than in context.xml) solved the issue. On Tue, May 12, 2020 at 9:45 PM Mark Thomas wrote: > On 12/05/2020 18:38, Jonathan Yom-Tov wrote: > > I'm trying to use PersistentManager with FileStore to load sessions from > > disk. Serialization goes ok but when the session is loaded I get an > > exception deserializing one of my application's classes. > > > > [2020-05-12 09:08:52] [SEVERE] Session: > > 6325A48BA1D2FC79105C7F4B0A76CB74.worker1; > > java.lang.ClassNotFoundException: com.mycompany.MyClass > > at > > > org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1365) > > at > > > org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1188) > > at java.lang.Class.forName0(Native Method) > > at java.lang.Class.forName(Class.java:348) > > at > > > org.apache.catalina.util.CustomObjectInputStream.resolveClass(CustomObjectInputStream.java:159) > > at > > java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1620) > > at > > java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1521) > > at > > java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1781) > > at > > java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1353) > > at > java.io.ObjectInputStream.readObject(ObjectInputStream.java:373) > > at > > > org.apache.catalina.session.StandardSession.doReadObject(StandardSession.java:1576) > > at > > > org.apache.catalina.session.StandardSession.readObjectData(StandardSession.java:1048) > > at org.apache.catalina.session.FileStore.load(FileStore.java:234) > > > > Looking into the classpath when the exception occurs I see that every jar > > in ${catalina.base}/lib is loaded plus those explicitly mentioned in the > > run command, but none of my application's jars. > > That is as expected. You want to look at the WebappClassLoader instance. > Is that pointing to the right web application? If not, why not? Pay > particular attention to the state field. > > > My application is deployed > > in ${catalina.base}/myapp/. I tried to add a ${catalina.base}/myapp/ > > META-INF/context.xml file, but that wasn't loaded. > > That is an odd location. Why not in webapps? > > > Then I tried to add > > > > > > > className="org.apache.catalina.webresources.JarResourceSet" > > base="${catalina.base}/mycompany/WEB-INF/lib/my.jar" webAppMount="/" /> > > > > That should never be necessary. > > > to context.xml but that didn't help either. It makes sense that Tomcat is > > separating my application from the rest of the classpath but then how do > I > > include the required class? > > If the correct web application class loader is picked up, is should just > work. > > Mark > > > - > To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org > For additional commands, e-mail: users-h...@tomcat.apache.org > >
Re: seamless restart
Thanks Mark. I've tried to use Redisson, it would've been the perfect solution for this except for the fact that my session object is a deep tree which is mutated in many areas of the code. So what happens is that as one request is changing the session state another will persist its session to Redis and overwrite the session of the first request. I can't think of an easy way to get around this. On Tue, May 12, 2020 at 8:39 PM Mark Eggers wrote: > Jonathan, > > On 5/12/2020 8:20 AM, Jonathan Yom-Tov wrote: > > The problem is that my application is running on AWS which apparently > > doesn't support multicasting so I can't use Tomcat's DeltaManager. I > > thought of using one of the Store implementations for > PersistentManager but > > that has the issues which I mentioned earlier. My aim is to get to the > > point where I can add or take away servers from the cluster without > > impacting user experience. Ideally all state would be stored in a central > > location (e.g. Redis). But, since this is difficult because of the way > the > > application is built I thought of using one server and only persisting > the > > sessions when the server goes down. But I still have to solve the issues > I > > mentioned. > > > > > > > > > > On Tue, May 12, 2020 at 6:06 PM Christopher Schultz < > > ch...@christopherschultz.net> wrote: > > > > Jonathan, > > > > On 5/12/20 05:51, Jonathan Yom-Tov wrote: > >>>> I have an application which changes the state of user sessions in > >>>> lots of places in the code. Is it possible to do a seamless switch > >>>> of Tomcat servers, preserving all sessions? > >>>> > >>>> I know I can use PersistentManager to persist sessions and load > >>>> them. I can think of two strategies: > >>>> > >>>> 1. Persist sessions periodically. This is more robust as I might > >>>> not have control of when the server shuts down. 2. Persist sessions > >>>> on server shutdown. > >>>> > >>>> > >>>> The problem with the first approach is that I might lose the latest > >>>> changes when the new server comes up. The problem with the second > >>>> is that I'll have to lock access to the session until the old > >>>> server is done saving it, which may make response times very slow. > >>>> > >>>> Is there a good solution to this that I might have overlooked? > > > > If you want to solve these problems: > > > > 1. Seamless (uninterrupted) restarts > > 2. Always up-to-date (well, as much as possible) > > 3. No downtime > > > > Then you really need a cluster where the sessions are being replicated > > around the cluster. > > > > This will solve some other problems as well: > > > > 4. Expected downtime (e.g. OS/Tomcat/application upgrade) > > 5. Unexpected downtime (network outage, hardware fault) > > 6. Scaling-out (either manually or automatically) > > > > You can do it with as little as two Tomcat instances. If you only care > > about being able to restart your application (and not the whole > > server, for example), then you can even run them side-by-side on the > > same server. You won't get protection against OS upgrades and > > unexpected downtime in that case, but you can get familiar with the > > setup without a whole lot of infrastructure. > > > > -chris > > Could you use the RedissonSessionManager and an AWS - distributed Redis > server? > > You could put all of your Tomcat servers in an elastic group, and let > AWS manage that. > > The real problem with this approach is deployment. How do you deploy > across an elastic group of Tomcat servers when you may not know the IP > addresses of the servers or how many you have? > > I can think of some really kludgy ways to do this with S3 and AWS > events, but I've not worked out the details. > > Another way to approach this is to run Docker on AWS (along with Redis), > and then deploy a new version by deploying a new Docker image in a > rolling fashion. > > If your session interface changes a lot, that could create issues. > > That's one of the advantages of using versioned deployment > (app.war##nnn) with a cluster. Old apps stay around until the session > expires, while new sessions get the new version. > > Maybe -- just thinking out loud -- you could use an elastic group, AWS > events, Redis (RedisSessionManager), and numbered WAR files to simulate > a Tomcat cluster. > > Another question: Is the database-backed sessio
ClassNotFoundException when loading session from disk
I'm trying to use PersistentManager with FileStore to load sessions from disk. Serialization goes ok but when the session is loaded I get an exception deserializing one of my application's classes. [2020-05-12 09:08:52] [SEVERE] Session: 6325A48BA1D2FC79105C7F4B0A76CB74.worker1; java.lang.ClassNotFoundException: com.mycompany.MyClass at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1365) at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1188) at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Class.java:348) at org.apache.catalina.util.CustomObjectInputStream.resolveClass(CustomObjectInputStream.java:159) at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1620) at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1521) at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1781) at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1353) at java.io.ObjectInputStream.readObject(ObjectInputStream.java:373) at org.apache.catalina.session.StandardSession.doReadObject(StandardSession.java:1576) at org.apache.catalina.session.StandardSession.readObjectData(StandardSession.java:1048) at org.apache.catalina.session.FileStore.load(FileStore.java:234) Looking into the classpath when the exception occurs I see that every jar in ${catalina.base}/lib is loaded plus those explicitly mentioned in the run command, but none of my application's jars. My application is deployed in ${catalina.base}/myapp/. I tried to add a ${catalina.base}/myapp/ META-INF/context.xml file, but that wasn't loaded. Then I tried to add to context.xml but that didn't help either. It makes sense that Tomcat is separating my application from the rest of the classpath but then how do I include the required class?
Re: seamless restart
The problem is that my application is running on AWS which apparently doesn't support multicasting so I can't use Tomcat's DeltaManager. I thought of using one of the Store implementations for PersistentManager but that has the issues which I mentioned earlier. My aim is to get to the point where I can add or take away servers from the cluster without impacting user experience. Ideally all state would be stored in a central location (e.g. Redis). But, since this is difficult because of the way the application is built I thought of using one server and only persisting the sessions when the server goes down. But I still have to solve the issues I mentioned. On Tue, May 12, 2020 at 6:06 PM Christopher Schultz < ch...@christopherschultz.net> wrote: > -BEGIN PGP SIGNED MESSAGE- > Hash: SHA256 > > Jonathan, > > On 5/12/20 05:51, Jonathan Yom-Tov wrote: > > I have an application which changes the state of user sessions in > > lots of places in the code. Is it possible to do a seamless switch > > of Tomcat servers, preserving all sessions? > > > > I know I can use PersistentManager to persist sessions and load > > them. I can think of two strategies: > > > > 1. Persist sessions periodically. This is more robust as I might > > not have control of when the server shuts down. 2. Persist sessions > > on server shutdown. > > > > > > The problem with the first approach is that I might lose the latest > > changes when the new server comes up. The problem with the second > > is that I'll have to lock access to the session until the old > > server is done saving it, which may make response times very slow. > > > > Is there a good solution to this that I might have overlooked? > > If you want to solve these problems: > > 1. Seamless (uninterrupted) restarts > 2. Always up-to-date (well, as much as possible) > 3. No downtime > > Then you really need a cluster where the sessions are being replicated > around the cluster. > > This will solve some other problems as well: > > 4. Expected downtime (e.g. OS/Tomcat/application upgrade) > 5. Unexpected downtime (network outage, hardware fault) > 6. Scaling-out (either manually or automatically) > > You can do it with as little as two Tomcat instances. If you only care > about being able to restart your application (and not the whole > server, for example), then you can even run them side-by-side on the > same server. You won't get protection against OS upgrades and > unexpected downtime in that case, but you can get familiar with the > setup without a whole lot of infrastructure. > > - -chris > -BEGIN PGP SIGNATURE- > Comment: Using GnuPG with Thunderbird - https://www.enigmail.net/ > > iQIzBAEBCAAdFiEEMmKgYcQvxMe7tcJcHPApP6U8pFgFAl66rKgACgkQHPApP6U8 > pFjsChAAtKdo2Ow+X+Lb0JQLAOxijryxlsRtO3rvdRPJLUxVG4ttVGXuJ86cPX9g > uRoyOrtgSw3N7mPMgL51B39Sp8GtB6zcjAiB4CQzOTXA3FiRN99Jna6dEVpCUcQx > xAUBNuJh6Q5N/l1tpLYIMgKXEmhGcexplNTEVl8IAb5tppNy1LtjUVMG3C4NolI1 > eKUVqNhtSmclBH9aDC94jlWLVH+OiKJhAfc965oCRv4E3vIcj5HGoKfK65iqFYPx > hzOMUzvJfsHBfNMo0UyKvRiDIFyBUgeUEIAJZWAJojhTSHymYpQozYBDIjCfNHYa > II6NYhYb9OuiwV9PEXFN2yZejBsgJvZzlbooWOg2z4nMmCItaTiUhOMyKNIY5wlz > iXnh85yx/GMRSsiQrTD6X4cAwCsXusHwoF/WC0JncYr7hZw/mqwcXDnMhUAccOCc > Z1l2x53yoVSH+RyoGgdG/DSWqLHZfiK/xr8UOtRbMD1WNfGOPo+GhpJBiSNSBeeS > LMNiQbvZEcTKOsxUFgUDPwB62kbDyLnt765tgrSOWubBIaHXBctTNLtv9sjp6ARG > DnNTmAtdk89UuhDA63iimDxx9jxDKsWKPz8Srf6RS7z8yUrlvFkfKQcIEaqHSLTr > LnbrTHK2k92bJonJua5hDcuTgU7axEBlWmXxChyZWmYm2r1R76M= > =suSa > -END PGP SIGNATURE- > > --------- > To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org > For additional commands, e-mail: users-h...@tomcat.apache.org > > -- [image: SysAid Technologies] <http://www.sysaid.com/?utm_source=signature_medium=email_campaign=sysaid-logo> Jonathan Yom-Tov Senior Architect jonathan.yom...@sysaid.com Phone (IL): +972 (3) 533-3675 Ext. 932 [image: SysAid Technologies] <https://www.sysaid.com/?utm_source=signature_medium=email_campaign=sysaid-logo-icon> [image: SysAid on Facebook] <https://www.facebook.com/SysAidIT> [image: SysAid on Twitter] <https://twitter.com/sysaid> [image: SysAid on Linked-in] <https://www.linkedin.com/company/sysaid-technologies-ltd> [image: SysAid on YouTube] <https://www.youtube.com/user/SysAidIT> [image: SysAid on Instagram] <https://www.instagram.com/sysaid_technologies/> [image: Banner] <https://www.sysaid.com/sig-link>
Re: how do I switch class loaders
It was actually one of mine. I put a jar file under lib/ that I forgot had the offending class packaged into it. On Tue, May 12, 2020 at 5:13 PM Christopher Schultz < ch...@christopherschultz.net> wrote: > -BEGIN PGP SIGNED MESSAGE- > Hash: SHA256 > > Jonathan, > > On 5/8/20 15:03, Jonathan Yom-Tov wrote: > > Got it! Using http://jhades.github.io/ it was quick and easy to > > find out that the offending class was indeed loaded from two > > different jar files. After I removed one of them casting worked > > with no issues. I didn't know jar hell could result in > > ClassCastException, but you learn something new every day. > > So what were the two libraries that were conflicting? Logging > libraries should be REALLY obvious since they have a very good chance > of colliding. Did some other library "helpfully" package log4j inside > its own JAR file? > > - -chris > > > On Fri, May 8, 2020 at 9:29 PM Olaf Kock > > wrote: > > > >> > >> On 08.05.20 19:50, Christopher Schultz wrote: > >>> Olaf, > >>> > >>> On 5/8/20 13:19, Olaf Kock wrote: > >>> > >>>> You might want to hunt down duplicate classes in the JAR > >>>> files on your classpath. Worst case: unpack them all in > >>>> temporary directories and check for occurrences of the > >>>> filename. Make sure that one doesn't overwrite the other when > >>>> unzipping. > >>> > >>> Or unpack them all and let the unzipper tell you if there are > >>> any filename collisions. > >>> > >>> Someone has probably written a "classpath scanner" that will > >>> just unzip everything and look for conflicts. > >> > >> > >> I've gotten follow up questions on how to use those tools in the > >> past. Key is to identify all the jars, less the options of the > >> tool, but since then I've just reverted to mention the low-tech > >> version, and am not even ashamed ;) > >> > >> That's not to say that I don't trust Jonathan to use a classpath > >> scanner - it's just a low-tech-preference out of habit. > >> > >> Plus, due to this habit, I currently can't come up with a tool's > >> name to look for :D > >> > >> Olaf > >> > >> > >> > >> - > >> > >> > To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org > >> For additional commands, e-mail: users-h...@tomcat.apache.org > >> > >> > > > -BEGIN PGP SIGNATURE- > Comment: Using GnuPG with Thunderbird - https://www.enigmail.net/ > > iQIzBAEBCAAdFiEEMmKgYcQvxMe7tcJcHPApP6U8pFgFAl66rREACgkQHPApP6U8 > pFhqOBAApsaappSGDrveTxgVU4X2x0VKtZxCzMX8yZ4rSPaFvRi0rMp1bLlaV/sw > ZaRAQLZbAF5dBgahU4AqKmEkPNw2SlncuykX1JZs//lCDqzaFrJ4Dbsw4YJ7cq+3 > 3jwV6LTS7XzFXOoCHShvvbbwsK2qTWE870TQwOSN+yCN0mTbZz3ah2qnKXoLWZvn > qUOfYmtTRJTN8vBsR0BpRq2QXZ+uL565A4WLeX9j5jTWiZ5zDNsjN4h9/GHcKChM > lKIwR8VVfGI+le4JHiW9kz0gukbe/gcvFNPnf5UpvpVZf4VYOQyuTV0gNYAO1QZ8 > CoZ9qNuAjO6aE4BW6PGeFCnDZ55/i6lVe8ZM69Z6WFum8jYOCi2wbuPyUmZqzTbX > aXAe7OWHXrDgdGUIUFaOvvpMjbEbG/6TBH+VMAbLN3i4uFEQwmjP+9JFn3PSeyok > ca/5ev99ExfqEOqpQgRddxjo8TBczZdchsUazvR0pcoEWzbQUPvZKN/lRnaCTkxn > Gvx7co1mw9sGVHkYhktJNLvZE6KP48xaRZISWhCVsVX0LgpUwOyD37N1+wUYgqJT > Zao62Za5GVVZrbD6+9HYBD3WhKwJwxvxICQ42diEitSxgdvRSTbuUbrREVfkiYgu > 7OmlWx6y7aXEDgDS7DSBOiMW3/N93uGzOPL0gECQnBmKHLDKfU4= > =ANY3 > -END PGP SIGNATURE- > > - > To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org > For additional commands, e-mail: users-h...@tomcat.apache.org > >
seamless restart
I have an application which changes the state of user sessions in lots of places in the code. Is it possible to do a seamless switch of Tomcat servers, preserving all sessions? I know I can use PersistentManager to persist sessions and load them. I can think of two strategies: 1. Persist sessions periodically. This is more robust as I might not have control of when the server shuts down. 2. Persist sessions on server shutdown. The problem with the first approach is that I might lose the latest changes when the new server comes up. The problem with the second is that I'll have to lock access to the session until the old server is done saving it, which may make response times very slow. Is there a good solution to this that I might have overlooked?
Re: how do I switch class loaders
Got it! Using http://jhades.github.io/ it was quick and easy to find out that the offending class was indeed loaded from two different jar files. After I removed one of them casting worked with no issues. I didn't know jar hell could result in ClassCastException, but you learn something new every day. Thanks everyone for your help. Olaf I found your suggestion especially helpful. Have a good weekend :-) On Fri, May 8, 2020 at 9:29 PM Olaf Kock wrote: > > On 08.05.20 19:50, Christopher Schultz wrote: > > Olaf, > > > > On 5/8/20 13:19, Olaf Kock wrote: > > > > > You might want to hunt down duplicate classes in the JAR files on > > > your classpath. Worst case: unpack them all in temporary > > > directories and check for occurrences of the filename. Make sure > > > that one doesn't overwrite the other when unzipping. > > > > Or unpack them all and let the unzipper tell you if there are any > > filename collisions. > > > > Someone has probably written a "classpath scanner" that will just > > unzip everything and look for conflicts. > > > I've gotten follow up questions on how to use those tools in the past. > Key is to identify all the jars, less the options of the tool, but since > then I've just reverted to mention the low-tech version, and am not even > ashamed ;) > > That's not to say that I don't trust Jonathan to use a classpath scanner > - it's just a low-tech-preference out of habit. > > Plus, due to this habit, I currently can't come up with a tool's name to > look for :D > > Olaf > > > > - > To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org > For additional commands, e-mail: users-h...@tomcat.apache.org > > -- [image: SysAid Technologies] <http://www.sysaid.com/?utm_source=signature_medium=email_campaign=sysaid-logo> Jonathan Yom-Tov Senior Architect jonathan.yom...@sysaid.com Phone (IL): +972 (3) 533-3675 Ext. 932 [image: SysAid Technologies] <https://www.sysaid.com/?utm_source=signature_medium=email_campaign=sysaid-logo-icon> [image: SysAid on Facebook] <https://www.facebook.com/SysAidIT> [image: SysAid on Twitter] <https://twitter.com/sysaid> [image: SysAid on Linked-in] <https://www.linkedin.com/company/sysaid-technologies-ltd> [image: SysAid on YouTube] <https://www.youtube.com/user/SysAidIT> [image: SysAid on Instagram] <https://www.instagram.com/sysaid_technologies/> [image: Banner] <https://www.sysaid.com/sig-link>
Re: how do I switch class loaders
Oops, my bad But that still leaves my original issue: why do I get a ClassCastException casting RedissonSessionManager to RedissonSessionManager? On Fri, 8 May 2020, 16:56 Luis Rodríguez Fernández, wrote: > Hello Jonathan, > > It is not exactly the same :), look at the "$2" appended at the end.This is > an "anonymous inner class" [1] > > Cheers, > > Luis > > [1] > > https://stackoverflow.com/questions/11388840/java-compiled-classes-contain-dollar-signs > > > El vie., 8 may. 2020 a las 11:52, Jonathan Yom-Tov (< > jonathan.yom...@sysaid.com>) escribió: > > > This is very odd. I ran Tomcat with -verbose:class (see relevant output > > below). The class is being loaded twice from the same location, I'm > > guessing by two different class loaders. How can that be? > > > > [Loaded org.redisson.tomcat.RedissonSessionManager from > > file:/C:/dev/tomcat.9.0.19/lib/redisson-tomcat-9-3.12.2.jar] > > [Loaded org.redisson.tomcat.RedissonSessionManager$2 from > > file:/C:/dev/tomcat.9.0.19/lib/redisson-tomcat-9-3.12.2.jar] > > > > On Fri, May 8, 2020 at 11:04 AM Olaf Kock wrote: > > > > > > > > On 08.05.20 09:37, Jonathan Yom-Tov wrote: > > > > Thanks Mark. Just tried that. I put the redisson-tomcat jar outside > of > > > > WEB-INF/lib and added it with scope provided. I get the exact same > > issue. > > > > What am I doing wrong? > > > > > > Make sure, it's actually gone from your webapp. Depending on the > > > deployment technique I've seen removed files to persist from previous > > > deployments. > > > > > > You might need to fully undeploy, then deploy the new version without > > > the jar in question. But inspect the runtime environment to make sure > > > you only have a single library accessible. Having the same class > > > available two different ways is a recipe for disaster, don't fix it my > > > messing with the classloader: Fix it by eliminating one of them. > > > > > > You might also check if you're not accessing any wrapped object, e.g. > by > > > inspecting getManager(session).getClass().getName(). > > > > > > Olaf > > > > > > > > > > > > > Here's my code: > > > > > > > > HttpSession session = httpServletRequest.getSession(false); > > > > try { > > > > RedissonSessionManager rsm = (RedissonSessionManager) > > > getManager(session); > > > > } catch (Exception e) { > > > > e.printStackTrace(); > > > > } > > > > > > > > private Manager getManager(HttpSession session) throws Exception { > > > > > > > > Field facadeSessionField = > > > > StandardSessionFacade.class.getDeclaredField("session"); > > > > facadeSessionField.setAccessible(true); > > > > StandardSession stdSession = (StandardSession) > > > > facadeSessionField.get(session); > > > > > > > > return stdSession.getManager(); > > > > } > > > > > > > > > > > > > > > > On Thu, May 7, 2020 at 11:52 PM Mark Thomas > wrote: > > > > > > > >> On 07/05/2020 21:36, Jonathan Yom-Tov wrote: > > > >>> My application uses Redisson (a client which persists the session > to > > > >>> Redis). There are two Redisson jar files located in > > $CATALINA_HOME/lib, > > > >> so > > > >>> if I understand the docs correctly they're loaded by the common > class > > > >>> loader. > > > >>> > > > >>> I want to access the RedissonSessionManager class during a request. > > The > > > >>> problem is that if I do something like RedissonSessionManager > > manager = > > > >>> (RedissonSessionManager) session.getManager() I get a > > > ClassCastException, > > > >>> presumably because they were loaded by different class loaders. > > > >>> > > > >>> Will it help if I somehow access the common class loader for this? > If > > > so > > > >>> how can I do that? If not is there some other way I can achieve > this? > > > >> Make sure you don't have those JARs in your application's > WEB-INF/lib > > as > > > >> well as $CATALINA_BASE/lib. > > > >> > > > >> In any recent version of Tomcat any JAR in $CATALINA_BASE/lib will > be > &g
Re: how do I switch class loaders
This is very odd. I ran Tomcat with -verbose:class (see relevant output below). The class is being loaded twice from the same location, I'm guessing by two different class loaders. How can that be? [Loaded org.redisson.tomcat.RedissonSessionManager from file:/C:/dev/tomcat.9.0.19/lib/redisson-tomcat-9-3.12.2.jar] [Loaded org.redisson.tomcat.RedissonSessionManager$2 from file:/C:/dev/tomcat.9.0.19/lib/redisson-tomcat-9-3.12.2.jar] On Fri, May 8, 2020 at 11:04 AM Olaf Kock wrote: > > On 08.05.20 09:37, Jonathan Yom-Tov wrote: > > Thanks Mark. Just tried that. I put the redisson-tomcat jar outside of > > WEB-INF/lib and added it with scope provided. I get the exact same issue. > > What am I doing wrong? > > Make sure, it's actually gone from your webapp. Depending on the > deployment technique I've seen removed files to persist from previous > deployments. > > You might need to fully undeploy, then deploy the new version without > the jar in question. But inspect the runtime environment to make sure > you only have a single library accessible. Having the same class > available two different ways is a recipe for disaster, don't fix it my > messing with the classloader: Fix it by eliminating one of them. > > You might also check if you're not accessing any wrapped object, e.g. by > inspecting getManager(session).getClass().getName(). > > Olaf > > > > > Here's my code: > > > > HttpSession session = httpServletRequest.getSession(false); > > try { > > RedissonSessionManager rsm = (RedissonSessionManager) > getManager(session); > > } catch (Exception e) { > > e.printStackTrace(); > > } > > > > private Manager getManager(HttpSession session) throws Exception { > > > > Field facadeSessionField = > > StandardSessionFacade.class.getDeclaredField("session"); > > facadeSessionField.setAccessible(true); > > StandardSession stdSession = (StandardSession) > > facadeSessionField.get(session); > > > > return stdSession.getManager(); > > } > > > > > > > > On Thu, May 7, 2020 at 11:52 PM Mark Thomas wrote: > > > >> On 07/05/2020 21:36, Jonathan Yom-Tov wrote: > >>> My application uses Redisson (a client which persists the session to > >>> Redis). There are two Redisson jar files located in $CATALINA_HOME/lib, > >> so > >>> if I understand the docs correctly they're loaded by the common class > >>> loader. > >>> > >>> I want to access the RedissonSessionManager class during a request. The > >>> problem is that if I do something like RedissonSessionManager manager = > >>> (RedissonSessionManager) session.getManager() I get a > ClassCastException, > >>> presumably because they were loaded by different class loaders. > >>> > >>> Will it help if I somehow access the common class loader for this? If > so > >>> how can I do that? If not is there some other way I can achieve this? > >> Make sure you don't have those JARs in your application's WEB-INF/lib as > >> well as $CATALINA_BASE/lib. > >> > >> In any recent version of Tomcat any JAR in $CATALINA_BASE/lib will be > >> visible to your application. > >> > >> Mark > >> > >> ------------- > >> To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org > >> For additional commands, e-mail: users-h...@tomcat.apache.org > >> > >> > > - > To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org > For additional commands, e-mail: users-h...@tomcat.apache.org > > -- [image: SysAid Technologies] <http://www.sysaid.com/?utm_source=signature_medium=email_campaign=sysaid-logo> Jonathan Yom-Tov Senior Architect jonathan.yom...@sysaid.com Phone (IL): +972 (3) 533-3675 Ext. 932 [image: SysAid Technologies] <https://www.sysaid.com/?utm_source=signature_medium=email_campaign=sysaid-logo-icon> [image: SysAid on Facebook] <https://www.facebook.com/SysAidIT> [image: SysAid on Twitter] <https://twitter.com/sysaid> [image: SysAid on Linked-in] <https://www.linkedin.com/company/sysaid-technologies-ltd> [image: SysAid on YouTube] <https://www.youtube.com/user/SysAidIT> [image: SysAid on Instagram] <https://www.instagram.com/sysaid_technologies/> [image: Banner] <https://www.sysaid.com/sig-link>
Re: how do I switch class loaders
Thanks Mark. Just tried that. I put the redisson-tomcat jar outside of WEB-INF/lib and added it with scope provided. I get the exact same issue. What am I doing wrong? Here's my code: HttpSession session = httpServletRequest.getSession(false); try { RedissonSessionManager rsm = (RedissonSessionManager) getManager(session); } catch (Exception e) { e.printStackTrace(); } private Manager getManager(HttpSession session) throws Exception { Field facadeSessionField = StandardSessionFacade.class.getDeclaredField("session"); facadeSessionField.setAccessible(true); StandardSession stdSession = (StandardSession) facadeSessionField.get(session); return stdSession.getManager(); } On Thu, May 7, 2020 at 11:52 PM Mark Thomas wrote: > On 07/05/2020 21:36, Jonathan Yom-Tov wrote: > > My application uses Redisson (a client which persists the session to > > Redis). There are two Redisson jar files located in $CATALINA_HOME/lib, > so > > if I understand the docs correctly they're loaded by the common class > > loader. > > > > I want to access the RedissonSessionManager class during a request. The > > problem is that if I do something like RedissonSessionManager manager = > > (RedissonSessionManager) session.getManager() I get a ClassCastException, > > presumably because they were loaded by different class loaders. > > > > Will it help if I somehow access the common class loader for this? If so > > how can I do that? If not is there some other way I can achieve this? > > Make sure you don't have those JARs in your application's WEB-INF/lib as > well as $CATALINA_BASE/lib. > > In any recent version of Tomcat any JAR in $CATALINA_BASE/lib will be > visible to your application. > > Mark > > - > To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org > For additional commands, e-mail: users-h...@tomcat.apache.org > > -- [image: SysAid Technologies] <http://www.sysaid.com/?utm_source=signature_medium=email_campaign=sysaid-logo> Jonathan Yom-Tov Senior Architect jonathan.yom...@sysaid.com Phone (IL): +972 (3) 533-3675 Ext. 932 [image: SysAid Technologies] <https://www.sysaid.com/?utm_source=signature_medium=email_campaign=sysaid-logo-icon> [image: SysAid on Facebook] <https://www.facebook.com/SysAidIT> [image: SysAid on Twitter] <https://twitter.com/sysaid> [image: SysAid on Linked-in] <https://www.linkedin.com/company/sysaid-technologies-ltd> [image: SysAid on YouTube] <https://www.youtube.com/user/SysAidIT> [image: SysAid on Instagram] <https://www.instagram.com/sysaid_technologies/> [image: Banner] <https://www.sysaid.com/sig-link>
how do I switch class loaders
My application uses Redisson (a client which persists the session to Redis). There are two Redisson jar files located in $CATALINA_HOME/lib, so if I understand the docs correctly they're loaded by the common class loader. I want to access the RedissonSessionManager class during a request. The problem is that if I do something like RedissonSessionManager manager = (RedissonSessionManager) session.getManager() I get a ClassCastException, presumably because they were loaded by different class loaders. Will it help if I somehow access the common class loader for this? If so how can I do that? If not is there some other way I can achieve this? Jon.
Re: Is it possible to programmatically compile jsp files?
Sounds good. What would be the best way of evaluating the result so I can cache it? On Wed, Mar 25, 2020 at 4:03 PM Olaf Kock wrote: > > On 25.03.20 14:51, Jonathan Yom-Tov wrote: > > I think I phrased my question incorrectly. What I want to do is to cache > > the HTML resulting from the JSPs evaluation so I can serve the cached > > result. The reason is that I'm working on an application which makes a > lot > > of requests per page. This makes the page very slow. What I want to do is > > to serve some of the requests which build the page out of a cache. > > Rewriting the offending endpoints would be a very lengthy process. There > > are a lot of them and they're part of a legacy project which is very hard > > to get into. > > > > So is pre-evaluating the JSPs the correct strategy or is there a > better way? > > > well, with that, you could either request the JSP yourself and cache the > result. To do this transparently, you could implement a ServletFilter > that caches the result if it senses a cacheable request and (on > subsequent requests) transparently serves the value from cache as long > as the criteria ("should re-evaluate") holds. > > Bonus points for taking care of concurrent requests during > re-evaluation, and pause them during the time a re-evaluation is done in > a different request. > > Olaf > > > > > - > To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org > For additional commands, e-mail: users-h...@tomcat.apache.org > > -- [image: SysAid Technologies] <http://www.sysaid.com/?utm_source=signature_medium=email_campaign=sysaid-logo> Jonathan Yom-Tov Senior Architect jonathan.yom...@sysaid.com Phone (IL): +972 (3) 533-3675 Ext. 932 [image: SysAid Technologies] <https://www.sysaid.com/?utm_source=signature_medium=email_campaign=sysaid-logo-icon> [image: SysAid on Facebook] <https://www.facebook.com/SysAidIT> [image: SysAid on Twitter] <https://twitter.com/sysaid> [image: SysAid on Linked-in] <https://www.linkedin.com/company/sysaid-technologies-ltd> [image: SysAid on YouTube] <https://www.youtube.com/user/SysAidIT> [image: SysAid on Instagram] <https://www.instagram.com/sysaid_technologies/> [image: Banner] <https://www.sysaid.com/sig-link>
Re: Is it possible to programmatically compile jsp files?
I think I phrased my question incorrectly. What I want to do is to cache the HTML resulting from the JSPs evaluation so I can serve the cached result. The reason is that I'm working on an application which makes a lot of requests per page. This makes the page very slow. What I want to do is to serve some of the requests which build the page out of a cache. Rewriting the offending endpoints would be a very lengthy process. There are a lot of them and they're part of a legacy project which is very hard to get into. So is pre-evaluating the JSPs the correct strategy or is there a better way? On Tue, Mar 24, 2020 at 11:59 PM Christopher Schultz < ch...@christopherschultz.net> wrote: > -BEGIN PGP SIGNED MESSAGE- > Hash: SHA256 > > Jonathan, > > On 3/24/20 10:44, Jonathan Yom-Tov wrote: > > I have a set of jsp files. These jsps' compilation result changes > > whenever a variable in my cache changes. I want to compile them > > whenever that variable changes so they're ready to serve without > > going through the normal pipeline. Is that possible? > > I completely agree with Olaf's response. > > That being said, there is a spec-defined way to invoke compilation of > a JSP without evaluating it: make a request to > /context/path/to/my.jsp?jsp_precompile > > This is defined in JSP 2.3 section 11.4.2. I wasn't able to find the > JSP spec 3.0 publication, but I'll bet it will be in there once it's > published (it may have been subsumed into Jakarta EE at this point). > > - -chris > -BEGIN PGP SIGNATURE- > Comment: Using GnuPG with Thunderbird - https://www.enigmail.net/ > > iQIzBAEBCAAdFiEEMmKgYcQvxMe7tcJcHPApP6U8pFgFAl56gpIACgkQHPApP6U8 > pFjQRg//Sc+dmxwrmjtZEqiI6KIBsvBS6A3jpTPMhUb6akiYy9YqciuuLJnYu8EE > tTYHkAo+52lIU15csUTRhGXzj1YgLexg3pVEroVChYgg9uwg0hN3+yp0UhbAjgxs > tZ1eEbVJX5wEm7MiHEFZTxbkQnZ5nQXUGeQnM6cdVaZJKZs7Hu+unMiAKldz+zlP > oNnfnchf4QEmI+z1L3ktBdwGBXaKCKTkdXXcPJKqzq/pEl/32/ncZS5xYOK0hcK3 > DK3pLLRxC9iBMKt5HSNMWAfiQMDtpVKpR4tLuwP+bB2rEKlkRYfslKzUHnWQlY0F > afT1dOSQvxEWFpMmnzU5H/d6/G9+xYKSlq/duCBm/7OZndXUe1A+HDr+CUQNbem6 > hHSszZ4kZoyt6B8iIJKigduwY4GcZV2ZKTO334KTscXXNka0B3Um94UK1CQP4CWS > n0lChV/bkqNviwcsA/Zq4YxrENpisVCvC2n4fILQ2ftqIgXmYR4sdYp5h3+joiEx > 64saVENrOaLO8gMtGF1nsUhuJlvld4VA9bkdRkHDfO63nvUN4x3McxPG7VxOplmh > Kws+axYpVekuHw0a7WkMQkPx0tIbIFuTs34KuoDifOjAoPGCCbOGKP9UlhndX9IR > S0oMMgDKuO6DupVTx28xX9qfjXnNRVSnaSETBhNO6qajiUZA7V4= > =ZiT1 > -END PGP SIGNATURE- > > - > To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org > For additional commands, e-mail: users-h...@tomcat.apache.org > > -- [image: SysAid Technologies] <http://www.sysaid.com/?utm_source=signature_medium=email_campaign=sysaid-logo> Jonathan Yom-Tov Senior Architect jonathan.yom...@sysaid.com Phone (IL): +972 (3) 533-3675 Ext. 932 [image: SysAid Technologies] <https://www.sysaid.com/?utm_source=signature_medium=email_campaign=sysaid-logo-icon> [image: SysAid on Facebook] <https://www.facebook.com/SysAidIT> [image: SysAid on Twitter] <https://twitter.com/sysaid> [image: SysAid on Linked-in] <https://www.linkedin.com/company/sysaid-technologies-ltd> [image: SysAid on YouTube] <https://www.youtube.com/user/SysAidIT> [image: SysAid on Instagram] <https://www.instagram.com/sysaid_technologies/> [image: Banner] <https://www.sysaid.com/sig-link>
Is it possible to programmatically compile jsp files?
I have a set of jsp files. These jsps' compilation result changes whenever a variable in my cache changes. I want to compile them whenever that variable changes so they're ready to serve without going through the normal pipeline. Is that possible?
Re: valve execution order
What about valves which are added programmatically within the same engine? Is it possible to control the order? On Mon, Mar 23, 2020 at 4:14 PM Christopher Schultz < ch...@christopherschultz.net> wrote: > -BEGIN PGP SIGNED MESSAGE- > Hash: SHA256 > > Mark, > > On 3/23/20 09:59, Mark Thomas wrote: > > On 23/03/2020 13:13, Jonathan Yom-Tov wrote: > >> I'm trying to create a valve which will prevent another valve > >> from working in case a particular request is made. Is there a way > >> to control the valve execution order so that I can inject my > >> valve right before the valve I want to stop? > > > > Valves should be added (and hence executed) in the order they > > appear in the XML. > > > > Also, Valves on an Engine always execute before those on a Host > > which always execute before those on a Context. > > Correct me if I'm wrong, but there is one more caveat: if the > defines its own Authenticator, then whatever Authenticator > Tomcat would have also automatically added is in fact NOT added. > > Where does the context's authentication valve go in that situation? In > the position where the default one would have gone, or in the > 's position according to the XML? > > - -chris > > -BEGIN PGP SIGNATURE- > Comment: Using GnuPG with Thunderbird - https://www.enigmail.net/ > > iQIzBAEBCAAdFiEEMmKgYcQvxMe7tcJcHPApP6U8pFgFAl54xE0ACgkQHPApP6U8 > pFiVHg/+NslxaBe+HThPGSoKS4+VLoHJ/T9ph9ksSDB7YrCBNs6D3NAjwtodmQ4m > bNF1YmCrm40fcOSe5e4LH74GOFEUKK8VAQ0O0ZVPVljt/RuttmtgCQMHbKEk3FVx > vPGe9ED6ouNvOjpib6LIoYlQHk1gJcK9joEMHfB4NTT9VM9/QFbgscC1LIeBmk5i > 4xzsZ1JAajWWJ7mj6kkkyJuUi8CKeeZL+U9kEqDyObTj0ODFpSekv5xmZ3Qoklds > YmYM00VaMn6R3pZpodk5Ha3/+uzUavEoGJ05Sz6/YIyDedZChAqsvkyAM/klpmYl > Rd1yiYOqi8zVdndpsrnMoCI5TCmTNuLrUZ44jP1e9kiaZe6bN7+FHyAD0O0SQXaS > XYvQIgb31MrVX4Q+zFoSHjbHfAaITGER/08X3hj1sOeFQc2i0E6IWLltfuXwG4tW > jMv/xcCWnkBBylU/grRNF/91Ym4QyZtbUhFKkb64Jrs6Hy24aG9j06rqTI7bxqnL > hMs5q0bjM6XbmuGoYnS60CKQBL3kwsfyJvbbB5n1X5vyg8LkE/6uYMp67/kIS+M2 > x9uk2ESfOgVj5yZYjxs/pZcWIjU1VdnTVN9vp16RTlR2vwoGCTQ6IouKYaYEiM3u > l83uObuBW8VcX+QEChSZn8rgSZKLG9xkQr+otFc/oVBPFtW0tJA= > =t6Nj > -END PGP SIGNATURE- > > - > To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org > For additional commands, e-mail: users-h...@tomcat.apache.org > >
valve execution order
I'm trying to create a valve which will prevent another valve from working in case a particular request is made. Is there a way to control the valve execution order so that I can inject my valve right before the valve I want to stop?
ajp port chosen at random
hi, I'm configuring a two tomcat cluster with session replication and encountering a strange issue. One of the tomcats appears to choose the AJP connector port at random. The other tomcat obeys the port directive from its connector without a problem. This is doubly strange because the second tomcat's entire directory is copied from the first's and I only made the necessary modifications to ports in server.xml in order to avoid clashes. The random port changes with every restart of tomcat. Any ideas on where I can find where tomcat chooses the port, or how I can debug this? thanks, Jon.
Re: cloud cluster
hi Chris, Do you have a link? I wasn't able to find one on Google, unless you mean https://bitnami.com/stack/tomcat/helm. thanks, Jon. On Tue, Feb 18, 2020 at 5:44 PM Christopher Schultz < ch...@christopherschultz.net> wrote: > -BEGIN PGP SIGNED MESSAGE- > Hash: SHA256 > > Jon, > > On 2/16/20 10:06, Jonathan Yom-Tov wrote: > > What kind of configuration do people usually use when deploying on > > a public cloud (e.g. AWS)? An auto-scaling cluster with session > > replication? A auto-scaling cluster with all sessions stored in an > > external cache? > > Rémy Mucharat has recently been developing Kubernetes-based cluster > membership capabilities. So if you are using Kubernetes, you might > want to look into using that. > > - -chris > -BEGIN PGP SIGNATURE- > Comment: Using GnuPG with Thunderbird - https://www.enigmail.net/ > > iQIzBAEBCAAdFiEEMmKgYcQvxMe7tcJcHPApP6U8pFgFAl5MBi4ACgkQHPApP6U8 > pFhhfhAAy4YicM2FAR23UnP6nVQxJdqRrSAQCxNVNMCxgUSYtIEeisb7pra3mIdS > dKU6YXAGdurKcSiL0LItwIR/GufzaVazM/vSBTZOrn+PUOPkGfbvAmO7jQbbmbxs > AP1NEruScgEVUNad/tUd6igG1iAjWFV7sZOcRIyXpEnyJxVIXujXWr+zmWi4caga > 5MskwisPBN6gCTTDqUGzhGK+2HvMWgPp/WGYbReO2hSm11jmuuTIsLpOqTXodgKM > y77QtNIcxsQtfMLiL6pNfVbWRB4QlFpSKIUUetdcXHB8Njk3neBTlNdtzU+UjN2A > 2dTtWFGbUYFKSRDD8T1QNbEc9biVBH2E7k73Fjo6lxYY0vt4UqCV8wA85h8A+Xxm > eOdRZt8LVAVC9pt+ctwtzDbB6CTWkQKJvYGUXyrEYfGA0ijAhXx118iI3DgXbpKf > J5eQQ1Ec85eABiwGjs6XqNOMn/6/9gn4Vjm+wKtSzVF+e563NNfMwGEM+GST8Q44 > dQoXmju9MoNlgXE8EnuO5aDk1Xtjd3z7aGWxdVFRQ9M0V+PC+2/vVHRCw6vGUpIb > NCdqFMUB1jWU9jO0urdCzrMcFoyawmxRuLbDGOVCHlaXLfNTYfkstudhv2METqbV > oZrC2gt6NQWsRbp4W6vIzxP22T+oPcWJvaKteVLjxZrrO2Jfi0M= > =7qcU > -END PGP SIGNATURE- > > - > To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org > For additional commands, e-mail: users-h...@tomcat.apache.org > > -- [image: SysAid Technologies] <http://www.sysaid.com/?utm_source=signature_medium=email_campaign=sysaid-logo> Jonathan Yom-Tov Senior Architect jonathan.yom...@sysaid.com Phone (IL): +972 (3) 533-3675 Ext. 932 [image: SysAid Technologies] <https://www.sysaid.com/?utm_source=signature_medium=email_campaign=sysaid-logo-icon> [image: SysAid on Facebook] <https://www.facebook.com/SysAidIT> [image: SysAid on Twitter] <https://twitter.com/sysaid> [image: SysAid on Linked-in] <https://www.linkedin.com/company/sysaid-technologies-ltd> [image: SysAid on YouTube] <https://www.youtube.com/user/SysAidIT> [image: SysAid on Instagram] <https://www.instagram.com/sysaid_technologies/> [image: Banner] <https://www.sysaid.com/sig-link>
cloud cluster
hi, What kind of configuration do people usually use when deploying on a public cloud (e.g. AWS)? An auto-scaling cluster with session replication? A auto-scaling cluster with all sessions stored in an external cache? Jon.