Cannot use BroadcasterCache with Spring security

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Cannot use BroadcasterCache with Spring security

spamskiller
This post has NOT been accepted by the mailing list yet.
Hi all,

Currently I'm using Atmosphere with Spring-MVC, Spring-Security, Tomcat and everything is perfect (Atmosphere 0.9.4, Spring-MVC 3.1.0, Spring-security 3.1.0, Tomcat 7.0.27).

But I have problem when trying to use with broadcasterCache. After client sends a subscribe request message to Tomcat server, the system throws ClassNotFoundException exception:
Caused by: java.lang.RuntimeException: java.lang.ClassNotFoundException: test.chat.atmosphere.cache.EventIdBroadcasterCache
        at org.atmosphere.cpr.BroadcasterConfig.configureBroadcasterCache(BroadcasterConfig.java:130)
        at org.atmosphere.cpr.BroadcasterConfig.<init>(BroadcasterConfig.java:106)
        at org.atmosphere.cpr.BroadcasterConfig.<init>(BroadcasterConfig.java:95)
        at org.atmosphere.cpr.DefaultBroadcaster.createBroadcasterConfig(DefaultBroadcaster.java:165)
        at org.atmosphere.cpr.DefaultBroadcaster.<init>(DefaultBroadcaster.java:143)
        at org.atmosphere.cpr.DefaultBroadcaster.<init>(DefaultBroadcaster.java:155)
        ... 41 more

The root cause is from BroadcasterConfig class, while running with:
BroadcasterCache cache = (BroadcasterCache) Thread.currentThread().getContextClassLoader()
                        .loadClass(AtmosphereFramework.broadcasterCacheClassName).newInstance();

And at this point, cache is null. It seems like Thread.currentThread().getContextClassLoader() didn't use context from Spring.


This is my web.xml:
<listener>
                <listener-class>
                        org.springframework.web.context.ContextLoaderListener
                </listener-class>
        </listener>
<filter>
                <filter-name>springSecurityFilterChain</filter-name>
                <filter-class>org.springframework.web.filter.DelegatingFilterProxy
                </filter-class>
        </filter>
        <filter-mapping>
                <filter-name>springSecurityFilterChain</filter-name>
                <url-pattern>/*</url-pattern>
        </filter-mapping>
<servlet>
                <servlet-name>spring-mvc-dispatcher</servlet-name>
                <servlet-class>org.atmosphere.cpr.MeteorServlet</servlet-class>
                <init-param>
                        <param-name>org.atmosphere.servlet</param-name>
                        <param-value>org.springframework.web.servlet.DispatcherServlet
                        </param-value>
                </init-param>
                <init-param>
                        <param-name>org.atmosphere.cpr.broadcasterClass</param-name>
                        <param-value>org.atmosphere.cpr.DefaultBroadcaster</param-value>
                </init-param>
                <init-param>
                        <param-name>org.atmosphere.cpr.broadcasterCacheClass</param-name>
                        <param-value>test.chat.atmosphere.cache.EventIdBroadcasterCache
                        </param-value>
                </init-param>

                <init-param>
                        <param-name>org.atmosphere.useNative</param-name>
                        <param-value>true</param-value>
                </init-param>
                <init-param>
                        <param-name>org.atmosphere.useWebSocket</param-name>
                        <param-value>true</param-value>
                </init-param>
                <init-param>
                        <param-name>org.atmosphere.useStream</param-name>
                        <param-value>false</param-value>
                </init-param>
                <async-supported>true</async-supported>
                <load-on-startup>1</load-on-startup>
        </servlet>
        <servlet-mapping>
                <servlet-name>spring-mvc-dispatcher</servlet-name>
                <url-pattern>/</url-pattern>
        </servlet-mapping>

I've tried to google but it seems like no one has same issue like me. Please help to check.

Thanks,
SP