Monday, January 19, 2015

Error in packaging Spring security example in Mkyong site


Link for code
http://www.mkyong.com/spring-security/spring-security-custom-login-form-annotation-example/

There are few errors
--------
misspelled of scope in a dependency as ''provider" and exclusion of "web.xml"

I have done the correction is 2 steps.
1. correction of the scope attribute
2. correction for exclusion of web.xml - where this will be looked and the example is done excluding web.xml  - added plugin to ignore web.xml


So again two corrections
--------------
1.

javax.servlet
javax.servlet-api
${javax.servlet.version}
provided


Below is the full trace of the error.

2.

org.apache.maven.plugins
maven-war-plugin
2.3

false



===========

C:\code\Examples\SpringSecurity\Mkyoung\spring-security-helloworld-annotation>mv
n package
[INFO] Scanning for projects...
[WARNING]
[WARNING] Some problems were encountered while building the effective model for
com.mkyong:spring-security-helloworld-annotation:war:1.0-SNAPSHOT
[WARNING] 'dependencies.dependency.scope' for javax.servlet:javax.servlet-api:ja
r must be one of [provided, compile, runtime, test, system] but is 'provider'. @
 line 41, column 11
[WARNING]
[WARNING] It is highly recommended to fix these problems because they threaten t
he stability of your build.
[WARNING]
[WARNING] For this reason, future Maven versions might no longer support buildin
g such malformed projects.
[WARNING]
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building SpringSecurity Hello World XML 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.4.3:resources (default-resources) @ spring-s
ecurity-helloworld-annotation ---
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources,
i.e. build is platform dependent!
[INFO] Copying 0 resource
[INFO]
[INFO] --- maven-compiler-plugin:2.3.2:compile (default-compile) @ spring-securi
ty-helloworld-annotation ---
[WARNING] File encoding has not been set, using platform encoding Cp1252, i.e. b
uild is platform dependent!
[INFO] Compiling 2 source files to C:\code\Examples\SpringSecurity\Mkyoung\sprin
g-security-helloworld-annotation\target\classes
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] \code\Examples\SpringSecurity\Mkyoung\spring-security-helloworld-annotat
ion\src\main\java\com\mkyong\config\core\SpringMvcInitializer.java:[7,7] error:
cannot access ServletException
[INFO] 1 error
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.450s
[INFO] Finished at: Mon Jan 19 15:20:27 IST 2015
[INFO] Final Memory: 10M/75M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.
3.2:compile (default-compile) on project spring-security-helloworld-annotation:
Compilation failure
[ERROR] \code\Examples\SpringSecurity\Mkyoung\spring-security-helloworld-annotat
ion\src\main\java\com\mkyong\config\core\SpringMvcInitializer.java:[7,7] error:
cannot access ServletException
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e swit
ch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please rea
d the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureExc
eption
C:\code\Examples\SpringSecurity\Mkyoung\spring-security-helloworld-annotation>

==========


Errors in POM

1. dependency ' javax.servlet"  scope is mispelled as "provider"  --> should be "provided"


=====
Error after correcting scope

============

[INFO]
[INFO] --- maven-war-plugin:2.1.1:war (default-war) @ spring-security-helloworld-annotation ---
[INFO] Packaging webapp
[INFO] Assembling webapp [spring-security-helloworld-annotation] in [C:\code\Examples\SpringSecurity\Mkyoung\spring-security-helloworld-anno
tation\target\SpringSecurityHelloWorld]
[INFO] Processing war project
[INFO] Copying webapp resources [C:\code\Examples\SpringSecurity\Mkyoung\spring-security-helloworld-annotation\src\main\webapp]
[INFO] Webapp assembled in [1123 msecs]
[INFO] Building war: C:\code\Examples\SpringSecurity\Mkyoung\spring-security-helloworld-annotation\target\SpringSecurityHelloWorld.war
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 7.401s
[INFO] Finished at: Mon Jan 19 15:50:57 IST 2015
[INFO] Final Memory: 13M/109M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-war-plugin:2.1.1:war (default-war) on project spring-security-helloworld-annot
ation: Error assembling WAR: webxml attribute is required (or pre-existing WEB-INF/web.xml if executing in update mode) -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException

==============