I am trying to understand why my checkstyle <allow> rule is not being respected by Maven and am getting the error: src\main\java\com\jon\ttf\adapter\persistence\BaseSqlPersistence.java:[4,1] (imports) ImportControl: Disallowed import - org.sql2o.Sql2o. I have removed most of the code in import-control-error.xml as they are all very similar. Could the problem be somewhere in checkstyle-checks.xml where a certain check is over riding my org.sql2o.Sql2o package?
Let me know if you want me to attach more code
import-control-error.xml
<import-control pkg="com.jon.ttf">
<disallow pkg=".*" regex="true"/>
<allow pkg="org.sql2o.Sql2o"/>
<allow pkg="spark"/>
</import-control>
checkstyle-checks.xml
<?xml version="1.0"?>
<!DOCTYPE module PUBLIC
"-//Puppy Crawl//DTD Check Configuration 1.3//EN"
"http://www.puppycrawl.com/dtds/configuration_1_3.dtd">
<module name="Checker">
<module name="SuppressWarningsFilter"/>
<property name="charset" value="UTF-8"/>
<property name="severity" value="warning"/>
<property name="fileExtensions" value="java, properties, xml"/>
<module name="TreeWalker">
<module name="RegexpSinglelineJava">
<property name="format" value="^\t* "/>
<property name="message" value="Indent must use tab characters"/>
<property name="ignoreComments" value="true"/>
</module>
<module name="SuppressWarningsHolder"/>
<module name="UnusedImports">
<property name="severity" value="error"/>
</module>
<module name="OuterTypeFilename"/>
<module name="ImportControl">
<property name="severity" value="error"/>
<property name="file" value="import-control-error.xml"/>
</module>
<module name="IllegalTokenText">
<property name="tokens" value="STRING_LITERAL, CHAR_LITERAL"/>
<property name="format"
value="\\u00(08|09|0(a|A)|0(c|C)|0(d|D)|22|27|5(C|c))|\\(0(10|11|12|14|15|42|47)|134)"/>
<property name="message" value="Avoid using corresponding octal or Unicode escape."/>
</module>
<module name="AvoidEscapedUnicodeCharacters">
<property name="allowEscapesForControlCharacters" value="true"/>
<property name="allowByTailComment" value="true"/>
<property name="allowNonPrintableEscapes" value="true"/>
</module>
<module name="LineLength">
<property name="severity" value="error"/>
<property name="max" value="300"/>
<property name="ignorePattern" value="^package.*|^import.*|a href|href|http://|https://|ftp://"/>
</module>
<module name="AvoidStarImport">
<property name="severity" value="error"/>
<property name="allowStaticMemberImports" value="true"/>
</module>
<module name="OneTopLevelClass"/>
<module name="NoLineWrap"/>
<module name="EmptyBlock">
<property name="option" value="TEXT"/>
<property name="tokens" value="LITERAL_TRY, LITERAL_FINALLY, LITERAL_IF, LITERAL_ELSE, LITERAL_SWITCH"/>
</module>
<module name="NeedBraces">
<property name="severity" value="error"/>
</module>
<module name="LeftCurly"/>
<module name="RightCurly">
<property name="option" value="alone"/>
<property name="tokens"
value="CLASS_DEF, METHOD_DEF, CTOR_DEF, LITERAL_FOR, LITERAL_WHILE, LITERAL_DO, STATIC_INIT, INSTANCE_INIT"/>
</module>
<module name="EqualsHashCode">
<property name="severity" value="error"/>
</module>
<module name="WhitespaceAround">
<property name="severity" value="error"/>
<property name="allowEmptyConstructors" value="true"/>
<property name="allowEmptyMethods" value="true"/>
<property name="allowEmptyTypes" value="true"/>
<property name="allowEmptyLoops" value="true"/>
<message key="ws.notFollowed"
value="WhitespaceAround: ''{0}'' is not followed by whitespace. Empty blocks may only be represented as '{}' when not part of a multi-block statement (4.1.3)"/>
<message key="ws.notPreceded"
value="WhitespaceAround: ''{0}'' is not preceded with whitespace."/>
</module>
<module name="OneStatementPerLine">
<property name="severity" value="error"/>
</module>
<module name="MultipleVariableDeclarations">
<property name="severity" value="error"/>
</module>
<module name="ArrayTypeStyle">
<property name="severity" value="error"/>
</module>
<module name="MissingSwitchDefault">
<property name="severity" value="error"/>
</module>
<module name="FallThrough">
<property name="severity" value="error"/>
</module>
<module name="UpperEll">
<property name="severity" value="error"/>
</module>
<module name="EmptyLineSeparator">
<property name="severity" value="error"/>
<property name="allowNoEmptyLineBetweenFields" value="true"/>
</module>
<module name="SeparatorWrap">
<property name="severity" value="error"/>
<property name="tokens" value="DOT"/>
<property name="option" value="nl"/>
</module>
<module name="SeparatorWrap">
<property name="severity" value="error"/>
<property name="tokens" value="COMMA"/>
<property name="option" value="EOL"/>
</module>
<module name="PackageName">
<property name="severity" value="error"/>
<property name="format" value="^[a-z]+(\.[a-z][a-z0-9]*)*$"/>
<message key="name.invalidPattern"
value="Package name ''{0}'' must match pattern ''{1}''."/>
</module>
<module name="TypeName">
<property name="severity" value="error"/>
<message key="name.invalidPattern"
value="Type name ''{0}'' must match pattern ''{1}''."/>
</module>
<module name="MethodTypeParameterName">
<property name="severity" value="error"/>
<property name="format" value="(^[A-Z][0-9]?)$|([A-Z][a-zA-Z0-9]*[T]$)"/>
<message key="name.invalidPattern"
value="Method type name ''{0}'' must match pattern ''{1}''."/>
</module>
<module name="InterfaceTypeParameterName">
<property name="severity" value="error"/>
<property name="format" value="(^[A-Z][0-9]?)$|([A-Z][a-zA-Z0-9]*[T]$)"/>
<message key="name.invalidPattern"
value="Interface type name ''{0}'' must match pattern ''{1}''."/>
</module>
<module name="NoFinalizer">
<property name="severity" value="error"/>
</module>
<module name="GenericWhitespace">
<property name="severity" value="error"/>
<message key="ws.followed"
value="GenericWhitespace ''{0}'' is followed by whitespace."/>
<message key="ws.preceded"
value="GenericWhitespace ''{0}'' is preceded with whitespace."/>
<message key="ws.illegalFollow"
value="GenericWhitespace ''{0}'' should followed by whitespace."/>
<message key="ws.notPreceded"
value="GenericWhitespace ''{0}'' is not preceded with whitespace."/>
</module>
<module name="Indentation">
<property name="severity" value="error"/>
<property name="basicOffset" value="8"/>
<property name="braceAdjustment" value="0"/>
<property name="caseIndent" value="8"/>
<property name="throwsIndent" value="8"/>
<property name="lineWrappingIndentation" value="8"/>
<property name="arrayInitIndent" value="16"/>
</module>
<module name="MethodName">
<property name="severity" value="error"/>
<property name="format" value="^[a-z][a-z0-9][a-zA-Z0-9_]*$"/>
<message key="name.invalidPattern" value="Method name ''{0}'' must match pattern ''{1}''."/>
</module>
<module name="EmptyCatchBlock">
<property name="severity" value="error"/>
</module>
</module>
</module>
am getting the error: BaseSqlPersistence.java:[4,1] (imports) ImportControl: Disallowed import - org.sql2o.Sql2o
import-control-error.xml
<disallow pkg=".*" regex="true"/>
<allow pkg="org.sql2o.Sql2o"/>
The order of rules for ImportControl is the same order as defined in the XML file. Since the .* is defined first, that means all imports are disallowed. If you remove this or move it to the bottom, then it should work as expected.
If you are trying to disallow all imports that aren't allowed, then this is the default behavior of ImportControl and the specific disallow isn't needed.
You can find more information at http://checkstyle.sourceforge.net/config_imports.html#ImportControl_Description
Order of rules in the same subpackage/root are defined by the order of declaration in the XML file, which is from top (first) to bottom (last).
As a final note,
<allow pkg="org.sql2o.Sql2o"/>
This is a class, not a package. If you are allowing the package, you must define it as org.sql2o. If you are allowing the class, it must be defined as <allow class="org.sql2o.Sql2o"/>.
I have the following checkstyle.xml file inside the confg/checkstyle directory of my project. I am using gradle (v3.4) and its relevant sections are copied below along with the error message I receive when I run gradle build (rootDir has not been set). How do I go about passing the rootDir to the checkstyle plugin?
error
Execution failed for task ':checkstyleMain'.
> Unable to create a Checker: unable to read /abc/def/ghi/jkl/config/checkstyle/checkstyle.xml - unable to parse configuration stream - Property ${rootDir} has not been set
build.gradle
apply plugin: 'checkstyle'
//tried with and without the below
checkstyle {
ignoreFailures = true
configFile = file("config/checkstyle/checkstyle.xml")
}
checkstyle.xml
<?xml version="1.0"?>
<!DOCTYPE module PUBLIC
"-//Puppy Crawl//DTD Check Configuration 1.3//EN"
"http://www.puppycrawl.com/dtds/configuration_1_3.dtd">
<!--
Checkstyle configuration that checks the Google coding conventions from Google Java Style
that can be found at https://google.github.io/styleguide/javaguide.html.
Checkstyle is very configurable. Be sure to read the documentation at
http://checkstyle.sf.net (or in your downloaded distribution).
To completely disable a check, just comment it out or delete it from the file.
Authors: Max Vetrenko, Ruslan Diachenko, Roman Ivanov.
-->
<module name = "Checker">
<property name="charset" value="UTF-8"/>
<property name="severity" value="error"/>
<module name="Header">
<property name="headerFile" value="${rootDir}/checkstyle.license"/>
<property name="ignoreLines" value="2"/>
<property name="fileExtensions" value="java"/>
</module>
<property name="fileExtensions" value="java, properties, xml"/>
<!-- Checks for whitespace -->
<!-- See http://checkstyle.sf.net/config_whitespace.html -->
<module name="FileTabCharacter">
<property name="eachLine" value="true"/>
</module>
<module name="TreeWalker">
<module name="OuterTypeFilename"/>
<module name="IllegalTokenText">
<property name="tokens" value="STRING_LITERAL, CHAR_LITERAL"/>
<property name="format" value="\\u00(08|09|0(a|A)|0(c|C)|0(d|D)|22|27|5(C|c))|\\(0(10|11|12|14|15|42|47)|134)"/>
<property name="message" value="Avoid using corresponding octal or Unicode escape."/>
</module>
<module name="AvoidEscapedUnicodeCharacters">
<property name="allowEscapesForControlCharacters" value="true"/>
<property name="allowByTailComment" value="true"/>
<property name="allowNonPrintableEscapes" value="true"/>
</module>
<module name="LineLength">
<property name="max" value="100"/>
<property name="ignorePattern" value="^package.*|^import.*|a href|href|http://|https://|ftp://"/>
</module>
<module name="AvoidStarImport"/>
<!-- TODO(ejona): Upstream? -->
<module name="UnusedImports"/>
<module name="OneTopLevelClass"/>
<module name="NoLineWrap"/>
<module name="EmptyBlock">
<property name="option" value="TEXT"/>
<property name="tokens" value="LITERAL_TRY, LITERAL_FINALLY, LITERAL_IF, LITERAL_ELSE, LITERAL_SWITCH"/>
</module>
<module name="NeedBraces"/>
<module name="LeftCurly">
<property name="maxLineLength" value="100"/>
</module>
<module name="RightCurly"/>
<module name="RightCurly">
<property name="option" value="alone"/>
<property name="tokens" value="CLASS_DEF, METHOD_DEF, CTOR_DEF, LITERAL_FOR, LITERAL_WHILE, LITERAL_DO, STATIC_INIT, INSTANCE_INIT"/>
</module>
<module name="WhitespaceAround">
<property name="allowEmptyConstructors" value="true"/>
<property name="allowEmptyMethods" value="true"/>
<property name="allowEmptyTypes" value="true"/>
<property name="allowEmptyLoops" value="true"/>
<message key="ws.notFollowed"
value="WhitespaceAround: ''{0}'' is not followed by whitespace. Empty blocks may only be represented as '{}' when not part of a multi-block statement (4.1.3)"/>
<message key="ws.notPreceded"
value="WhitespaceAround: ''{0}'' is not preceded with whitespace."/>
</module>
<module name="OneStatementPerLine"/>
<module name="MultipleVariableDeclarations"/>
<module name="ArrayTypeStyle"/>
<module name="MissingSwitchDefault"/>
<module name="FallThrough"/>
<module name="UpperEll"/>
<module name="ModifierOrder"/>
<module name="EmptyLineSeparator">
<property name="allowNoEmptyLineBetweenFields" value="true"/>
</module>
<module name="SeparatorWrap">
<property name="tokens" value="DOT"/>
<property name="option" value="nl"/>
</module>
<module name="SeparatorWrap">
<property name="tokens" value="COMMA"/>
<property name="option" value="EOL"/>
</module>
<module name="PackageName">
<property name="format" value="^[a-z]+(\.[a-z][a-z0-9]*)*$"/>
<message key="name.invalidPattern"
value="Package name ''{0}'' must match pattern ''{1}''."/>
</module>
<module name="TypeName">
<message key="name.invalidPattern"
value="Type name ''{0}'' must match pattern ''{1}''."/>
</module>
<module name="MemberName">
<property name="format" value="^[a-z][a-z0-9][a-zA-Z0-9]*$"/>
<message key="name.invalidPattern"
value="Member name ''{0}'' must match pattern ''{1}''."/>
</module>
<module name="ParameterName">
<!-- TODO(ejona): too strict, as one-character parameter names are permitted
<property name="format" value="^[a-z][a-z0-9][a-zA-Z0-9]*$"/-->
<property name="format" value="^[a-z][a-zA-Z0-9]*$"/>
<message key="name.invalidPattern"
value="Parameter name ''{0}'' must match pattern ''{1}''."/>
</module>
<module name="CatchParameterName">
<!-- TODO(ejona): too strict, as one-character parameter names are permitted.
<property name="format" value="^[a-z][a-z0-9][a-zA-Z0-9]*$"/-->
<property name="format" value="^[a-z][a-zA-Z0-9]*$"/>
<message key="name.invalidPattern"
value="Catch parameter name ''{0}'' must match pattern ''{1}''."/>
</module>
<module name="LocalVariableName">
<property name="tokens" value="VARIABLE_DEF"/>
<!-- TODO(ejona): too strict, as one-character parameter names are permitted.
Add support for Unicode.
<property name="format" value="^[a-z][a-z0-9][a-zA-Z0-9]*$"/-->
<property name="format" value="^[^A-Z]"/>
<property name="allowOneCharVarInForLoop" value="true"/>
<message key="name.invalidPattern"
value="Local variable name ''{0}'' must match pattern ''{1}''."/>
</module>
<module name="ClassTypeParameterName">
<property name="format" value="(^[A-Z][0-9]?)$|([A-Z][a-zA-Z0-9]*[T]$)"/>
<message key="name.invalidPattern"
value="Class type name ''{0}'' must match pattern ''{1}''."/>
</module>
<module name="MethodTypeParameterName">
<property name="format" value="(^[A-Z][0-9]?)$|([A-Z][a-zA-Z0-9]*[T]$)"/>
<message key="name.invalidPattern"
value="Method type name ''{0}'' must match pattern ''{1}''."/>
</module>
<module name="InterfaceTypeParameterName">
<property name="format" value="(^[A-Z][0-9]?)$|([A-Z][a-zA-Z0-9]*[T]$)"/>
<message key="name.invalidPattern"
value="Interface type name ''{0}'' must match pattern ''{1}''."/>
</module>
<module name="NoFinalizer"/>
<module name="GenericWhitespace">
<message key="ws.followed"
value="GenericWhitespace ''{0}'' is followed by whitespace."/>
<message key="ws.preceded"
value="GenericWhitespace ''{0}'' is preceded with whitespace."/>
<message key="ws.illegalFollow"
value="GenericWhitespace ''{0}'' should followed by whitespace."/>
<message key="ws.notPreceded"
value="GenericWhitespace ''{0}'' is not preceded with whitespace."/>
</module>
<module name="Indentation">
<property name="basicOffset" value="2"/>
<property name="braceAdjustment" value="0"/>
<property name="caseIndent" value="2"/>
<property name="throwsIndent" value="4"/>
<property name="lineWrappingIndentation" value="4"/>
<property name="arrayInitIndent" value="2"/>
</module>
<module name="AbbreviationAsWordInName">
<property name="ignoreFinal" value="false"/>
<property name="allowedAbbreviationLength" value="1"/>
</module>
<module name="OverloadMethodsDeclarationOrder"/>
<!-- TODO(ejona): Does not consider assignment during declaration as a usage.
<module name="VariableDeclarationUsageDistance"/-->
<module name="CustomImportOrder">
<property name="specialImportsRegExp" value="com.google"/>
<property name="sortImportsInGroupAlphabetically" value="true"/>
<property name="customImportOrderRules" value="STATIC###SPECIAL_IMPORTS###THIRD_PARTY_PACKAGE###STANDARD_JAVA_PACKAGE"/>
</module>
<module name="MethodParamPad"/>
<module name="OperatorWrap">
<property name="option" value="NL"/>
<property name="tokens" value="BAND, BOR, BSR, BXOR, DIV, EQUAL, GE, GT, LAND, LE, LITERAL_INSTANCEOF, LOR, LT, MINUS, MOD, NOT_EQUAL, PLUS, QUESTION, SL, SR, STAR "/>
</module>
<module name="AnnotationLocation">
<property name="tokens" value="CLASS_DEF, INTERFACE_DEF, ENUM_DEF, METHOD_DEF, CTOR_DEF"/>
</module>
<module name="AnnotationLocation">
<property name="tokens" value="VARIABLE_DEF"/>
<property name="allowSamelineMultipleAnnotations" value="true"/>
</module>
<module name="NonEmptyAtclauseDescription"/>
<module name="JavadocTagContinuationIndentation"/>
<module name="SummaryJavadoc">
<property name="forbiddenSummaryFragments" value="^#return the *|^This method returns |^A [{]#code [a-zA-Z0-9]+[}]( is a )"/>
</module>
<module name="JavadocParagraph"/>
<module name="AtclauseOrder">
<property name="tagOrder" value="#param, #return, #throws, #deprecated"/>
<property name="target" value="CLASS_DEF, INTERFACE_DEF, ENUM_DEF, METHOD_DEF, CTOR_DEF, VARIABLE_DEF"/>
</module>
<module name="JavadocMethod">
<property name="scope" value="public"/>
<property name="allowMissingParamTags" value="true"/>
<property name="allowMissingThrowsTags" value="true"/>
<property name="allowMissingReturnTag" value="true"/>
<property name="minLineCount" value="2"/>
<!-- TOOD(ejona): Too restrictive for tests
<property name="allowedAnnotations" value="Override, Test"/-->
<property name="allowedAnnotations" value="Override, Test, Before, After, BeforeClass, AfterClass, Setup, TearDown"/>
<property name="allowThrowsTagsForSubclasses" value="true"/>
</module>
<module name="MethodName">
<property name="format" value="^[a-z][a-z0-9][a-zA-Z0-9_]*$"/>
<message key="name.invalidPattern"
value="Method name ''{0}'' must match pattern ''{1}''."/>
</module>
<module name="SingleLineJavadoc">
<!-- TODO(ejona): Based on mis-reading of style; consider upstreaming
<property name="ignoreInlineTags" value="false"/-->
</module>
<module name="EmptyCatchBlock">
<property name="exceptionVariableName" value="expected"/>
</module>
<module name="CommentsIndentation"/>
</module>
</module>
I simply replaced the checkstyle.xml file (which does not need the rootDir to be used in the xml file. Running gradle build works fine with checkstyle now.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE module PUBLIC
"-//Puppy Crawl//DTD Check Configuration 1.3//EN"
"http://www.puppycrawl.com/dtds/configuration_1_3.dtd">
<!-- This is a checkstyle configuration file. For descriptions of
what the following rules do, please see the checkstyle configuration
page at http://checkstyle.sourceforge.net/config.html -->
<module name="Checker">
<module name="FileTabCharacter">
<!-- Checks that there are no tab characters in the file.
-->
</module>
<module name="NewlineAtEndOfFile">
<property name="lineSeparator" value="lf"/>
</module>
<module name="RegexpSingleline">
<!-- Checks that FIXME is not used in comments. TODO is preferred.
-->
<property name="format" value="((//.*)|(\*.*))FIXME" />
<property name="message" value='TODO is preferred to FIXME. e.g. "TODO(johndoe): Refactor when v2 is released."' />
</module>
<module name="RegexpSingleline">
<!-- Checks that TODOs are named. (Actually, just that they are followed
by an open paren.)
-->
<property name="format" value="((//.*)|(\*.*))TODO[^(]" />
<property name="message" value='All TODOs should be named. e.g. "TODO(johndoe): Refactor when v2 is released."' />
</module>
<module name="JavadocPackage">
<!-- Checks that each Java package has a Javadoc file used for commenting.
Only allows a package-info.java, not package.html. -->
</module>
<!-- All Java AST specific tests live under TreeWalker module. -->
<module name="TreeWalker">
<!--
IMPORT CHECKS
-->
<module name="RedundantImport">
<!-- Checks for redundant import statements. -->
<property name="severity" value="error"/>
</module>
<module name="ImportOrder">
<!-- Checks for out of order import statements. -->
<property name="severity" value="warning"/>
<property name="groups" value="com.google,android,junit,net,org,java,javax"/>
<!-- This ensures that static imports go first. -->
<property name="option" value="top"/>
<property name="tokens" value="STATIC_IMPORT, IMPORT"/>
</module>
<!--
JAVADOC CHECKS
-->
<!-- Checks for Javadoc comments. -->
<!-- See http://checkstyle.sf.net/config_javadoc.html -->
<module name="JavadocMethod">
<property name="scope" value="protected"/>
<property name="severity" value="warning"/>
<property name="allowMissingJavadoc" value="true"/>
<property name="allowMissingParamTags" value="true"/>
<property name="allowMissingReturnTag" value="true"/>
<property name="allowMissingThrowsTags" value="true"/>
<property name="allowThrowsTagsForSubclasses" value="true"/>
<property name="allowUndeclaredRTE" value="true"/>
</module>
<module name="JavadocType">
<property name="scope" value="protected"/>
<property name="severity" value="error"/>
</module>
<module name="JavadocStyle">
<property name="severity" value="warning"/>
</module>
<!--
NAMING CHECKS
-->
<!-- Item 38 - Adhere to generally accepted naming conventions -->
<module name="PackageName">
<!-- Validates identifiers for package names against the
supplied expression. -->
<!-- Here the default checkstyle rule restricts package name parts to
seven characters, this is not in line with common practice at Google.
-->
<property name="format" value="^[a-z]+(\.[a-z][a-z0-9]{1,})*$"/>
<property name="severity" value="warning"/>
</module>
<module name="TypeNameCheck">
<!-- Validates static, final fields against the
expression "^[A-Z][a-zA-Z0-9]*$". -->
<metadata name="altname" value="TypeName"/>
<property name="severity" value="warning"/>
</module>
<module name="ConstantNameCheck">
<!-- Validates non-private, static, final fields against the supplied
public/package final fields "^[A-Z][A-Z0-9]*(_[A-Z0-9]+)*$". -->
<metadata name="altname" value="ConstantName"/>
<property name="applyToPublic" value="true"/>
<property name="applyToProtected" value="true"/>
<property name="applyToPackage" value="true"/>
<property name="applyToPrivate" value="false"/>
<property name="format" value="^([A-Z][A-Z0-9]*(_[A-Z0-9]+)*|FLAG_.*)$"/>
<message key="name.invalidPattern"
value="Variable ''{0}'' should be in ALL_CAPS (if it is a constant) or be private (otherwise)."/>
<property name="severity" value="warning"/>
</module>
<module name="StaticVariableNameCheck">
<!-- Validates static, non-final fields against the supplied
expression "^[a-z][a-zA-Z0-9]*_?$". -->
<metadata name="altname" value="StaticVariableName"/>
<property name="applyToPublic" value="true"/>
<property name="applyToProtected" value="true"/>
<property name="applyToPackage" value="true"/>
<property name="applyToPrivate" value="true"/>
<property name="format" value="^[a-z][a-zA-Z0-9]*_?$"/>
<property name="severity" value="warning"/>
</module>
<module name="MemberNameCheck">
<!-- Validates non-static members against the supplied expression. -->
<metadata name="altname" value="MemberName"/>
<property name="applyToPublic" value="true"/>
<property name="applyToProtected" value="true"/>
<property name="applyToPackage" value="true"/>
<property name="applyToPrivate" value="true"/>
<property name="format" value="^[a-z][a-zA-Z0-9]*$"/>
<property name="severity" value="warning"/>
</module>
<module name="MethodNameCheck">
<!-- Validates identifiers for method names. -->
<metadata name="altname" value="MethodName"/>
<property name="format" value="^[a-z][a-zA-Z0-9]*(_[a-zA-Z0-9]+)*$"/>
<property name="severity" value="warning"/>
</module>
<module name="ParameterName">
<!-- Validates identifiers for method parameters against the
expression "^[a-z][a-zA-Z0-9]*$". -->
<property name="severity" value="warning"/>
</module>
<module name="LocalFinalVariableName">
<!-- Validates identifiers for local final variables against the
expression "^[a-z][a-zA-Z0-9]*$". -->
<property name="severity" value="warning"/>
</module>
<module name="LocalVariableName">
<!-- Validates identifiers for local variables against the
expression "^[a-z][a-zA-Z0-9]*$". -->
<property name="severity" value="warning"/>
</module>
<!--
LENGTH and CODING CHECKS
-->
<module name="LineLength">
<!-- Checks if a line is too long. -->
<property name="max" value="${com.puppycrawl.tools.checkstyle.checks.sizes.LineLength.max}" default="100"/>
<property name="severity" value="error"/>
<!--
The default ignore pattern exempts the following elements:
- import statements
- long URLs inside comments
-->
<property name="ignorePattern"
value="${com.puppycrawl.tools.checkstyle.checks.sizes.LineLength.ignorePattern}"
default="^(package .*;\s*)|(import .*;\s*)|( *(\*|//).*https?://.*)$"/>
</module>
<module name="LeftCurly">
<!-- Checks for placement of the left curly brace ('{'). -->
<property name="severity" value="warning"/>
</module>
<module name="RightCurly">
<!-- Checks right curlies on CATCH, ELSE, and TRY blocks are on
the same line. e.g., the following example is fine:
<pre>
if {
...
} else
</pre>
-->
<!-- This next example is not fine:
<pre>
if {
...
}
else
</pre>
-->
<property name="option" value="same"/>
<property name="severity" value="warning"/>
</module>
<!-- Checks for braces around if and else blocks -->
<module name="NeedBraces">
<property name="severity" value="warning"/>
<property name="tokens" value="LITERAL_IF, LITERAL_ELSE, LITERAL_FOR, LITERAL_WHILE, LITERAL_DO"/>
</module>
<module name="UpperEll">
<!-- Checks that long constants are defined with an upper ell.-->
<property name="severity" value="error"/>
</module>
<module name="FallThrough">
<!-- Warn about falling through to the next case statement. Similar to
javac -Xlint:fallthrough, but the check is suppressed if a single-line comment
on the last non-blank line preceding the fallen-into case contains 'fall through' (or
some other variants which we don't publicized to promote consistency).
-->
<property name="reliefPattern"
value="fall through|Fall through|fallthru|Fallthru|falls through|Falls through|fallthrough|Fallthrough|No break|NO break|no break|continue on"/>
<property name="severity" value="error"/>
</module>
<!--
MODIFIERS CHECKS
-->
<module name="ModifierOrder">
<!-- Warn if modifier order is inconsistent with JLS3 8.1.1, 8.3.1, and
8.4.3. The prescribed order is:
public, protected, private, abstract, static, final, transient, volatile,
synchronized, native, strictfp
-->
</module>
<!--
WHITESPACE CHECKS
-->
<module name="WhitespaceAround">
<!-- Checks that various tokens are surrounded by whitespace.
This includes most binary operators and keywords followed
by regular or curly braces.
-->
<property name="tokens" value="ASSIGN, BAND, BAND_ASSIGN, BOR,
BOR_ASSIGN, BSR, BSR_ASSIGN, BXOR, BXOR_ASSIGN, COLON, DIV, DIV_ASSIGN,
EQUAL, GE, GT, LAND, LE, LITERAL_CATCH, LITERAL_DO, LITERAL_ELSE,
LITERAL_FINALLY, LITERAL_FOR, LITERAL_IF, LITERAL_RETURN,
LITERAL_SYNCHRONIZED, LITERAL_TRY, LITERAL_WHILE, LOR, LT, MINUS,
MINUS_ASSIGN, MOD, MOD_ASSIGN, NOT_EQUAL, PLUS, PLUS_ASSIGN, QUESTION,
SL, SL_ASSIGN, SR_ASSIGN, STAR, STAR_ASSIGN"/>
<property name="severity" value="error"/>
</module>
<module name="WhitespaceAfter">
<!-- Checks that commas, semicolons and typecasts are followed by
whitespace.
-->
<property name="tokens" value="COMMA, SEMI, TYPECAST"/>
</module>
<module name="NoWhitespaceAfter">
<!-- Checks that there is no whitespace after various unary operators.
Linebreaks are allowed.
-->
<property name="tokens" value="BNOT, DEC, DOT, INC, LNOT, UNARY_MINUS,
UNARY_PLUS"/>
<property name="allowLineBreaks" value="true"/>
<property name="severity" value="error"/>
</module>
<module name="NoWhitespaceBefore">
<!-- Checks that there is no whitespace before various unary operators.
Linebreaks are allowed.
-->
<property name="tokens" value="SEMI, DOT, POST_DEC, POST_INC"/>
<property name="allowLineBreaks" value="true"/>
<property name="severity" value="error"/>
</module>
<module name="ParenPad">
<!-- Checks that there is no whitespace before close parens or after
open parens.
-->
<property name="severity" value="warning"/>
</module>
</module>
</module>
While creating SonarQube Quality Profile I provided checkstyle file to it. After Quality Profile wsa created I check which checkstyle (Permalinks) and it is different than one I provided. I am new to this field could you shade some light on it?
Original checkstyle I provided:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE module PUBLIC "-//Puppy Crawl//DTD Check Configuration 1.3//EN" "http://www.puppycrawl.com/dtds/configuration_1_3.dtd">
<module name="Checker">
<property name="severity" value="warning"/>
<module name="TreeWalker">
<module name="FileContentsHolder"/>
<module name="CyclomaticComplexity">
<property name="severity" value="warning"/>
<property name="max" value="25"/>
</module>
<module name="InterfaceIsType">
<property name="severity" value="warning"/>
</module>
<module name="HiddenFieldCheck">
<property name="severity" value="warning"/>
<property name="tokens" value="VARIABLE_DEF"/>
<property name="ignoreConstructorParameter" value="true"/>
<property name="ignoreSetter" value="true"/>
<property name="ignoreAbstractMethods" value="true"/>
</module>
<module name="TypecastParenPadCheck">
<property name="severity" value="info"/>
</module>
<module name="StringLiteralEquality">
<property name="severity" value="warning"/>
</module>
<module name="LocalVariableNameCheck">
<property name="severity" value="warning"/>
</module>
<module name="NoWhitespaceBeforeCheck">
<property name="severity" value="info"/>
</module>
<module name="RedundantImport">
<property name="severity" value="warning"/>
</module>
<module name="AnonInnerLength">
<property name="severity" value="warning"/>
<property name="max" value="50"/>
</module>
<module name="StaticVariableNameCheck">
<property name="severity" value="warning"/>
</module>
<module name="ParameterName">
<property name="severity" value="warning"/>
</module>
<module name="ParenPadCheck">
<property name="severity" value="info"/>
</module>
<module name="FinalClass">
<property name="severity" value="warning"/>
</module>
<module name="MethodTypeParameterName">
<property name="severity" value="warning"/>
</module>
<module name="WhitespaceAfterCheck">
<property name="severity" value="info"/>
</module>
<module name="UpperEll">
<property name="severity" value="info"/>
</module>
<module name="LocalFinalVariableName">
<property name="severity" value="warning"/>
</module>
<module name="JavadocVariableCheck">
<property name="severity" value="ignore"/>
<property name="scope" value="public"/>
<metadata name="net.sf.eclipsecs.core.lastEnabledSeverity" value="info"/>
</module>
<module name="TypeNameCheck">
<property name="severity" value="warning"/>
</module>
<module name="MemberNameCheck">
<property name="severity" value="warning"/>
</module>
<module name="NeedBracesCheck">
<property name="severity" value="warning"/>
</module>
<module name="VisibilityModifier">
<property name="severity" value="warning"/>
</module>
<module name="FinalParametersCheck">
<property name="severity" value="ignore"/>
<metadata name="net.sf.eclipsecs.core.lastEnabledSeverity" value="warning"/>
</module>
<module name="PackageName">
<property name="severity" value="warning"/>
</module>
<module name="ParameterAssignment">
<property name="severity" value="warning"/>
</module>
<module name="RedundantThrows">
<property name="severity" value="ignore"/>
<metadata name="net.sf.eclipsecs.core.lastEnabledSeverity" value="info"/>
</module>
<module name="IllegalImport">
<property name="severity" value="error"/>
</module>
<module name="AvoidNestedBlocks">
<property name="severity" value="warning"/>
</module>
<module name="TodoCommentCheck">
<property name="severity" value="info"/>
</module>
<module name="DesignForExtension">
<property name="severity" value="ignore"/>
<metadata name="net.sf.eclipsecs.core.lastEnabledSeverity" value="warning"/>
</module>
<module name="SimplifyBooleanReturn">
<property name="severity" value="warning"/>
</module>
<module name="HideUtilityClassConstructor">
<property name="severity" value="warning"/>
</module>
<module name="SimplifyBooleanExpression">
<property name="severity" value="warning"/>
</module>
<module name="ClassTypeParameterName">
<property name="severity" value="warning"/>
</module>
<module name="JavadocStyleCheck">
<property name="severity" value="warning"/>
</module>
<module name="BooleanExpressionComplexityCheck">
<property name="severity" value="warning"/>
</module>
<module name="InnerAssignmentCheck">
<property name="severity" value="warning"/>
</module>
<module name="MagicNumberCheck">
<property name="severity" value="ignore"/>
<metadata name="net.sf.eclipsecs.core.lastEnabledSeverity" value="warning"/>
</module>
<module name="JavadocTypeCheck">
<property name="severity" value="warning"/>
</module>
<module name="IllegalInstantiation">
<property name="severity" value="warning"/>
</module>
<module name="IllegalThrows">
<property name="severity" value="warning"/>
</module>
<module name="RedundantModifierCheck">
<property name="severity" value="warning"/>
</module>
<module name="LeftCurlyCheck">
<property name="severity" value="info"/>
</module>
<module name="TrailingComment">
<property name="severity" value="info"/>
</module>
<module name="MethodName">
<property name="severity" value="warning"/>
</module>
<module name="LineLength">
<property name="severity" value="warning"/>
<property name="max" value="160"/>
</module>
<module name="AvoidStarImport">
<property name="severity" value="warning"/>
</module>
<module name="DefaultComesLast">
<property name="severity" value="warning"/>
</module>
<module name="OperatorWrapCheck">
<property name="severity" value="info"/>
</module>
<module name="EmptyBlock">
<property name="severity" value="info"/>
</module>
<module name="MethodLengthCheck">
<property name="severity" value="warning"/>
</module>
<module name="EqualsHashCode">
<property name="severity" value="error"/>
</module>
<module name="MissingSwitchDefault">
<property name="severity" value="warning"/>
</module>
<module name="MethodParamPadCheck">
<property name="severity" value="info"/>
</module>
<module name="GenericWhitespace">
<property name="severity" value="info"/>
</module>
<module name="EmptyStatement">
<property name="severity" value="info"/>
</module>
<module name="RightCurlyCheck">
<property name="severity" value="info"/>
</module>
<module name="ConstantNameCheck">
<property name="severity" value="warning"/>
</module>
<module name="ArrayTypeStyle">
<property name="severity" value="info"/>
</module>
<module name="UnusedImports">
<property name="severity" value="warning"/>
</module>
<module name="WhitespaceAroundCheck">
<property name="severity" value="info"/>
</module>
<module name="ModifierOrder">
<property name="severity" value="warning"/>
</module>
<module name="JavadocMethodCheck">
<property name="severity" value="warning"/>
<property name="suppressLoadErrors" value="true"/>
</module>
<module name="NoWhitespaceAfterCheck">
<property name="severity" value="info"/>
</module>
<module name="FallThrough">
<property name="severity" value="warning"/>
</module>
<module name="MultipleVariableDeclarations">
<property name="severity" value="warning"/>
</module>
</module>
<module name="SuppressionCommentFilter"/>
<module name="NewlineAtEndOfFile">
<property name="severity" value="info"/>
</module>
<module name="FileTabCharacter">
<property name="severity" value="info"/>
</module>
<module name="FileLength">
<property name="severity" value="warning"/>
</module>
<module name="JavadocPackage">
<property name="severity" value="ignore"/>
<metadata name="net.sf.eclipsecs.core.lastEnabledSeverity" value="info"/>
</module>
<module name="RegexpSinglelineCheck">
<property name="severity" value="ignore"/>
<metadata name="net.sf.eclipsecs.core.lastEnabledSeverity" value="inherit"/>
</module>
<module name="SuppressionFilter">
<property name="file" value="${samedir}\suppressions.xml"/>
</module>
</module>
checkstyle which SonarQube Quality Profile uses (Permalinks):
<!-- Generated by Sonar -->
<module name="Checker">
<module name="SuppressionCommentFilter"/>
<module name="SuppressWarningsFilter"/>
<module name="FileTabCharacter">
<property name="severity" value="info"/>
</module>
<module name="JavadocPackage">
<property name="severity" value="info"/>
</module>
<module name="FileLength">
<property name="severity" value="warning"/>
</module>
<module name="NewlineAtEndOfFile">
<property name="severity" value="info"/>
<property name="lineSeparator" value="system"/>
</module>
<module name="TreeWalker">
<module name="FileContentsHolder"/>
<module name="SuppressWarningsHolder"/>
<module name="AnonInnerLength">
<property name="severity" value="warning"/>
<property name="max" value="50"/>
</module>
<module name="ArrayTypeStyle">
<property name="severity" value="info"/>
</module>
<module name="AvoidNestedBlocks">
<property name="severity" value="warning"/>
</module>
<module name="AvoidStarImport">
<property name="severity" value="warning"/>
<property name="allowStaticMemberImports" value="false"/>
<property name="allowClassImports" value="false"/>
</module>
<module name="ClassTypeParameterName">
<property name="severity" value="warning"/>
<property name="format" value="^[A-Z]$"/>
</module>
<module name="CyclomaticComplexity">
<property name="severity" value="warning"/>
<property name="max" value="25"/>
<property name="switchBlockAsSingleDecisionPoint" value="false"/>
<property name="tokens" value="LITERAL_WHILE,LITERAL_DO,LITERAL_FOR,LITERAL_IF,LITERAL_SWITCH,LITERAL_CASE,LITERAL_CATCH,QUESTION,LAND,LOR"/>
</module>
<module name="DefaultComesLast">
<property name="severity" value="warning"/>
</module>
<module name="DesignForExtension">
<property name="severity" value="info"/>
</module>
<module name="EmptyBlock">
<property name="severity" value="info"/>
<property name="option" value="stmt"/>
<property name="tokens" value="LITERAL_WHILE,LITERAL_TRY,LITERAL_FINALLY,LITERAL_DO,LITERAL_IF,LITERAL_ELSE,LITERAL_FOR,INSTANCE_INIT,STATIC_INIT,LITERAL_SWITCH,LITERAL_SYNCHRONIZED"/>
</module>
<module name="EmptyStatement">
<property name="severity" value="info"/>
</module>
<module name="EqualsHashCode">
<property name="severity" value="error"/>
</module>
<module name="FallThrough">
<property name="severity" value="warning"/>
</module>
<module name="FinalClass">
<property name="severity" value="warning"/>
</module>
<module name="GenericWhitespace">
<property name="severity" value="info"/>
</module>
<module name="HideUtilityClassConstructor">
<property name="severity" value="warning"/>
</module>
<module name="IllegalImport">
<property name="severity" value="error"/>
</module>
<module name="IllegalInstantiation">
<property name="severity" value="warning"/>
</module>
<module name="IllegalThrows">
<property name="severity" value="warning"/>
<property name="ignoreOverriddenMethods" value="true"/>
</module>
<module name="InterfaceIsType">
<property name="severity" value="warning"/>
</module>
<module name="LineLength">
<property name="severity" value="warning"/>
<property name="max" value="160"/>
</module>
<module name="LocalFinalVariableName">
<property name="severity" value="warning"/>
<property name="format" value="^[a-z][a-zA-Z0-9]*$"/>
</module>
<module name="MethodName">
<property name="severity" value="warning"/>
<property name="allowClassName" value="false"/>
<property name="format" value="^[a-z][a-zA-Z0-9]*$"/>
</module>
<module name="MethodTypeParameterName">
<property name="severity" value="warning"/>
<property name="format" value="^[A-Z]$"/>
</module>
<module name="MissingSwitchDefault">
<property name="severity" value="warning"/>
</module>
<module name="ModifierOrder">
<property name="severity" value="warning"/>
</module>
<module name="MultipleVariableDeclarations">
<property name="severity" value="warning"/>
</module>
<module name="PackageName">
<property name="severity" value="warning"/>
<property name="format" value="^[a-z]+(\.[a-zA-Z_][a-zA-Z0-9_]*)*$"/>
</module>
<module name="ParameterAssignment">
<property name="severity" value="warning"/>
</module>
<module name="ParameterName">
<property name="severity" value="warning"/>
<property name="format" value="^[a-z][a-zA-Z0-9]*$"/>
<property name="ignoreOverridden" value="false"/>
</module>
<module name="RedundantImport">
<property name="severity" value="warning"/>
</module>
<module name="SimplifyBooleanExpression">
<property name="severity" value="warning"/>
</module>
<module name="SimplifyBooleanReturn">
<property name="severity" value="warning"/>
</module>
<module name="StringLiteralEquality">
<property name="severity" value="warning"/>
</module>
<module name="TrailingComment">
<property name="severity" value="info"/>
<property name="format" value="^[\s\}\);]*$"/>
</module>
<module name="UnusedImports">
<property name="severity" value="warning"/>
<property name="processJavadoc" value="true"/>
</module>
<module name="UpperEll">
<property name="severity" value="info"/>
</module>
<module name="VisibilityModifier">
<property name="severity" value="warning"/>
<property name="allowPublicImmutableFields" value="true"/>
<property name="packageAllowed" value="false"/>
<property name="publicMemberPattern" value="^serialVersionUID$"/>
<property name="protectedAllowed" value="false"/>
<property name="ignoreAnnotationCanonicalNames" value="org.junit.Rule,com.google.common.annotations.VisibleForTesting"/>
</module>
</module>
</module>
Some rules are replaced with java plugin rules, other are mapped/not implemented yet. You should check the map link:
A majority of the Checkstyle rules have been introduced in the Sonar Java plugin. Copied rules are marked "Deprecated" in the Checkstyle plugin ONLY beacause Sonar plugin have similar rule , but a some summary of map/replaced rules (a lot of mistakes) is available.
Source https://github.com/checkstyle/sonar-checkstyle
I am getting the following error when I am trying to instantiate a MockHttpServletRequest object like this: MockHttpServletRequest request = new MockHttpServletRequest();
java.lang.NoSuchMethodError: org.springframework.core.CollectionFactory.createLinkedMapIfPossible(I)Ljava/util/Map;at org.springframework.mock.web.MockHttpServletRequest.(MockHttpServletRequest.java:107)
at org.springframework.mock.web.MockHttpServletRequest.(MockHttpServletRequest.java:187)
My maven code:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>groupId</groupId>
<artifactId>Servlet</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
</properties>
<dependencies>
<!-- http://mvnrepository.com/artifact/org.springframework/spring-web -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>4.2.6.RELEASE</version>
</dependency>
<!-- http://mvnrepository.com/artifact/org.springframework/spring-mock -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-mock</artifactId>
<version>2.0.8</version>
</dependency>
</dependencies>
</project>
the iml file:
<?xml version="1.0" encoding="UTF-8"?>
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
<component name="FacetManager">
<facet type="web" name="Web">
<configuration>
<descriptors>
<deploymentDescriptor name="web.xml" url="file://$MODULE_DIR$/web/WEB-INF/web.xml" />
</descriptors>
<webroots>
<root url="file://$MODULE_DIR$/web" relative="/" />
</webroots>
<sourceRoots />
</configuration>
</facet>
</component>
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_5" inherit-compiler-output="false">
<output url="file://$MODULE_DIR$/target/classes" />
<output-test url="file://$MODULE_DIR$/target/test-classes" />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
<excludeFolder url="file://$MODULE_DIR$/target" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="Java EE 6-Java EE 6" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-web:4.2.6.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-aop:4.2.6.RELEASE" level="project" />
<orderEntry type="library" name="Maven: aopalliance:aopalliance:1.0" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-beans:4.2.6.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-context:4.2.6.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-expression:4.2.6.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-core:4.2.6.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-mock:2.0.8" level="project" />
<orderEntry type="library" name="Maven: commons-logging:commons-logging:1.1" level="project" />
</component>
</module>
My external libraries directories:
I have also added a Java Servlet jar:
I am using Intellij IDEA; thanks in advance.
M. Deinum response worked for me, replace spring-mock with spring-test, additionally take a look at the .iml file and make sure the spring-mock is gone, otherwise remove it manually and re-attempt to execute the test.
Credits to: M. Deinum
I am following cxf sample to verify the signature, unfortunately I got following error " org.apache.wss4j.common.ext.WSSecurityException: The signature or decryption was invalid"
I've tried many days and don't find any solution.
spring configuration:
<?xml version="1.0" encoding="UTF-8"?><beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:int="http://www.springframework.org/schema/integration"
xmlns:jaxws="http://cxf.apache.org/jaxws" xmlns:jaxrs="http://cxf.apache.org/jaxrs"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/integration http://www.springframework.org/schema/integration/spring-integration-3.0.xsd
http://cxf.apache.org/jaxrs http://cxf.apache.org/schemas/jaxrs.xsd http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd">
<import resource="classpath*:META-INF/cxf/cxf.xml" />
<!-- <import resource="classpath*:META-INF/cxf/cxf-extension-soap.xml" /> -->
<!-- <import resource="classpath*:META-INF/cxf/cxf-servlet.xml" /> -->
<jaxws:endpoint id="billingWs"
implementor="com.npp.ws.soap.BillingWS" address="/BillingWs">
<jaxws:features>
<bean class="org.apache.cxf.feature.LoggingFeature" />
</jaxws:features>
<jaxws:inInterceptors>
<bean class="org.apache.cxf.ws.security.wss4j.WSS4JInInterceptor">
<constructor-arg>
<map>
<entry key="action" value="Signature Timestamp" />
<entry key="signaturePropFile" value="server_sign.properties" />
<entry key="passwordCallbackClass" value="server.ServerPasswordCallback" />
</map>
</constructor-arg>
</bean>
<bean class="org.apache.cxf.ws.security.wss4j.DefaultCryptoCoverageChecker" />
</jaxws:inInterceptors>
</jaxws:endpoint>
pom
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.springframework.samples.service.service</groupId>
<artifactId>cxftest</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<properties>
<!-- Generic properties -->
<java.version>1.6</java.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<servlet.version>2.5</servlet.version>
<!-- Spring -->
<spring-framework.version>3.2.3.RELEASE</spring-framework.version>
<logback.version>1.0.13</logback.version>
<slf4j.version>1.7.5</slf4j.version>
<cxf.version>3.1.1</cxf.version>
</properties>
<dependencies>
<!-- Logging with SLF4J & LogBack -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>${slf4j.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>${logback.version}</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>${spring-framework.version}</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-frontend-jaxws</artifactId>
<version>${cxf.version}</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-http</artifactId>
<version>${cxf.version}</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-ws-security</artifactId>
<version>${cxf.version}</version>
</dependency>
</dependencies>
and the saop request
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Header>
<wsse:Security soap:mustUnderstand="1"
xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
<ds:Signature Id="Signature-377" xmlns:ds="http://www.w3.org/2000/09/xmldsig#">
<ds:SignedInfo>
<ds:CanonicalizationMethod
Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#" />
<ds:SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#dsa-sha1" />
<ds:Reference URI="#id-378">
<ds:Transforms>
<ds:Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#" />
</ds:Transforms>
<ds:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1" />
<ds:DigestValue>1ZFZORXkYPbowBDc3Lg+Netl2hU=</ds:DigestValue>
</ds:Reference>
<ds:Reference URI="#Timestamp-376">
<ds:Transforms>
<ds:Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#" />
</ds:Transforms>
<ds:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1" />
<ds:DigestValue>bMO8RXVgtRWyxyoxyY1IwHKY3Z8=</ds:DigestValue>
</ds:Reference>
</ds:SignedInfo>
<ds:SignatureValue>QbizkdCQosjgfy2HUhX7LqxsIEQiDAGgamNfZTGFHPvqyynJ1Tm9iA==</ds:SignatureValue>
<ds:KeyInfo Id="KeyId-F19E25F47A63BAEC351364893623867377">
<wsse:SecurityTokenReference
wsu:Id="STRId-F19E25F47A63BAEC351364893623867378"
xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"
xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
<ds:X509Data>
<ds:X509IssuerSerial>
<ds:X509IssuerName>CN=localhost,OU=Eng,O=G,L=Boulder,ST=CO,C=US</ds:X509IssuerName>
<ds:X509SerialNumber>1317155816</ds:X509SerialNumber>
</ds:X509IssuerSerial>
</ds:X509Data>
</wsse:SecurityTokenReference>
</ds:KeyInfo>
</ds:Signature>
<wsu:Timestamp wsu:Id="Timestamp-376"
xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
<wsu:Created>2013-04-02T09:07:03.867Z</wsu:Created>
<wsu:Expires>2013-04-02T09:17:03.867Z</wsu:Expires>
</wsu:Timestamp>
</wsse:Security>
</soap:Header>
<soap:Body wsu:Id="id-378"
xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
<ns1:Echo xmlns:ns1="http://www.test.com/billing">
<parameters>
<Version>3</Version>
<CorrelationId>b9da054b2f0c493e9633fc527de7055a</CorrelationId>
<Message>Hello user.</Message>
</parameters>
</ns1:Echo>
</soap:Body>
Enable debug logging - it will tell you exactly where signature validation failed.
I suggest you to enable debugging with
System.setProperty("javax.net.debug","ssl");
... or in your call to the vm with -Djavax.net.debug=ssl
That way you will see the exact point where the signature failed