Question

Here is my error of my spring-security-loginform-annotation project

I refer that from mkyong site link

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.3.2:compile (default-compile) on project spring-security-loginform-annotation: Compilation failure: Compilation failure:
[ERROR] \Projects\SpringKT\spring-security-custom-login-form-annotation\src\main\java\com\mkyong\config\SecurityConfig.java:[12,7] error: cannot access Filter
[ERROR] \Projects\SpringKT\spring-security-custom-login-form-annotation\src\main\java\com\mkyong\config\core\SpringSecurityInitializer.java:[5,7] error: cannot access ServletException

Here is my details of project

Versions

<spring.version>4.0.6.RELEASE</spring.version>
<spring.security.version>3.2.3.RELEASE</spring.security.version>
<jstl.version>1.2</jstl.version>
<javax.servlet.version>3.1.0</javax.servlet.version>

I run it as like this mvn clean package install jetty:run

But its gives above error

@Configuration
@EnableWebSecurity
public class SecurityConfig extends WebSecurityConfigurerAdapter {//Line 12

public class SpringSecurityInitializer extends AbstractSecurityWebApplicationInitializer {//Line 05
Was it helpful?

Solution

It works, but pom is broken.

When declaring dependency on javax.servlet-api scope is misspelled provider where it should be provided (maven gave me a warning on this before your error).

And no webxml is provided (what is correct), but <failOnMissingWebXml>false</failOnMissingWebXml> is nowhere in pom => maven gave me an error when I had fixed first problem.

I fixed it by adding a new <plugin> declaration in plugins :

  <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-war-plugin</artifactId>
    <version>2.3</version>
    <configuration>
      <failOnMissingWebXml>false</failOnMissingWebXml>
    </configuration>
  </plugin>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top