Tuesday, May 9, 2017

MAVEN build plugins

Following plugins can be used to build jar file with sources embedded.

<!-- adding your sources into jar file -->


<!-- copying your resource folder into build directory -->
<!-- here the phase you need -->

<!-- copying your library folder into build directory -->

<!-- setting your main runner class -->

Wednesday, March 1, 2017

Object to JSON string mapper in JAVA

Following code can be used to convert JAVA objects to JSON string. You have to use jackson JAVA library for objects to JSON conversion.

RequestMessage requestMessage = new RequestMessage();
        RequestEntity requestEntity = new RequestEntity();

ObjectMapper mapper = new ObjectMapper();

Converted JSONstring will like this.


Monday, February 13, 2017

Install local jars in maven repository

Following command can be used to install local or internal jar files in maven repository.

mvn install:install-file -Dfile=d:/libs/test.jar -DgroupId=com.company.test -DartifactId=test -Dversion=1.0 -Dpackaging=jar

After installing jar files in maven repository, you can use the jar files in maven project as a dependency in pom.xml.


Sunday, February 5, 2017

JBoss EAP6.4 log4j deadlock error

JBoss6.4 is using log4j 'per deployment logging' function. That means, JBoss application server itself adding log4j into application. When using multiple log4j implementations, log4j deadlock scenario may be caused. To avoid that, it can be added 'jboss-deployment-structure.xml' file into JBoss application WEB-INF.

Error message
"http-/" #109 daemon prio=5 os_prio=0 tid=0x00007fa3e4163000 nid=0x636a waiting for monitor entry [0x00007fa3ae4e7000]
     java.lang.Thread.State: BLOCKED (on object monitor)
     at java.io.PrintStream.flush(PrintStream.java:335)

<!-- exclude the logging subsystem to disable deployment unit processors from running -->
<subsystem name="logging" />

Tuesday, January 3, 2017

Cross domain security error dwr

You can avoid security checking in client side in dwr by adding following code into web.xml file


Thursday, December 29, 2016

Remove last char in vi

Following Linux commands can be used to replace last character in vi editor.

1. Open file using vi editor
2. Run the following command to replace last char


3. Save file using :wq!

Sunday, December 18, 2016

Create soft link in Linux

Suppose you want to create shortcuts in Linux, you can use 'ln -s' command to create soft links.

Ex :- If you need to run JAVA6 and JAVA8 both from terminal, you have to add java6 and java8 commands to /usr/bin for terminal execution.

Steps to keep java6 and java8.

  1. Create two files in /usr/bin/ as java6 and java8
  2. Extract JAVA6 and JAVA8 to Linux file system. Suppose directory locations are /usr/java6/ and /usr/java8/
  3. Create Soft links for java6 and java8 using the following commands as root.

ln -s /usr/java8/jdk1.6.0_10/bin/java /usr/bin/java6

ln -s /usr/java8/jdk1.8.0_12/bin/java /usr/bin/java8

Now check versions using following commands in terminal.

java6 -version
java8 -version