0

I am trying to configure spring session 1.1.1 with my spring 3.2.18 based application. Following are dependencies

compile group: 'org.springframework', name: 'spring-context', version: 3.2.18
  ....
compile group: 'org.springframework.integration', name: 'spring-integration-jms', version: '2.0.3.RELEASE'
compile group: 'org.springframework', name: 'spring-jms', version: 3.2.18
compile group: 'org.springframework.security', name: 'spring-security-core', version: 3.1.4.RELEASE
compile group: 'org.springframework.session', name: 'spring-session-data-redis', version: '1.1.1.RELEASE'
compile (group: 'org.apache.commons', name: 'commons-pool2', version: '2.4.2'){
                        force = true
                    }

Following are Spring session configurations in code.

@Configuration
@EnableRedisHttpSession
public class ApplicationConfiguration {

  @Bean
  public JedisConnectionFactory connectionFactory() {
    return new JedisConnectionFactory();
  }

  @Bean
  public JmsTemplate jmsTemplate() {
    JmsTemplate jmsTemplate = new JmsTemplate();
    jmsTemplate.setConnectionFactory(connectionFactory());
    return jmsTemplate;
  }
}

public class SpringSessionInitializer extends AbstractHttpSessionApplicationInitializer {
  public SpringSessionInitializer() {
    super(ApplicationConfiguration.class);
  }
}

I am getting following exception.

Caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire field: private Instantiation of bean failed; nested exception is org.springframework.beans.factory.BeanDefinitionStoreException: Factory method [public org.springframework.jms.core.JmsTemplate com.emaratech.v2015.messaging.configuration.MessagingConfiguration$DevelopmentConfiguration.jmsTemplate()] threw exception; nested exception is java.lang.ClassCastException: org.springframework.data.redis.connection.jedis.JedisConnectionFactory incompatible with javax.jms.ConnectionFactory

That indicates provide JedisConnectionFactory is not compatible with JMS ConnectionFactory. Can you suggest which spring session and Jedis version is compatible with Spring JMS verion 3.2.18? What other configuration will be required to configure it successfully?

  • 1
    You're getting that exception because you're trying to plug JedisConnectionFactory into JmsTemplate. Just like you can't fit a JdbcConnectionFactory for Jedis. They would be doing way different things and communicating to completely different tools – shinjw Oct 15 '17 at 07:31
  • 1
    Indeed; why do you think you can use a `JmsTemplate` to talk to `Redis` ? – Gary Russell Oct 15 '17 at 21:17
  • Sorry It my bad. Thanks for help. – Aamir Latif Oct 16 '17 at 04:54

0 Answers0