Re: Persistent Manager Implementation Question
Yes both are pointing the same configuration because i was doing some testing how it works all of this about session, i wasnt able to get it to work in a new application just using spring boot , but i just did it on friday. what i was missing it was use the session and not only a getter or endpoint without any use of the session. it seems to get it to work that you need to use the session, the configuration is already working jdbcInterceptors="org.apache.tomcat.jdbc.pool.interceptor.ConnectionState; org.apache.tomcat.jdbc.pool.interceptor.StatementFinalizer; org.apache.tomcat.jdbc.pool.interceptor.ResetAbandonedTimer" with this configuration my both application are working fine and also i created in the new application how to test it : @GetMapping("/create") public String testSession(HttpSession session) { // Add a session attribute session.setAttribute("testAttribute", "testValue"); // Get the session ID String sessionId = session.getId(); return "Session created with ID: " + sessionId + " and attribute added"; } @GetMapping("/getse") public String getSessionAttribute(HttpSession session) { // Get the session ID String sessionId = session.getId(); // Retrieve session attribute String attributeValue = (String) session.getAttribute("testAttribute"); if (attributeValue != null) { return "Session ID: " + sessionId + ", Attribute value: " + attributeValue; } else { return "Session ID: " + sessionId + ", Attribute not found"; } } and also added a filter to validate to create it correctly @Component public class SessionValidationFilter extends OncePerRequestFilter { protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) throws ServletException, IOException { String requestURI = request.getRequestURI(); // Exclude the create-session endpoint from filtering if (requestURI.equals("/demo/create")) { filterChain.doFilter(request, response); return; } HttpSession session = request.getSession(false); // Do not create session if it doesn't exist if (session != null && session.getId() != null) { // Session is valid, proceed with the request filterChain.doFilter(request, response); } else { // Session is invalid, return an error response response.sendError(HttpServletResponse.SC_UNAUTHORIZED, "Session expired or not authenticated"); } } } El lun, 12 feb 2024 a las 9:18, Christopher Schultz (< ch...@christopherschultz.net>) escribió: > Miguel, > > On 2/8/24 15:49, Miguel Vidal wrote: > > Im trying to configure correctly in 2 different applications : Persistent > > Manager Implementation using a mysqldb as a datasource. > > Do you have both PersistentManager configurations pointing at the same > database and same set of tables? I think it will be rare to have session > id collisions, but configuring both applications to use the same storage > may cause very difficult to discover bugs under high usage. > > It will also increase lock contention needlessly across the two > applications. > > -chris > > > In one of them that is a legacy project i have some dependencies as > > > > > > org.springframework > > spring-core > > ${spring.framework.version} > > > > > > > > org.springframework > > spring-context > > ${spring.framework.version} > > > > > > and it is already doing the registry of the sessions in my bd. > > but in the other app im using a spring boot with the same configuration. > > I'm not able to see any registration of the sessions in my db. After the > > deploy of my app in a tomcat server and hit any resource example > > /test/resource im able to see the response correctly but i just want to > > know if this Persistent Manager Implementation is only for legacy apps? > or > > why is running in one and in the other is not. > > > > this is my xml for both > > > > > > > reloadable="true" useHttpOnly="true" cookies="${uses.cookies}" > > > > > > className="org.apache.catalina.session.PersistentManager" > > maxInactiveInterval="3600" debug="0" saveOnRestart="true" > > maxActiveSessions="-1" minIdleSwap="1" maxIdleSwap="2" > > maxIdleBackup="1" > > > > dataSourceName="jdbc/tomcat" > > driverName="com.mysql.jdbc.Driver" > > sessionAppCol="app_name" > > sessionDataCol="session_data" > > sessionIdCol="session_id" > > sessionLastAccessedCol="last_access" > > sessionMaxInactiveCol="max_inactive" > > sessionTable="tomcat_sessions" > > sessionValidCol="valid_session" > > /> > > > > > > > name="jdbc/tomcat" > >
Re: [OT] Tomcat not syncing existing sessions on restart
Manak, On 2/12/24 10:33, Manak Bisht wrote: Chris, On Mon, 12 Feb 2024, 20:52 Christopher Schultz, < ch...@christopherschultz.net> wrote: I wouldn't refuse to configure, since anyone using 0.0.0.0 with /separate/ hosts wouldn't experience this problem. I am using separate hosts (two docker containers on two different machines) in my main deployment. I just reproduced the problem on the same host to rule out network issues. Thanks for the clarification. For some reason, I thought this was two Docker containers on the same host. -chris - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Re: [OT] Tomcat not syncing existing sessions on restart
Chris, On Mon, 12 Feb 2024, 20:52 Christopher Schultz, < ch...@christopherschultz.net> wrote: > I wouldn't refuse to configure, since anyone using > 0.0.0.0 with /separate/ hosts wouldn't experience this problem. I am using separate hosts (two docker containers on two different machines) in my main deployment. I just reproduced the problem on the same host to rule out network issues. Sincerely, Manak Bisht
Re: Tomcat Instance unable to connect to DB with TCPS
Michael, On 2/8/24 21:54, Kebret, Michael wrote: Tomcat version 9.0.83 running on Linux redhat 7 java 11.0.20. When changing the protocol from TCP to TCPS in Catalina.properties and in server.xml we have attribute truststorePassword= (tested with both cleartext and encrypted) password connection is refused to the DB and get the below exceptions. However, when we add -Djavax.net.ssl.trustStorePassword=cleartext to setenv.sh the connection is made successfully. Wanted to see if anyone has faced something similar or have any suggestions on how I can get TCPS working without having to use -D option in setenv.sh > java.sql.SQLException: Unable to start the Universal Connection Pool: oracle.ucp.UniversalConnectionPoolException: Cannot get Connection from Datasource: java.sql.SQLRecoverableException: IO Error: The Network Adapter could not establish the connection You probably do not want to set a JVM-wide default trust store password. Instead, you probably want to use your JDBC connection URL to pass the trust store location and password directly to the driver. Something like jdbc:oracle:thin:@//[HOST][:PORT]/SERVICE?truststore=/etc/myapp/db.p12=changeit Have a look at https://docs.oracle.com/cd/E13222_01/wls/docs81/jdbc_drivers/oracle.html#1066413 for inspiration. I'm not sure if this is the driver you are using or not. I don't see anything in there that applies. :( Perhaps Oracle's driver really does require that you use JVM-wide trust store and password? Super-yuck. -chris - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Re: [OT] Tomcat not syncing existing sessions on restart
Mark, On 2/9/24 06:14, Mark Thomas wrote: With the Receiver using address="0.0.0.0" I see the same issues you do. I'm not yet convinced that is a bug. If this is known to essentially always not-work... should we log something at startup? I wouldn't refuse to configure, since anyone using 0.0.0.0 with /separate/ hosts wouldn't experience this problem. -chris - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Re: Persistent Manager Implementation Question
Miguel, On 2/8/24 15:49, Miguel Vidal wrote: Im trying to configure correctly in 2 different applications : Persistent Manager Implementation using a mysqldb as a datasource. Do you have both PersistentManager configurations pointing at the same database and same set of tables? I think it will be rare to have session id collisions, but configuring both applications to use the same storage may cause very difficult to discover bugs under high usage. It will also increase lock contention needlessly across the two applications. -chris In one of them that is a legacy project i have some dependencies as org.springframework spring-core ${spring.framework.version} org.springframework spring-context ${spring.framework.version} and it is already doing the registry of the sessions in my bd. but in the other app im using a spring boot with the same configuration. I'm not able to see any registration of the sessions in my db. After the deploy of my app in a tomcat server and hit any resource example /test/resource im able to see the response correctly but i just want to know if this Persistent Manager Implementation is only for legacy apps? or why is running in one and in the other is not. this is my xml for both jdbcInterceptors="org.apache.tomcat.jdbc.pool.interceptor.ConnectionState; org.apache.tomcat.jdbc.pool.interceptor.StatementFinalizer; org.apache.tomcat.jdbc.pool.interceptor.ResetAbandonedTimer" these 2 are the guides where i learn the mayority how to do it https://svn.apache.org/repos/asf/tomcat/archive/tc4.1.x/trunk/container/catalina/docs/JDBCStore-howto.html https://gerrytan.wordpress.com/2013/08/21/tomcat-7-jdbc-session-persistence/ im going to attach the code that im trying to know why is not working. - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org