Posts

Showing posts from 2013

illegal reference to static field from initializer

I found an issue with build for one my projects, this project was working fine on my IDE (eclipse). When i used build tool i encountered this error. [echo] Compiling the source files .....     [javac] Compiling 54 source files to /comp/acserver/slaves/node/workspace/build/HelloWorld/build     [javac] /comp/acserver/slaves/node/workspace/src/com/pkg/config/Person1.java:32: illegal reference to static field from initializer     [javac]         logger=Logger.getLogger(CustomLogs.getLogName(Person1.class));     [javac]                                                                    [javac] /comp/acserver/slaves/node/workspace/src/com/pkg/config/SomeClass.java:28: illegal reference to static field from initializer     [javac]         logger=Logger.getLogger(CustomLogs.getLogName(SomeClass.class));     [javac]                                                                         [javac] /comp/acserver/slaves/node/workspace/src/com/pkg/config/ContextLookup.java:36: illegal reference

eclipse not publishing again to tomcat server after removing and adding back the project

Image
Many a time it happens that after removing a project from eclipse embedded server, once you try add back, the application does not get added properly. Some of the contents go missing while removing then adding adding the application back while eclipse publishes the application content into servers directory. This causes 404 error on browser as the application is not loaded inside the container. To avoid this situation, proceed as following 1. Goto add/ remove option by right clicking on the server. 2. Select remove on subsequent screen. 3. Clean the server Thereafter use option (1) to add back the application. This will ensure that application content are published successfully to server directory.

sun access manager, session not cleaned issue. Identity theft and impersonisation.

A high-security risk, leading to identity theft and impersonation. This security issue is mostly caused by lack of knowledge of security aspects on part of application developers/ architects. PROBLEM One person signs into a sun access manager policy-enabled application from a web browser. After completing his task, he signs out and goes home relieved of his/ her work. But this machine is in public access, say some kiosk or cyber cafe. Another user comes in and signs into the same application which the previous user used. Viola....he logs into an application as the first person instead. CAUSE Sun access manager is responsible for deleting cookies of the application, which stores session and may store some other credentials too. Now one can only delete the cookies that belong to it. So in case, Sun access manager agent resides in www.xyz.com domain (see the site URL in the address bar for respective sites), it cannot delete cookies from another application from www.abc.com

Trim zeros from decimal string

I came across one interesting requirement, where I had to clip zero's from the decimal formatted string. Sharing the code below. Requirement X.Y000 as X.Y 0.1000 as 0.1 1.000 as 1 Java method: private static final Pattern TRAILING_ZERO = Pattern. compile ( "[.]{1}[0-9]*(0)+$" );        public static String removeTrailingZeros(String digit){               if (digit== null ) return digit;               Matcher m= TRAILING _ZERO .matcher(digit);               if (m.find()){                      digit=digit.replaceAll( "0*$" , "" );                      if (digit.endsWith( "." ))                            digit=digit.replace( "." , "" );               }               return digit;        }  

Convert complex objects into xml

 There are many utilities like Xstream which can provide this functionality, but i did not find them easy to use, so i am putting this small utility to help unmarshelling complex objects into readable format for easier debugging. Most of the tools rely on toString method overrides to unmarshall the objects and fail to unwrap the multilevel nesting.   This code also converts strings containing xml or html into character data so that output remains readable in XML editors. There are two helper flags, sample output is as follows. 1. SIMPLE_TYPED = false and CANONICAL_TYPED = false  <ArrayList><String><String>mystery</String><Boolean><Boolean>true</Boolean><ArrayList><String><String>one</String><String><String>two</String></ArrayList></ArrayList> 2. SIMPLE_TYPED = true and CANONICAL_TYPED = false  <ArrayList:java.util.ArrayList><String:java.lang.String><String:String