You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@shiro.apache.org by Les Hazlewood <lh...@apache.org> on 2012/05/15 21:12:49 UTC

Re: Spring / Shiro 'shiroFilter' must be of type [javax.servlet.Filter]

Have you defined the ShiroFilter in web.xml to be a DelegatingFilterProxy?

http://shiro.apache.org/spring.html

If so, what does your web.xml look like?

Cheers,

--
Les Hazlewood
CTO, Stormpath | http://stormpath.com | 888.391.5282
twitter: @lhazlewood | http://twitter.com/lhazlewood
blog: http://leshazlewood.com
stormpath blog: http://www.stormpath.com/blog

On Tue, May 15, 2012 at 7:54 AM, aliasdhacker <an...@gmail.com> wrote:
> I started work on a project that was configured as a web app with a shiro ini
> file.  It was working.  I have integrated and I get the exception at the
> bottom.
>
> I checked out the spring sample projected and tried to run it, I get the
> same error, must be of type javax.servlet.Filter.
>
> AppContext(from sample app)  This gives me the error.
> http://pastebin.com/kF4c3yRE
>
> Web.xml (From sample proj.)  This gives me the error.
> http://pastebin.com/85Bc1kZH
>
> Running JDK 64bit, 1.6.0_32
> Tomcat 6.0.35 and 5.5.35
> Windows 7 64 bit
> IDE - Spring tools suite
> (SpringSource Tool Suite
> Version: 2.9.1.RELEASE
> Build Id: 201203221000)
>
> May 15, 2012 10:09:14 AM org.apache.catalina.core.AprLifecycleListener init
> INFO: The APR based Apache Tomcat Native library which allows optimal
> performance in production environments was not found on the
> java.library.path: C:\Program
> Files\Java\jdk1.6.0_32\bin;C:\Windows\Sun\Java\bin;C:\Windows\system32;C:\Windows;C:\Program
> Files (x86)\NVIDIA
> Corporation\PhysX\Common;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program
> Files\Mercurial\;g:\Program Files (x86)\Git\cmd;g:\Program Files
> (x86)\Git\bin;C:\Program Files (x86)\OpenVPN\bin;.
> May 15, 2012 10:09:14 AM org.apache.tomcat.util.digester.SetPropertiesRule
> begin
> WARNING: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting
> property 'source' to 'org.eclipse.jst.jee.server:XXXXXXXXXXXX_UserPortal'
> did not find a matching property.
> May 15, 2012 10:09:15 AM org.apache.coyote.http11.Http11Protocol init
> INFO: Initializing Coyote HTTP/1.1 on http-8080
> May 15, 2012 10:09:15 AM org.apache.catalina.startup.Catalina load
> INFO: Initialization processed in 931 ms
> May 15, 2012 10:09:15 AM org.apache.catalina.core.StandardService start
> INFO: Starting service Catalina
> May 15, 2012 10:09:15 AM org.apache.catalina.core.StandardEngine start
> INFO: Starting Servlet Engine: Apache Tomcat/6.0.35
> May 15, 2012 10:09:16 AM org.apache.catalina.loader.WebappClassLoader
> validateJarFile
> INFO:
> validateJarFile(C:\Users\aliasdhacker\Documents\workspace-sts-2.9.1.RELEASE\.metadata\.plugins\org.eclipse.wst.server.core\tmp2\wtpwebapps\XXXXXXXXXXX_UserPortal\WEB-INF\lib\Commons.jar)
> - jar not loaded. See Servlet Spec 2.3, section 9.7.2. Offending class:
> javax/servlet/Servlet.class
> May 15, 2012 10:09:16 AM org.apache.catalina.core.ApplicationContext log
> INFO: Set web app root system property: 'spring-sample.webapp.root' =
> [C:\Users\aliasdhacker\Documents\workspace-sts-2.9.1.RELEASE\.metadata\.plugins\org.eclipse.wst.server.core\tmp2\wtpwebapps\XXXXXXXXX_UserPortal\]
> SLF4J: Class path contains multiple SLF4J bindings.
> SLF4J: Found binding in
> [jar:file:/C:/Users/aliasdhacker/Documents/Jobs-ImportantInfo/XXXXXXX/apache-tomcat-6.0.35-instance1/lib/slf4j-log4j12-1.6.4.jar!/org/slf4j/impl/StaticLoggerBinder.class]
> SLF4J: Found binding in
> [jar:file:/C:/Users/aliasdhacker/Documents/workspace-sts-2.9.1.RELEASE/.metadata/.plugins/org.eclipse.wst.server.core/tmp2/wtpwebapps/XXXXXXXXXXXXX_UserPortal/WEB-INF/lib/slf4j-log4j12-1.5.10.jar!/org/slf4j/impl/StaticLoggerBinder.class]
> SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an
> explanation.
> May 15, 2012 10:09:16 AM org.apache.catalina.core.ApplicationContext log
> INFO: Initializing Spring root WebApplicationContext
> INFO : org.springframework.web.context.ContextLoader - Root
> WebApplicationContext: initialization started
> INFO : org.springframework.web.context.support.XmlWebApplicationContext -
> Refreshing Root WebApplicationContext: startup date [Tue May 15 10:09:16 EDT
> 2012]; root of context hierarchy
> INFO : org.springframework.beans.factory.xml.XmlBeanDefinitionReader -
> Loading XML bean definitions from ServletContext resource
> [/WEB-INF/applicationContext.xml]
> log4j:ERROR A "org.apache.log4j.xml.DOMConfigurator" object is not
> assignable to a "org.apache.log4j.spi.Configurator" variable.
> log4j:ERROR The class "org.apache.log4j.spi.Configurator" was loaded by
> log4j:ERROR [org.apache.catalina.loader.StandardClassLoader@5a5e5a50]
> whereas object of type
> log4j:ERROR "org.apache.log4j.xml.DOMConfigurator" was loaded by
> [WebappClassLoader
>  context: /XXXXXXXXXXX_UserPortal
>  delegate: false
>  repositories:
>    /WEB-INF/classes/
> ----------> Parent Classloader:
> org.apache.catalina.loader.StandardClassLoader@5a5e5a50
> ].
> log4j:ERROR Could not instantiate configurator
> [org.apache.log4j.xml.DOMConfigurator].
> INFO : org.springframework.web.context.support.XmlWebApplicationContext -
> Bean 'lifecycleBeanPostProcessor' of type [class
> org.apache.shiro.spring.LifecycleBeanPostProcessor] is not eligible for
> getting processed by all BeanPostProcessors (for example: not eligible for
> auto-proxying)
> INFO : org.springframework.beans.factory.support.DefaultListableBeanFactory
> - Pre-instantiating singletons in
> org.springframework.beans.factory.support.DefaultListableBeanFactory@2825491d:
> defining beans
> [dataSource,bootstrapDataPopulator,securityManager,cacheManager,jdbcRealm,lifecycleBeanPostProcessor,org.springframework.aop.framework.autoproxy.DefaultAdvisorAutoProxyCreator#0,org.apache.shiro.spring.security.interceptor.AuthorizationAttributeSourceAdvisor#0,secureRemoteInvocationExecutor,shiroFilter];
> root of factory hierarchy
> log4j:WARN No appenders could be found for logger
> (org.springframework.jdbc.datasource.DriverManagerDataSource).
> log4j:WARN Please initialize the log4j system properly.
> log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for
> more info.
> INFO : org.springframework.web.context.ContextLoader - Root
> WebApplicationContext: initialization completed in 1476 ms
> May 15, 2012 10:09:18 AM org.apache.catalina.core.StandardContext
> filterStart
> SEVERE: Exception starting filter shiroFilter
> org.springframework.beans.factory.BeanNotOfRequiredTypeException: Bean named
> 'shiroFilter' must be of type [javax.servlet.Filter], but was actually of
> type [org.apache.shiro.spring.web.ShiroFilterFactoryBean]
>        at
> org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:360)
>        at
> org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
>        at
> org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1097)
>        at
> org.springframework.web.filter.DelegatingFilterProxy.initDelegate(DelegatingFilterProxy.java:326)
>        at
> org.springframework.web.filter.DelegatingFilterProxy.initFilterBean(DelegatingFilterProxy.java:236)
>        at
> org.springframework.web.filter.GenericFilterBean.init(GenericFilterBean.java:194)
>        at
> org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:295)
>        at
> org.apache.catalina.core.ApplicationFilterConfig.setFilterDef(ApplicationFilterConfig.java:422)
>        at
> org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:115)
>        at
> org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:4072)
>        at
> org.apache.catalina.core.StandardContext.start(StandardContext.java:4726)
>        at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1057)
>        at org.apache.catalina.core.StandardHost.start(StandardHost.java:840)
>        at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1057)
>        at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:463)
>        at org.apache.catalina.core.StandardService.start(StandardService.java:525)
>        at org.apache.catalina.core.StandardServer.start(StandardServer.java:754)
>        at org.apache.catalina.startup.Catalina.start(Catalina.java:595)
>        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>        at
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
>        at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
>        at java.lang.reflect.Method.invoke(Method.java:597)
>        at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289)
>        at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)
> May 15, 2012 10:09:18 AM org.apache.catalina.core.StandardContext start
> SEVERE: Error filterStart
> May 15, 2012 10:09:18 AM org.apache.catalina.core.StandardContext start
> SEVERE: Context [/XXXXXXXXX_UserPortal] startup failed due to previous
> errors
> May 15, 2012 10:09:18 AM org.apache.catalina.core.ApplicationContext log
> INFO: Closing Spring root WebApplicationContext
> INFO : org.springframework.web.context.support.XmlWebApplicationContext -
> Closing Root WebApplicationContext: startup date [Tue May 15 10:09:16 EDT
> 2012]; root of context hierarchy
> INFO : org.springframework.beans.factory.support.DefaultListableBeanFactory
> - Destroying singletons in
> org.springframework.beans.factory.support.DefaultListableBeanFactory@2825491d:
> defining beans
> [dataSource,bootstrapDataPopulator,securityManager,cacheManager,jdbcRealm,lifecycleBeanPostProcessor,org.springframework.aop.framework.autoproxy.DefaultAdvisorAutoProxyCreator#0,org.apache.shiro.spring.security.interceptor.AuthorizationAttributeSourceAdvisor#0,secureRemoteInvocationExecutor,shiroFilter];
> root of factory hierarchy
> May 15, 2012 10:09:18 AM org.apache.catalina.core.ApplicationContext log
> INFO: Shutting down log4j
> May 15, 2012 10:09:18 AM org.apache.catalina.loader.WebappClassLoader
> clearReferencesThreads
> SEVERE: The web application [/XXXXXXXXXX_UserPortal] appears to have started
> a thread named [net.sf.ehcache.CacheManager@11c19919] but has failed to stop
> it. This is very likely to create a memory leak.
> May 15, 2012 10:09:18 AM org.apache.catalina.loader.WebappClassLoader
> clearReferencesThreads
> SEVERE: The web application [/XXXXXXXX_UserPortal] appears to have started a
> thread named [org.apache.shiro.realm.text.PropertiesRealm-0-accounts.data]
> but has failed to stop it. This is very likely to create a memory leak.
> May 15, 2012 10:09:18 AM org.apache.catalina.loader.WebappClassLoader
> clearReferencesThreads
> SEVERE: The web application [/XXXXXXXXX_UserPortal] appears to have started
> a thread named [shiro-activeSessionCache.data] but has failed to stop it.
> This is very likely to create a memory leak.
> May 15, 2012 10:09:18 AM org.apache.coyote.http11.Http11Protocol start
> INFO: Starting Coyote HTTP/1.1 on http-8080
> May 15, 2012 10:09:18 AM org.apache.jk.common.ChannelSocket init
> INFO: JK: ajp13 listening on /0.0.0.0:8009
> May 15, 2012 10:09:18 AM org.apache.jk.server.JkMain start
> INFO: Jk running ID=0 time=0/213  config=null
> May 15, 2012 10:09:18 AM org.apache.catalina.startup.Catalina start
> INFO: Server startup in 3591 ms
>
>
> --
> View this message in context: http://shiro-user.582556.n2.nabble.com/Spring-Shiro-shiroFilter-must-be-of-type-javax-servlet-Filter-tp7560045.html
> Sent from the Shiro User mailing list archive at Nabble.com.

Re: Spring / Shiro 'shiroFilter' must be of type [javax.servlet.Filter]

Posted by aliasdhacker <an...@gmail.com>.
Wonderful suggestion Jared Bunting.  It was indeed a classpath duplicate
dependency issue.  I have resolved it by cleaning out my class path and
verifying only one of each spring lib and one of each shiro lib (required
libs)

Thanks again!

--
View this message in context: http://shiro-user.582556.n2.nabble.com/Spring-Shiro-shiroFilter-must-be-of-type-javax-servlet-Filter-tp7560045p7562439.html
Sent from the Shiro User mailing list archive at Nabble.com.

Re: Spring / Shiro 'shiroFilter' must be of type [javax.servlet.Filter]

Posted by Jared Bunting <ja...@peachjean.com>.
For some reason, Spring is not recognizing ShiroFilterFactoryBean as a 
factory bean.  It seems likely that there is a classpath issue here 
(ShiroFilterFactoryBean's super class being in a different classloader 
from the ApplicationContext).  Do the spring jars exist in more than 
one place in your classpath?  (war, tomcat itself, eclipse?)  Is there 
anything interesting about the way that you're running tomcat?

It looks like a classpath issue, but given my lack of recent experience 
with tomcat, eclipse, and spring, that's probably as much assistance as 
I can give.

-Jared

On Tue 15 May 2012 04:24:16 PM CDT, aliasdhacker wrote:
> I  have, thank you.   The web.xml pastebin link is in the original post.
>
> --
> View this message in context: http://shiro-user.582556.n2.nabble.com/Spring-Shiro-shiroFilter-must-be-of-type-javax-servlet-Filter-tp7560045p7560743.html
> Sent from the Shiro User mailing list archive at Nabble.com.



Re: Spring / Shiro 'shiroFilter' must be of type [javax.servlet.Filter]

Posted by aliasdhacker <an...@gmail.com>.
I  have, thank you.   The web.xml pastebin link is in the original post.

--
View this message in context: http://shiro-user.582556.n2.nabble.com/Spring-Shiro-shiroFilter-must-be-of-type-javax-servlet-Filter-tp7560045p7560743.html
Sent from the Shiro User mailing list archive at Nabble.com.