spring-projects / spring-projects/spring-session

NULL HTTPSessionManager with Jdbc Session Configuration

Open
#1,360 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

status: waiting-for-triage
Dominant language
Java
Stars
1.9k
Forks
1.2k
Avg merge
4h 27m
Merged PRs (30d)
55

Description

I'm using Spring sessionand JDBC for multi session by creating session aliases. Spring boot not included in my application.

sessionManager is NULL when I try to take it as

HttpSessionManager sessionManager =(HttpSessionManager) httpRequest.getAttribute(HttpSessionManager.class.getName());

beans are

    <bean id="dataSource"  class="org.springframework.jndi.JndiObjectFactoryBean">
	<property name="jndiName"
		value="java:comp/env/jdbc/SpringSessionDB" />
</bean>

<bean class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
	<constructor-arg ref="dataSource" />
</bean>
<context:annotation-config />
<bean
	class="org.springframework.session.jdbc.config.annotation.web.http.JdbcHttpSessionConfiguration" />

my web.xml includes filter

    <filter>
	<filter-name>springSessionRepositoryFilter</filter-name>
	<filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
</filter>
<filter-mapping>
	<filter-name>springSessionRepositoryFilter</filter-name>
	<url-pattern>/*</url-pattern>
</filter-mapping>

pom.xml has dependencies

         <dependency>
		<groupId>org.springframework.session</groupId>
		<artifactId>spring-session</artifactId>
		<version>1.3.5.RELEASE</version>
	</dependency>

	<dependency>
		<groupId>org.springframework</groupId>
		<artifactId>spring-webmvc</artifactId>
		<version>5.0.4.RELEASE</version>
	</dependency>
	<dependency>
		<groupId>org.springframework.session</groupId>
		<artifactId>spring-session-jdbc</artifactId>
		<version>2.1.4.RELEASE</version>
	</dependency>

	<dependency>
		<groupId>mysql</groupId>
		<artifactId>mysql-connector-java</artifactId>
		<version>8.0.15</version>
	</dependency>
	<dependency>
		<groupId>org.apache.commons</groupId>
		<artifactId>commons-pool2</artifactId>
		<version>2.4.1</version>
	</dependency>



	<dependency>
		<groupId>javax.servlet</groupId>
		<artifactId>javax.servlet-api</artifactId>
		<version>4.0.0</version>
	</dependency>

Do I need to include any other configuration for session backed by JDBC?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the web.xml springSessionRepositoryFilter and the JdbcHttpSessionConfiguration bean, then compare the spring-session dependencies and versions listed in pom.xml. Reproduce the request that reads HttpSessionManager from HttpSessionManager.class.getName() and determine what configuration is needed for that attribute to be available when JDBC-backed sessions are used.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, mysql, spring
Domain
backend, databases
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.