Posts

How to  Implement a Fall-Back Feature How will you handle the situation when you have a big release which consists of multiple modules being integrated in one go for Production Release of your appilcation ?  Taking into consideration there might be issue with any of one of ingredient module’s code, will make entire application do go down - and hence the business will be down. A simple flaw in one file may make your entire application to get down. = Here is the approach:  Design a Table in database which will hold two columns ModuleNames and  flag. ModuleName will store the name of multiple modules which are being released in current release. When the application starts it reads the ModuleName & Flag in memory.  We may store the value from the following table in a static HashMap as  < String, boolean > . Module_id (PK) Module_Name isEnabled (Flag) Dependent_Module_id(FK) 1 Prot...
MAVEN : How to read Jar files or library from intranet of your Company. You might be given the POM.XML information to download the jars, like: Maven Plugin : explanation: < dependency >    < groupId >com.mycompany.165654.GMNABRAVE.PUSH< /groupId >    < artifactId >GMPPUSH< /artifactId >    < version >GMNABRAVEPUSH-3.0.1< /version > < /dependency > Means look SETTING.XML  it should have URL and location of above JAR, like: < repository > < id >releases< /id > < url >http://sd-879d-d482:8081/nexus/content/repositories/releases< /url > < releases > < enabled >true< /enabled > < /releases > < /repository > < repository > It means go to browser and open the following link. There you will see the required JAR: http://sd-879d-d482:8081/nexus/content/repositories/snapshots/com/mycompany/165654/GMNABRAVE/PUSH/GMPPUSH...
MVN Build: Sometime you will see the MVN build in Eclipse is failing and the same is successful in command promt. Here are some commands that you can use to run on command prompt. C:\ mvn clean install -X To escapre test cases: C:\ mvn clean install -X -DskipTests

SonarLint & SonarQube implementation in your Project

Image
SonarQube : SonarQube is very strong tool available for Code review. How to integrate the   plugin into your Development studio, ie. Eclipse or STS. Go to, Eclipse -> Help -> Install New Software-> And enter there  “http://downloads.sonarsource.com/eclipse/eclipse/” Checking the code ceoverage: Go to SonarQube view - > SonarLInt: http://eclipse.sonarlint.org/ Then Run the GREEN ALAYZE on SonarQube(that will be for SonarLint):-> Sometimes you might get SonarQube errors indicating you to change the code, which you might not want to do because of any reason. Then you can write //NOSONAR next to the line. This will discard the block  or the line where you write this comment.

RTC - Repository : How to Revert Back the Changes

Image
HOW TO REVERT BACK THE CHANGES WHICH HAVE COMMITED INTO RTC REPOSITORY: = IN ECLIPSE Right click on the owning component in the Pending Changes view and select Show->History. The change set will appear in the History view.   Right click on the change set and choose Discard... This will discard the change set from your workspace. So your workspace should now have all change from the stream *except* the one you want to remove. You can verify this by checking that your bad change set is the only thing you see Incoming.   Right click on the component and choose "Replace in [your stream name]..."  RTC (Jazz) : How to point your stream to different stream and take codes into your local: Example: you have local worskapce set up from dev stream, but now you have PATCH stream and want to take latest code. Go to ‘Pending Changes’ and select “Change Flow Target” to the required stream. How to remove namespace from xml file ? Step 1: ...
Image
Hibernate - How to implement a 'Composite Key' : Suppose we have a Table in database which has many coulumns, among which two columns are PRIMARY KEY : UNIQUE_ID, NOTIFICATION_CHANNEL. We will write a separate Class which will contain these two columsn which are a part of COMPOSIT PRIMARY KEY. We will write a separate class for rest of the fields in that Table; and this class will also hold the reference of COMPOSIT PRIMARY KEY classs :->

Writing Test Cases

Image
1. Writing Test Cases for POJO classes Most of the time we need to write test cases for POJO classes. So that Test case Coverage can shoot up. We need to identify the package where we have pojo classes and count the number of POJO classes present on that package. Add 1 into the total count which will include the JUnit test class for  itself. For example if there are 4 POJO classes for which you wish to write test cases, write the "EXPECTED_CLASS_COUNT = 5;" into your test case. Here is the example:-- Add dependency in POM.XML:-               < dependency >                      < groupId > com.openpojo </ groupId >                      < artifactId > openpojo </ artifactId > ...

Spring Security

Image
             Security is the primary need of any web based application as it provided security from un-authorized access of your application. Spring Framework has API defined which can be configured and used in any Java web application.    There are two of the terms widely used in Security world - Principle ,  Authentication and Authorization . As these words itself are self explanatory; Principle - it can be a user, device or system. Most of the time it is a User. Authentication means checking the authentication, i.e. userid and password of a user. Authorization means authorizing a user to decide whether she should be allowed to access a resource on web application. Things we are going to learn here are:- 1. Designing a Login and Logout page which will ask for  userId/pwd 2. Storing encrypted pwd into database which will authenticate users. 3. Verifying authorization of any user before displaying...

How generate UML Diagram in Eclipse ( Reveres Engineering)

Most of the time it happens that we need to do reverse engineering from the existing Java codes. We have the code in Eclipse project and want something light and very handy to get Class Diagrams & Sequence Diagram generated from all those codes. Here is the best solution for this Reverse engineering : ObjectAid Yes, ObjectAid is an UML tool which has its plugin. How to Use ObjectAid plugin ? Go to Eclipse --> Help --> Install New Softwares --->   Click on "Add" and enter the following: Name: UML Plugin Location: http://objectaid.com/update/current Click OK. You will get the plugin installed in your eclipse. Restart the eclipse. Go to "Package Explorer" and right click on the package for which you want to generate the Class and Sequence diagram. Right click and --> New ---> Other ----> ObjectAid --> Class Diagram or Sequence Diagram. And now your Class Diagram / Sequence diagram is ready now.

HTML 5

What is DOM When your browser renders a web page, it constructs a Document Object Model (DOM) , a collection of objects that represent the HTML elements on the page. Every element — every , every , every — is represented in the DOM by a different object. (There are also global objects, like window and document, that aren’t tied to specific elements.) HTML5 defines over a dozen new input types that you can use in your forms. < input type="search" > for search boxes :  < input type="number" > for spinboxes < input type="range" > for sliders < input type="color" > for color pickers < input type="tel" > for telephone numbers < input type="url" > for web addresses < input type="email "> for email addresses < input type="date" > for calendar date pickers < input type="month" > for months < input type="week" > fo...

Tools to use

Process mapping tool : which is online version of Visio :-   http://www.gliffy.com My Eclipse (Juno) is not showing Maven option while creating new Project. Resolution : go to Eclipse -; Help - Market place and serch there for "Maven Integration for Eclipse WTP" and Next -next-FInish. Which Online Decompiler is best to use ? Resolution : How to Create project from existing ant file with project ? look at : http://www.ahristov.com/tutorial/java-compiler/eclipse.html How to create maven based project ? Please refer this link: http://emrpms.blogspot.in/2012/11/spring-security-hello-world-example.html How to Stop JBoss in Window OS: jboss/bin/ RUN THIS CMMAND  jboss-cli --connect command=:shutdown What are the difference between different names of Eclipse and what does they mean ? = Release Date Platform version Projects Kepler 26 June 2013 4.3 Kepler Projects Juno 27 June 2012 4.2...

Oracle Database

What is Object in Oracle? = This concept is almost analogue to Java Object. Oracle object types are user-defined types that make it possible to model real-world entities such as customers and purchase orders as objects in the database.When you create a variable of an object type, you create an instance of the type and the result is an object. An object has the attributes and methods defined for its type. Because an object instance is a concrete thing, you can assign values to its attributes and call its methods. Defining an object type does not allocate any storage. Let us see example to learn how to create and use Object in Oracle. First, define an Object Type, i.e data type: Example: CREATE TYPE person_typ AS OBJECT ( idno NUMBER, first_name VARCHAR2(20), last_name VARCHAR2(25), email VARCHAR2(25), phone VARCHAR2(20), MAP MEMBER FUNCTION get_idno RETURN NUMBER, CREATE TYPE BODY person_typ AS MAP MEMBER FUNCTION get_id...

Java Performance

How to check the Memory used by Java class CheckMemory{ public static void main(String[] a) { Runtime rt = Runtime.getRuntime(); System.out.println(" Free memory: " + rt.freeMemory()); System.out.println("Total memory: " + rt.totalMemory()); while (true); } } To cehck its usage at Client and Serverside run them like:- Client Side - JVM Usage:- C:\>\progra~1\java\jdk1.6.0_02\bin\java LongWhile Free memory: 4997088 Total memory: 5177344 ServerSide JVM usage:- C:\>\progra~1\java\jdk1.6.0_02\bin\java -server LongWhile Free memory: 4997088 Total memory: 5177344

Exceptions encountered during Development

Miscellaneous Exceptions :-  You might encounter various exceptions while developing a Project with Spring and Hibernate. I have depicted few of them here and their solutions:- 1. SEVERE: Context initialization failed org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in ServletContext resource [/WEB-INF/spring-servlet.xml]: Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: org/apache/commons/collections/map/LRUMap Solution:-      Use commons-collections.jar 2. SEVERE: Servlet.service() for servlet spring threw exception org.springframework.beans.factory.BeanNotOfRequiredTypeException: Bean named 'org.springframework.transaction.interceptor.TransactionInterceptor#0' must be of type [org.aopalliance.aop.Advice], but was actually of type [org.springframework.transaction.interceptor.TransactionInterceptor] Solution:-  It might be due to  ...