SuppressionFilter is not working - checkstyle

SuppressionFilter is not ignoring the files which are given in suppressions.xml
In checkstyle.xml,
<module name="Checker">
<module name="SuppressionFilter">
<property name="file" value="/home/svn/testrepo/scripts/suppressions.xml"/>
</module>
<module name="TreeWalker">
....
</module>
In suppressions.xml (which is in /home/svn/testrepo/scripts),
<?xml version="1.0"?>
<!DOCTYPE suppressions PUBLIC
"-//Puppy Crawl//DTD Suppressions 1.0//EN"
"http://www.puppycrawl.com/dtds/suppressions_1_0.dtd">
<suppressions>
<suppress checks="."
files="Constants.java" />
</suppressions>
Also, tried with the below one:
<suppressions>
<suppress files="Constants\.java" checks="[a-zA-Z0-9]*"/>
</suppressions>
Also, tried with:
<suppressions>
<suppress checks=".*"
files="Constants.java" />
</suppressions>
None of the options are working. Can anybody have answers on this? Please help me out.

Assuming you configure the filter using:
<module name="SuppressionFilter">
<property name="file" value="suppressions.xml"/>
</module>
Then an example content of suppressions.xml could be:
<?xml version="1.0"?>
<!DOCTYPE suppressions PUBLIC
"-//Puppy Crawl//DTD Suppressions 1.1//EN"
"http://www.puppycrawl.com/dtds/suppressions_1_1.dtd">
<suppressions>
<suppress checks="." files="[\\/]SoapAdapter\.java$"/>
</suppressions>
This will then suppress all checks for the files named SoapAdapter.java. Note that [\\/] is just a regular expression to handle file names under Unix (which use /) and Windows (which use \).
Also recommend reading the Checkstyle documenation on the subject at http://checkstyle.sourceforge.net/config.html.

just add ${config_loc} in front of value as described in the official documentation
<module name="SuppressionFilter">
<property name="file" value="${config_loc}/suppressions.xml"/>
</module>

Related

Auto add all files in the folder

Following part includes a single file but I would like to include all files in the folder which matches with *.log. Is there a way to make it work?
<!DOCTYPE root
[
<!ENTITY log SYSTEM "Log.log">
]>
<root>
&log;
</root>
*.log
There is no root element in log files.
not even <?xml version="1.0" encoding="UTF-8"?> and/or xslt link like <?xml-stylesheet type="text/xsl" href="test.xsl" ?> each file has 1000+ records like below
<E2ETraceEvent xmlns="http://schemas.microsoft.com/2004/06/E2ETraceEvent">
<System xmlns="http://schemas.microsoft.com/2004/06/windows/eventlog/system">
<SubType Name="Information">0</SubType>
<Correlation ActivityID="a54221e2-ad37-434a-8f0d-101f7abc2221" />
</System>
<ApplicationData>Test21</ApplicationData>
</E2ETraceEvent>
<E2ETraceEvent xmlns="http://schemas.microsoft.com/2004/06/E2ETraceEvent">
<System xmlns="http://schemas.microsoft.com/2004/06/windows/eventlog/system">
<SubType Name="Information">0</SubType>
<Correlation ActivityID="d30741c2-da73-434a-8f0d-101f7ceb2228" />
</System>
<ApplicationData>Test24</ApplicationData>
</E2ETraceEvent>

Css resource not available in jsp

Hi I'm using spring and I want to include a css file.
I've created a folder resources/mytheme/css/signing.css under webapp.
My dispatcher servlet looks like this:
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd">
<context:component-scan base-package="com.springapp.mvc"/>
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/WEB-INF/pages/"/>
<property name="suffix" value=".jsp"/>
</bean>
<mvc:resources mapping="/resources/**" location="/resources/mytheme/" />
</beans>
In my jsp file I reference to the css file like this:
<link href="${pageContext.request.contextPath}/resources/css/signing.css" rel="stylesheet" >
When I surf to the page I always get a 404 and The requested resource is not available.
Someone who can help me?
I fixed the problem by adding this to my web.xml
<servlet-mapping>
<servlet-name>default</servlet-name>
<url-pattern>/resources/*</url-pattern>
</servlet-mapping>
This makes my resource folder available.

RazorEngine 3.2.0: Razor Namespace not found in .cshtml File

I'm using RazorEngine 3.2.0 in a Class Library project.
I resolved some Class Library related issues by following the following answer to the following SO-question: Razor intellisense error: Feature 'extension method' cannot be used because it is not part of the ISO-2 C# language specification
Problem
I try to use the #inherits keyword. If I just write the full qualified name for the view-class, intellisense works. If I try to inherit from RazorEngine.Templating.TemplateBase<T> it seems that the whole RazorEngine-Assemlby isn't resolved.
The Template looks like this:
#inherits RazorEngine.Templating.TemplateBase<ViewModels.PrintCatalogData>
<!DOCTYPE html>
<html>
<head>
...
At Runtime it works - just intellisense is failing.
Question
What is needed that the intellisense recognizes the RazorEngine-Assembly?
The #inherits probably does not like the fully qualified name. Try adding the namespace RazorEngine.Templating to your web.config and then remove the fully qualified name from the view template.
<system.web.webPages.razor>
<host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<pages pageBaseType="System.Web.Mvc.WebViewPage">
<namespaces>
<add namespace="System.Web.Mvc" />
<add namespace="System.Web.Mvc.Ajax" />
<add namespace="System.Web.Mvc.Html" />
<add namespace="System.Web.Optimization"/>
<add namespace="System.Web.Routing" />
<add namespace="Assemblies"/>
<add namespace="RazorEngine.Templating"/>
<add namespace="Resources"/>
</namespaces>
</pages>

Under Spring Framework: WARN: WARN No appenders could be found for logger (org.springframework.web.context.ContextLoader)

I have spent all day trying to solve the logging problem I'm having with log4j in a webapp. No matter what I do, I cannot get rid of the following:
log4j:WARN No appenders could be found for logger (org.springframework.web.context.ContextLoader).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
Just to be clear, I have read all of the articles here on Stack Overflow addressing this issue. I've read the log4j manual. I've been through a dozen different tutorials. I've tried the properties approach and the XML approach (log4j.properties and log4j.xml, respectively). Also, I have confirmed that the log4j.xml file is being read. Aside from the fact that the server tells me so during startup, I can influence the level of feedback through the .xml file. So, yes, the log4j.xml file is in the CLASSPATH.
I know I'm missing something simple and fundamental. Below are the relevant files:
LOG4J.XML (/WEB-INF):
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE log4j:configuration PUBLIC "-//APACHE//DTD LOG4J 1.2//EN" "log4j.dtd">
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
<!-- Appenders -->
<appender name="console" class="org.apache.log4j.ConsoleAppender">
<param name="Target" value="System.out" />
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%-5p: %c - %m%n" />
</layout>
</appender>
<!-- Application Loggers -->
<logger name="com.tiersoftinc.testlog">
<level value="info" />
</logger>
<!-- 3rdparty Loggers -->
<logger name="org.springframework.core">
<level value="info" />
</logger>
<logger name="org.springframework.beans">
<level value="info" />
</logger>
<logger name="org.springframework.context">
<level value="info" />
</logger>
<logger name="org.springframework.web">
<level value="info" />
</logger>
<!-- Root Logger -->
<root>
<priority value="warn" />
<appender-ref ref="console" />
</root>
</log4j:configuration>
and WEB.XML (/WEB-INF):
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<!-- The definition of the Root Spring Container shared by all Servlets and Filters, and the applicationContext.xml file -->
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
/WEB-INF/spring/root-context.xml
/WEB-INF/spring/app-context.xml
</param-value>
</context-param>
<!-- Logging listener -->
<listener>
<listener-class>org.springframework.web.util.Log4jConfigListener</listener-class>
</listener>
<context-param>
<param-name>log4jConfigLocation</param-name>
<param-value>/WEB-INF/log4j.xml</param-value>
</context-param>
<!-- Creates the Spring Container shared by all Servlets and Filters -->
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<!-- Processes application requests -->
<servlet>
<servlet-name>appServlet</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/spring/appServlet/servlet-context.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>appServlet</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
</web-app>
and APP-CONTEXT.XML (/WEB-INF/spring):
<?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:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:p="http://www.springframework.org/schema/p"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd
http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.1.xsd">
<!-- Activates various annotations to be detected in bean classes -->
<context:annotation-config />
<!-- Scans the classpath for annotated components that will be auto-registered as Spring beans.
For example #Controller and #Service. Make sure to set the correct base-package -->
<context:component-scan base-package="com.tiersoftinc.gridlab3" />
<!-- Configures the annotation-driven Spring MVC Controller programming model.
Note that, with Spring 3.0, this tag works in Servlet MVC only! -->
<mvc:annotation-driven />
<mvc:resources mapping="/resources/**" location="/resources/" />
<!-- Imports datasource configuration -->
<import resource="app-context-mongo.xml"/>
</beans>
and APP-CONTEXT-MONGO.XML (/WEB-INF/spring):
<?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:p="http://www.springframework.org/schema/p"
xmlns:c="http://www.springframework.org/schema/c"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:mongo="http://www.springframework.org/schema/data/mongo"
xmlns:util="http://www.springframework.org/schema/util"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-3.1.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.1.xsd
http://www.springframework.org/schema/data/mongo
http://www.springframework.org/schema/data/mongo/spring-mongo-1.0.xsd
http://www.springframework.org/schema/util
http://www.springframework.org/schema/util/spring-util-3.1.xsd">
<!-- Activate Spring Data MongoDB repository support -->
<mongo:repositories base-package="com.tiersoftinc.gridlab3.repository" />
<bean id="propertyPlaceholderConfigurer"
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="locations">
<list>
<value>/WEB-INF/spring/database.properties</value>
</list>
</property>
</bean>
<!-- MongoDB host -->
<mongo:mongo host="${mongo.host.name}" port="${mongo.host.port}"/>
<!-- Template for performing MongoDB operations -->
<bean id="mongoTemplate" class="org.springframework.data.mongodb.core.MongoTemplate"
c:mongo-ref="mongo" c:databaseName="${mongo.db.name}"/>
<!-- Service for initializing MongoDB with sample data using MongoTemplate -->
<bean id="initGridLab3Service" class="com.tiersoftinc.gridlab3.services.InitGridLab3Service" init-method="init"/>
</beans>
and, finally, ROOT-CONTEXT.XML (/WEB-INF/spring):
<?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:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd
http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.1.xsd">
<!-- Root Context: defines shared resources visible to all other web components -->
<context:annotation-config />
</beans>
What am I missing?
Thank you.
Have you tried this?
<logger name="org.springframework.web">
<level value="info" />
<appender-ref ref="console" />
</logger>
Put these lines in the beginning of your web.xml:
<listener>
<listener-class>org.springframework.web.util.Log4jConfigListener</listener-class>
</listener>
<context-param>
<param-name>log4jConfigLocation</param-name>
<param-value>classpath:/main/resources/log4j.xml</param-value>
</context-param>

App.config issues

When i modified my app.config to include the ReflectSoftware logging infomration, Ninjatrader crashed. Can you point out where I did not configure it correctly?
?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.net>
<defaultProxy>
<proxy usesystemdefault="False"/>
</defaultProxy>
</system.net>
<configSections>
<section name="insightSettings" type="ReflectSoftware.Insight.ConfigurationHandler,ReflectSoftware.Insight"/>
</configSections>
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<!--
In order to recieve location information, you must ensure the layout has the parameter ${callsite} and all
its properties set accordantly.
-->
<extensions>
<add assembly="ReflectSoftware.Insight.Extensions.NLog"/>
</extensions>
<targets>
<target name="ReflectInsight"
xsi:type="ReflectInsight"
instanceName="nlogInstance1"
displayLevel="true"
displayLocation="true"
layout="${callsite:className=true:fileName=true:includeSourcePath=true:methodName=true}" />
</targets>
<rules>
<logger name="*" minlevel="Trace" writeTo="ReflectInsight" />
</rules>
</nlog>
</configuration>
fixed by moving the xml fragment after Config sections