Back Forum Reply New

class not found SecurityContextHolderAwareRequestFilter

hey all.  i'm just getting started with spring security, but i keep getting this error:

java.lang.NoClassDefFoundError: org//security/web/wrapper/SecurityContextHolderAwareRequestFilter

Normally, this is an easy fix.  But, if i go to jarvana/ to located the jar it's in, it doesn't exist (at least a version of the one with this particular package name org..security.web.wrapper).  In spring security 3.0.0 and above, the package is:

org..security.web.servletapi

In spring security versions less than 3.0.0, the package is:

org..security.wrapper

Both of these don't match the package that I'm getting complaints about. What gives?

Do you have the spring-security-web jar ? maven2/org/sp....5.RELEASE.jar

what is the spring security version you are using?

yeah, i have that jar.  i'm using spring security 3.0.0.RELEASE.  here's my pom:HTML Code:
lt;project xmlns=quotOM/4.0.0quot; xmlns:xsi=quot;2001/XMLSchema-instancequot; xsi:schemaLocation=quotOM/4.0.0 maven-v4_0_0.xsdquot;gt; lt;modelVersiongt;4.0.0lt;/modelVersiongt; lt;groupIdgt;edu.ucd.gslt;/groupIdgt; lt;artifactIdgt;springapplt;/artifactIdgt; lt;packaginggt;warlt;/packaginggt; lt;versiongt;0.0.1-SNAPSHOTlt;/versiongt; lt;namegt;springapp Maven Webapplt;/namegt; lt;uclgt;uclgt; lt;propertiesgt;   lt;org..versiongt;3.0.0.RELEASElt;/org..versiongt;
lt;/propertiesgt; lt;dependenciesgt;    lt;dependencygt;     lt;groupIdgt;junitlt;/groupIdgt;     lt;artifactIdgt;junitlt;/artifactIdgt;     lt;versiongt;3.8.1lt;/versiongt;     lt;scopegt;testlt;/scopegt;   lt;/dependencygt;   lt;dependencygt;  lt;groupIdgt;org.apache.tomcatlt;/groupIdgt;  lt;artifactIdgt;servlet-apilt;/artifactIdgt;  lt;versiongt;6.0.32lt;/versiongt;  lt;scopegt;providedlt;/scopegt;
lt;/dependencygt;
lt;!--
lt;dependencygt;  lt;groupIdgt;org.lt;/groupIdgt;  lt;artifactIdgt;spring-webmvclt;/artifactIdgt;  lt;versiongt;2.5.6lt;/versiongt;
lt;/dependencygt;--gt;lt;dependencygt;  lt;groupIdgt;org.lt;/groupIdgt;  lt;artifactIdgt;spring-webmvclt;/artifactIdgt;  lt;versiongt;${org..version}lt;/versiongt;
lt;/dependencygt;
lt;dependencygt;  lt;groupIdgt;javax.servletlt;/groupIdgt;  lt;artifactIdgt;jstllt;/artifactIdgt;  lt;versiongt;1.2lt;/versiongt;
lt;/dependencygt;
lt;dependencygt;  lt;groupIdgt;log4jlt;/groupIdgt;  lt;artifactIdgt;log4jlt;/artifactIdgt;  lt;versiongt;1.2.9lt;/versiongt;
lt;/dependencygt;
lt;dependencygt;  lt;groupIdgt;commons-dbcplt;/groupIdgt;  lt;artifactIdgt;commons-dbcplt;/artifactIdgt;  lt;versiongt;1.4lt;/versiongt;
lt;/dependencygt;
lt;dependencygt;  lt;groupIdgt;mysqllt;/groupIdgt;  lt;artifactIdgt;mysql-connector-javalt;/artifactIdgt;  lt;versiongt;5.1.14lt;/versiongt;
lt;/dependencygt;
lt;!--
lt;dependencygt;  lt;groupIdgt;org.lt;/groupIdgt;  lt;artifactIdgt;springlt;/artifactIdgt;  lt;versiongt;2.5.6lt;/versiongt;
lt;/dependencygt;--gt;lt;dependencygt; lt;groupIdgt;org.lt;/groupIdgt; lt;artifactIdgt;spring-corelt;/artifactIdgt; lt;versiongt;${org..version}lt;/versiongt;
lt;/dependencygt;
lt;dependencygt; lt;groupIdgt;org.lt;/groupIdgt; lt;artifactIdgt;spring-jdbclt;/artifactIdgt; lt;versiongt;${org..version}lt;/versiongt;
lt;/dependencygt;
lt;dependencygt;  lt;groupIdgt;org..securitylt;/groupIdgt;  lt;artifactIdgt;spring-security-configlt;/artifactIdgt;  lt;versiongt;${org..version}lt;/versiongt;  lt;!-- lt;versiongt;3.0.0.M2lt;/versiongt; --gt;
lt;/dependencygt;lt;dependencygt;  lt;groupIdgt;org..securitylt;/groupIdgt;  lt;artifactIdgt;spring-security-corelt;/artifactIdgt;  lt;versiongt;${org..version}lt;/versiongt;
lt;/dependencygt;

lt;dependencygt;  lt;groupIdgt;org..securitylt;/groupIdgt;  lt;artifactIdgt;spring-security-taglibslt;/artifactIdgt;  lt;versiongt;${org..version}lt;/versiongt;
lt;/dependencygt;
lt;dependencygt;  lt;groupIdgt;org..securitylt;/groupIdgt;  lt;artifactIdgt;spring-security-weblt;/artifactIdgt;  lt;versiongt;${org..version}lt;/versiongt;
lt;/dependencygt;
lt;/dependenciesgt; lt;buildgt;   lt;finalNamegt;springapplt;/finalNamegt;   lt;pluginManagementgt;      lt;pluginsgt;        lt;plugingt;       lt;groupIdgt;org.codehaus.mojolt;/groupIdgt;       lt;artifactIdgt;tomcat-maven-pluginlt;/artifactIdgt;       lt;configurationgt;    lt;servergt;localhostlt;/servergt;       lt;/configurationgt;
lt;/plugingt;    lt;/pluginsgt;   lt;/pluginManagementgt; lt;/buildgt;
lt;/projectgt;That package is available in one of the milestones of Spring Security 3 (it got further re-factored before the stable was released). Providing a full stack trace might help to figure out why this is actually happening (please use the code tags). In the meantime I would try cleaning your project and building again. If that does not work try renaming your maven repository at ~/.m2/repository to ensure that you have not downloaded a bad jar. You might also check your maven settings files in the install and your home to ensure there is nothing odd in there (i.e. pointing to a repo that isn't maven central, proxying the repos, etc).

PS You should upgrade Spring and Spring Security to 3.0.5.RELEASE to fix these vulnerabilities.

.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.NoClassDefFoundError: org//security/web/wrapper/SecurityContextHolderAwareRequestFilter
at org..security.config.from.fromSecurityBeanDefinitionParser.createServletApiFilter(fromSecurityBeanDefinitionParser.java:723)
at org..security.config.from.fromSecurityBeanDefinitionParser.parse(fromSecurityBeanDefinitionParser.java:210)
at org..beans.factory.xml.NamespaceHandlerSupport.parse(NamespaceHandlerSupport.java:69)
at org..beans.factory.xml.BeanDefinitionParserDelegate.parseCustomElement(BeanDefinitionParserDelegate.java:1297)
at org..beans.factory.xml.BeanDefinitionParserDelegate.parseCustomElement(BeanDefinitionParserDelegate.java:1287)
at org..beans.factory.xml.DefaultBeanDefinitionDocumentReader.parseBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:135)
at org..beans.factory.xml.DefaultBeanDefinitionDocumentReader.registerBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:92)
at org..beans.factory.xml.XmlBeanDefinitionReader.registerBeanDefinitions(XmlBeanDefinitionReader.java:507)
at org..beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:398)
... 27 morei've also upgraded to Spring and Spring Security 3.0.5.RELEASE

As Rob says, that class doesn't exist in Spring Security 3.0.5. Nor do the methods in the stacktrace you've posted. So if you are seeing this stacktrace then there is another version on your classpath.

Did you check lt;TOMCAT_HOMEgt;/lib/ for other versions?

i finally got it to work.  in my STS quot;targetquot; directory, WEB-INF/lib contained ALOT of duplicate jars:

spring-security-web-3.0.5.RELEASE,
spring-security-web-3.0.4.RELEASE,
spring-security-web-3.0.3.RELEASE,
spring-security-web-3.0.2.RELEASE,
etc.

So, i got rid of the quot;targetquot; directory manually, as opposed to doing Project gt; Clean in STS and that worked like a charm.  Apparently, removing the quot;targetquot; directory isn't something that Project gt; Clean does.  

Thanks guys
¥
Back Forum Reply New