Wednesday, May 20, 2015

Install java plugin in FireFox on Ubuntu

Based on
I presume that JAVA_HOME is defined , if not substitute it with real path.

On Ubuntu:

cd /usr/lib/mozilla/plugins
sudo ln -s $JAVA_HOME/jre/lib/amd64/ .


/usr/lib/mozilla/plugins $ ls -la
total 8
drwxr-xr-x 2 root root 4096 May 20 11:57 .
drwxr-xr-x 3 root root 4096 Oct 29  2014 ..
lrwxrwxrwx 1 root root   37 May 13 12:43 -> /etc/alternatives/mozilla-flashplugin
lrwxrwxrwx 1 root root   42 May 20 11:57 -> /opt/jdk1.8.0_45/jre/lib/amd64/

Launch Java app from web and on jnlp usage please select javaws:

ATTENTION: if no javaws is selected - use that window by option "Other ..." to select application at $JAVA_HOME/bin/javaws (example: /opt/jdk1.8.0_45/bin/javaws)

Saturday, May 16, 2015

Sevntu Checkstyle release 1.13.0

Braking backward compatibility:
VariableDeclarationUsageDistanceCheck was moved to Checkstyle library . Author: Roman Ivanov
AbbreviationAsWordInNameCheck is transfered to Checkstyle library . Author: Roman Ivanov
New Check RequiredParameterForAnnotationCheck. Fixes #321 . Author: Andrew Uljanenko
New Check UselessSuperCtorCallCheck implemeted. Fixes #186 . Author: Alexey
New Check EmptyPublicCtorInClassCheck implemented. fixes #291 . Author: Alexey
New Check NameConventionForJunit4TestClassesCheck implemented. Fixes #80 . Author: Alexey
New Check UselessSingleCatchCheck implemented. issue #267 fixed . Author: Alexey
New Check: AvoidConditionInversion . #112 . Author: alexkravin
New Check: NestedSwitchCheck - Checking if there is no switch block inside other switch block.  Issue #249. Author: Damian Szczepanik
fix for NPE in ConfusingConditionCheck . Author: melodicwing
Fixed false positive in check ForbidReturnInFinallyBlockChech. Fixes #269 . Author: Andrew Uljanenko
Diamond operator - fixed violations on anonymous classes . Issue #270 . Author: alexkravin
Refactored prefixes, changed indentation of switch-case, issue #298 . Author: alexkravin
Moved test-input folder from src/test/java to src/test/resources . Author: alexkravin
no java6 support since 6.2 release . Author: Roman Ivanov
version 1.13.0 bump, java6, fixes for errors of m2e . Author: Roman Ivanov
Updated maximum line length to 100 symbols . Author: Daniil Yaroslavtsev
Small code changes and extended UT's. Fixes #317 . Author: Andrew Uljanenko
New test case added. Fixes #275 . Author: Andrew Uljanenko
New test case added. Fixes #274 . Author: Andrew Uljanenko
Extended javadoc, UTs. Fixed #264 . Author: Andrew Uljanenko
Code coverage improvement . Author: Damian Szczepanik
Short-circuit logic is used in boolean expressions, issue #169 . Author: Michal Kordas
Code coverage improvements for ReturnCountExtendedCheck . Author: Damian Szczepanik
Improved AvoidHidingCauseExceptionCheck code coverage . Author: Damian Szczepanik
Improved UselessSingleCatchCheck code coverage . Author: Damian Szczepanik
Improved AvoidDefaultSerializableInInnerClasses code coverage to 100% . Author: Damian Szczepanik
Fixes several Sonar violations . Author: Damian Szczepanik
Remove unused input for AvoidHidingCauseExceptionCheck . Author: Damian Szczepanik
Increase AvoidNotShortCircuitOperatorsForBooleanCheck code coverage Pull #324 . Author: Damian Szczepanik
Moved static duplicated methods into Utils class . Author: Damian Szczepanik
Sonar violation: Tabulation characters should not be used . Author: Damian Szczepanik
improved InterfaceTypeParameterNameCheck code coverage . Author: Damian Szczepanik
Improved UnnecessaryParenthesesExtendedCheck test coverage . Author: Damian Szczepanik
Fixed Sonar critical and major violations: - "static final" arrays should be "private" - "for" loop incrementers should modify the variable being tested in the loop's stop condition - Declarations should use Java collection interfaces such as "List" rather than specific implementation classes such as "LinkedList" . Author: Damian Szczepanik
Run cobentura with mvn check or mavn install and fail if code coverage criteria are not met. For new files we expect to have 100% code coverage, for older one that do not pass this rule we added some rules . Author: Damian Szczepanik
Added Utils class that has one method for reporting unsupported AST token . Author: Damian Szczepanik
Removed duplicate check for the empty list: first condition isEmpty() but then for-each which also skips iteration if list is empty . Author: Damian Szczepanik
Increase OverridableMethodInConstructorCheck code coverage: - Added more test cases (examples) - Replaced to Serializable/Clonable stirngs to Cloneable.class.getSimpleName() - Increase coverage by using true and false values of checkCloneMethod and checkReadObjectMethod . Author: Damian Szczepanik
MapIterationInForEachLoopCheck - Converted strings to .class.getName() - moved initialization to beginTree method . Author: Damian Szczepanik
Improved test coverity of EitherLogOrThrowCheck by: - adding new test with inner class - invoking setters method by setting attributes in test scenario . Author: Damian Szczepanik
Improved test coverity in ConfusingConditionCheck by setting default parameters in test case . Author: Damian Szczepanik
Improved coverage of AvoidDefaultSerializableInInnerClasses by importing full qualified class name Serializable (use . Author: Damian Szczepanik
Improved test coverity of class ChildBlockLengthCheckCheck by adding test for tested class . Author: Damian Szczepanik
Improved CustomDeclarationOrderCheck - Added tests to increase coverage - Fixed rule in test method - Fixed formatting (indents) . Author: Damian Szczepanik

Saturday, April 11, 2015

Should logger be private static or not

Just read -

decision is full of trade off but, that article is the best, so I am referencing it in my blog to let me quickly find it, as that question re-appear again and again.

My position:
Logger should never be public or protected and even share-able with or accessible by others classes, eventually will be enforced by Checkstyle -

Tuesday, March 24, 2015

Oracle listener is stopped unexpectedly on Xubuntu 14.04

Oracle listener is always launched on startup, I did not nothing special to stop it, but during work I found that listener is not started ....

15:01 $ lsnrctl status

LSNRCTL for Linux: Version - Production on 24-MAR-2015 15:01:40

Copyright (c) 1991, 2011, Oracle.  All rights reserved.

TNS-12541: TNS:no listener
 TNS-12560: TNS:protocol adapter error
  TNS-00511: No listener
   Linux Error: 111: Connection refused
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=rivanov)(PORT=1521)))
TNS-12541: TNS:no listener
 TNS-12560: TNS:protocol adapter error
  TNS-00511: No listener
   Linux Error: 111: Connection refused

15:01 $ lsnrctl start

LSNRCTL for Linux: Version - Production on 24-MAR-2015 15:12:35

Copyright (c) 1991, 2011, Oracle.  All rights reserved.

Alias                     LISTENER
Version                   TNSLSNR for Linux: Version - Production
Start Date                24-MAR-2015 15:02:20
Uptime                    0 days 0 hr. 10 min. 15 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Default Service           XE
Listener Parameter File   /u01/app/oracle/product/11.2.0/xe/network/admin/listener.ora
Listener Log File         /u01/app/oracle/product/11.2.0/xe/log/diag/tnslsnr/vdu-rivanov/listener/alert/log.xml
Listening Endpoints Summary...
Services Summary...
Service "PLSExtProc" has 1 instance(s).
  Instance "PLSExtProc", status UNKNOWN, has 1 handler(s) for this service...
Service "XE" has 1 instance(s).
  Instance "XE", status READY, has 1 handler(s) for this service...
Service "XEXDB" has 1 instance(s).
  Instance "XE", status READY, has 1 handler(s) for this service...
The command completed successfully

BUT SQLDeveloper still have no ability to connect to local instance.
Java still cannot connect to ORACLE XE on "mvn clean test"

15:10 $ sudo /etc/init.d/oracle-xe restart

after that command all works fine

Thursday, March 12, 2015

Neutral Filters and Evaluator ordering for Logback SMTPAppender

Example of config with nuance of NEUTRAL usage for filters,
miss of at least one filter that do deny by well distinctive parameter (level, marker) will result in sending mail with all events from begging of logs till event required in Evaluator.

<appender name="MY_MAIL" class="">


<if condition="property(&quot;MY_ENV_VAR&quot;) == &quot;&quot; || property(&quot;MY_ENV_VAR&quot;) == null">
<subject>[%marker] [%p] from ${HOSTNAME}</subject>
<subject>[${MY_ENV_VAR}] [%marker] [%p] from ${HOSTNAME}</subject>

<!-- the way SMTPAppender works makes him only apply filters firsly 
    and then apply evaluator to actually trigger 
e-mail sending, filters are also executed in order in 
which they are defined in configuration -->
<!-- Due to usage of NEUTRAL at EvaluatorFilter(see below) without 
    this filter, mail will contain all events from beggining 
    till MY_MARKER -->
<filter class="ch.qos.logback.core.filter.EvaluatorFilter">
<evaluator class="ch.qos.logback.classic.boolex.OnMarkerEvaluator">

<!-- perform more precise filtering, 
    you can suppress particular messages here -->
<filter class="ch.qos.logback.core.filter.EvaluatorFilter">
// reduce noise of job for some problems
if (level == WARN && logger.contains("ConstraintService") 
&& message.contains("violates constraint")) {
return false;
return true;
<!-- NEUTRAL as we may want to add more filters later -->

<!-- This evaluator triggers e-mail sending. As we only filter 
    events with appropriate
marker, e-mail would always have only one logEvent -->
<evaluator class="ch.qos.logback.classic.boolex.OnMarkerEvaluator">


Tuesday, March 10, 2015

Catch Exception or catch Throwable when you need to log anything

When you ask yourself a question what to catch in main method Exception and Throwable - use Throwable to catch all unexpected problems for sure.

if you choose to catch Exception you will lose Errors ,and Errors are not only system problems.

interesting Error that could happen in business logic + misconfiguration

initialization of non static field


declaration of Configuration

public enum Configuration {

private AbstractApplicationContext context;

private Configuration() {
this.context = new AnnotationConfigApplicationContext("com.mycompany");

public static <T> T getBean(Class<T> clazz) {
return INSTANCE.context.getBean(clazz);

public void destroy() {


If you somewhow did a mistake in from and Configuration will fail to initialize then getBean is failed with ExceptionInInitializerError, but it have a cause Exception that could be like:

Exception in thread "main" java.lang.ExceptionInInitializerError
at com.mycompany.ExecutableImpl.execute(
at com.revere.xfeed.customclients.renaissance.MyTestClass.main(
Caused by: org.springframework.beans.factory.BeanInitializationException: Could not load properties; nested exception is (No such file or directory)
at org.springframework.beans.factory.config.PropertyResourceConfigurer.postProcessBeanFactory(
at org.springframework.context.annotation.AnnotationConfigApplicationContext.<init>(

so you have to catch Thowable in main method to log all problems before exiting a application.

interface Executable {
void execute(Object args) throws Throwable;

class ExecutableImpl implements Executable {

public void doAll() throws IOException, FTPException {
throw new IOException();

public void execute(Object args) throws Throwable {
try {
} catch (Throwable th) {
throw th;


or do "throws Exception" in interface , no other changes are required,  but that will kind if lie to developers as you know that code could throw ExceptionInInitializerError :) even it mean to be RuntimeException.

Functional naming guides is not good for OOP

As you pass in parameter object - it have to be named as noun. Library method expect function. Function is a noun, so it is object.
Object Oriented languages have very good methodology for naming of all items, that let read code easily, mixing in different methodology that conflicts - it is not good approach.

-  names = FluentIterable.from(zipFiles).transformAndConcat(getTableNamesForZipFile).toSet();
+ names = FluentIterable.from(zipFiles).transformAndConcat(tableNamesForZipFileMaker).toSet();

  public <T> FluentIterable<T> transformAndConcat(
      Function<? super E, ? extends Iterable<? extends T>> function) {
    return from(Iterables.concat(transform(function)));

Name should be:
tableNamesForZipFileResolver, ...

It is ok to have no standard prefix/suffix for name, as all functions are different by type (different functional libraries).

Economizing on 2-5 letter in comparison  to use "get" prefix does not cost that.

Interesting compromise for naming function objects : column2Name, file2name, zipFile2Name