Techies Experience

Friday, April 11, 2014

How to Resolve java.net.unknownhostexception in Jboss

Java Technlogy Updates : How to Resolve java.net.unknownhostexception in Jboss

How to Resolve java.net.unknownhostexception in Jboss


This post describes How to Resolve java.net.unknownhostexception in Jboss.
Many times we have seen when we start jboss we are facing one exception in jboss "java.net.UnknownHostException".

1:  java.net.UnknownHostException: localhost.localdomain: localhost.localdomain  
2:  at java.net.InetAddress.getLocalHost(InetAddress.java:1234)  
3:  at org.jboss.system.server.ServerInfo.getHostAddress(ServerInfo.java:233)  
How to resolve this Exception.One Quick solutions to resolve this exception is modify /etc/hosts configuration file in linux.
in this post will discuss how to modify /etc/hosts file and how to change entry in /etc/hosts file.

What is /etc/hosts file


The hosts file contains lines of text containing IP address in the first text field followed by one or more host names. Each field is separated by white space (blanks or seperated by tab).
Comment lines may be included; they are indicated by a hash character (#) in the first position of such lines. Entirely blank lines in the file are ignored.

For example,Hosts contains following details:
1:  # IPAddress Hostname        Alias   
2:  192.168.11.55 chkmmd051.kgnglobal.local chkmmd051   
3:  127.0.0.1 localhost.localdomain localdomain   
4:  ::1  localhost localhost.localdomain localhost6 localhost6.localdomain6   

The left column is the IP address to be resolved. The next column is that host's name and next columns are alias for that host. In the second line, for example, the IP address 192.168.11.55 is for the host chkmmd051.kgnglobal.local Another alias is chkmmd051.

to change this file will require root user permission, After you are finished configuration of your files, don't forget to restart your services and restart your jboss server for the changes to take effect.

References :
  1. How do I modify my hosts file? @ http://www.rackspace.com/knowledge_center/article/how-do-i-modify-my-hosts-file
  2. How to Modify /etc/hosts @ http://community.linuxmint.com/tutorial/view/159

Monday, April 7, 2014

How to Select Oracle Driver Version

Java Technlogy Updates : How to Select oracle Driver Version

How To select Oracle Driver Version


This post describes how to use diffrent JDBC drivers with diffrent JDK versions.
whenever we upgrdate our database or JDK we are facing Exceptions like "DriverManager.getConnection gives the Error: "No suitable driver".

Check this link for more information how to select oracle driver version and other database version.


Which JDBC drivers support which versions of Javasoft's JDK?


Below table shows how to use jdk and JDBC drivers.

Driver Compatibility Matrix
JDBC drivers Version Driver Type JDK Version
Oracle pre-8i OCI THIN Drivers JDK 1.0.x and JDK 1.1.x
Oracle 8.1.5 OCI and THIN Drivers JDK 1.0.x and JDK 1.1.x
Oracle 8.1.6 SDK THIN Driver JDK 1.1.x and JDK 1.2.x (aka Java2)
8.1.6 SDK OCI Driver JDK 1.1.x
8.1.6 OCI and THIN Driver JDK 1.1.x and JDK 1.2.x
8.1.7 OCI and THIN Driver JDK 1.1.x and JDK 1.2.x
9.0.1 OCI and THIN Driver JDK 1.1.x, JDK 1.2.x and JDK 1.3.x
9.0.2 OCI and THIN Driver JDK 1.1.x, JDK 1.2.x, JDK 1.3.x, and JDK 1.4.x
10.1.0 OCI and THIN Driver JDK 1.1.x, JDK 1.2.x, JDK 1.3.x, and JDK 1.4.x
10.2.0 OCI and THIN Driver JDK 1.2.x, JDK 1.3.x, JDK 1.4.x, and JDK 5.0.x

What are the jar files and supported JDK Installation.


Supported JDK Installation for Oracle Drivers.
Supported Jar File Java Version Remarks
ojdbc5.jar JDK1.5  
ojdbc5_g.jar JDK1.5 compiled with option -g
ojdbc5dms.jar JDK1.5 includes code to support Oracle Dynamic Monitoring Service
ojdbc5dms_g.jar JDK1.5 includes code to support Oracle Dynamic Monitoring Service
ojdbc6.jar JDK1.6 support basic functionality for the Thin and OCI drivers
ojdbc6_g.jar JDK1.6  
ojdbc6dms.jar JDK1.6 Oracle Dynamic Monitoring Service (DMS)
ojdbc6dms_g.jar JDK1.6 full JDBC logging support
In future whenever you upgrade Database version you have to conside appropriate JDK version.
References :
  1. Oracle Driver Version @ http://www.oracle.com/technetwork/java/hotspotfaq-138619.html
  2. Feature Matrix for Oracle Server JDBC drivers @ https://www.inetsoftware.de/products/jdbc-driver/oracle/features

Thursday, March 20, 2014

JDK-32-bit JVM-vs-64-bit JVm

Technology Update : What is diffrence between 32 bit JVM and 64 bit JVM.

What is diffrence between JDK 32 bit- & JDK 64 bit JVM ?


We have used jdk many times for java development but we facing one question every time
what is diffence between 32 bit jvm and 64 bit jvm?.

What is 64 bit JVM & 32 bit JVM ?


64 bit JVM runs in the 64-bit environment of a 64-bit OS on a 64-bit processor. The major differences between 32-bit and 64-bit jvm are the sizes of machine words,
the amount of addressable memory, and the Operating System memory in use.
The main advantage of Java in a 64-bit environment is the larger address space.
This allows for a much larger Java heap size and an increased maximum number of Java Threads,which required for large applications.
many user assume that we are using 32 bit to 64 bit environment means ,
we are doubled the size of Java Integers from 32 bit to 64 bit. we are not doing any modifications in JVM releated specifications.

When to use 32 bit and 64 bit JVM ?


If Java Application running on a system is required more RAM greater than 4GB then will use 64 bit
other caes 32 bit is fine.

How to check JVM is 32 bit or 64 bit


1.Using Java Version

Case 32 bit it will print
 java version "1.6.0_24"  
 OpenJDK Runtime Environment (IcedTea6 1.11.1) (rhel-1.45.1.11.1.el6-i386)  
 OpenJDK Server VM (build 20.0-b12, mixed mode)  

Case 64 bit it will print
 java -version  
 java version "1.6.0_24"  
 Java(TM) SE Runtime Environment (build 1.6.0_25-b06)  
 Java HotSpot(TM) 64-Bit Server VM (build 20.0-b11, mixed mode)  

2.Using System property sun.arch.data.model

one more option to find find whether JVM is 32 bit or 64 bit by using System.getProperty("sun.arch.data.model") at least on Sun's hotspot JVM. for 32 bit JVM "sun.arch.data.model" will be 32 and for 64 bit JVM this would be 64.
 System.out.println("32 /64 JVM Bit size: " + System.getProperty("sun.arch.data.model"));  
 Output:  
 JVM Bit size: 32 //JVM is 32 bit  
 JVM Bit size: amd64 //JVM is 64 bit  
3.Using System.getProperty("os.arch")

"os.arch" is another System property which you can use to find whether installed JRE or JVM is 32 bit or 64 bit. by name it sounds that it will return operating system arch but you can still give it a try. Though I haven't tested on all different JVM, I have read that it can indeed return JVM Bitness.If you try this on 64 bit machine and 32 bit JVM combination than please let us know what does it return. here is what it returns in case of 32 bit JVM:
 System.out.println("JVM Bit size: " + System.getProperty("os.arch"));  
 output :  
 JVM Bit size: x86 //on 32 bit JVM  
 JVM Bit size: amd64 //on 64 bit JVM  

5.Using java -d64 -version

using this command will get the below mentioned output.
 java -d64 -version   
 This Java instance does not support a 64-bit JVM.  
 Please install the desired version.  
That's all the ways we can used to check JVM is 32 bit or 64 bit. any improvements , suggestions are highly appreciated.
some references also you can check online here.

References :
  1. Check JDK 32 bit or 64 bit @ http://www.java.com/en/download/faq/java_win64bit.xml
  2. Lotus Media Centre @ http://lotusmediacentre.com/difference-between-32-bit-and-64-bit-jvm-choose-wisely/

Wednesday, March 12, 2014

How to use Jboss Tattletale

Jboss Tattletale :generates reports that will show dependencies and general information and duplication of jar files

JBoss Tattletale Introduction


Jboss Tattletale is tool will help you to understand your project structure, dependencies available in your project.


Below mentioned list of activities we can do with the help of Jboss Tattletale :

  1. Find dependencies between JAR files
  2. Find missing classes from the classpath
  3. Check for duplicated multiple JAR files
  4. Verify the SerialVersionUID of a class
  5. Jar file details with version numbers
  6. Unused JAR files/ sealed / signed JAR archives
  7. Locate a class in a JAR file
  8. Get the OSGi status of your project

JBoss Tattletale will recursive scan the directory pass as the argument for JAR files and then build the reports as HTML files.

How to use Jboss Tattletale in your project.


Prerequisites to install jboss tattletale is JDK 1.5 or higher version is required.

How to install jboss tattletale


you can download jboss tattletale from site http://www.jboss.org/tattletale/downloads once donwload is complete
you can extract the same using command

 unzip jboss-tattletale-1.1.1.GA.zip  
or

 tar xzf jboss-tattletale-1.1.1.GA.tar.gz  

How to Configure tattletale


you can do the tattletale configuration in this file. this file is located under main directory.

Tattletale command to generate analysis Report

 java -Xmx512m -jar tattletale.jar [-exclude=<excludes>] <scan-directory> [output-directory]
command used for generating below Report.
 java -Xmx512m -jar tattletale.jar /home/ISG/deepak641/Desktop/DESKTOP/MyServers/jboss-5.1.0.GA/  
You will get output like this in HTML format.

JBoss Tattletale 1.1.2.Final


Dependencies


Reports

Archives


Generated by: JBoss Tattletale 1.1.2.Final check each and every link manually you will get respective detail report.

References :

  1. Check Jboss Tattletale Guide @ http://www.jboss.org/tattletale
  2. SVN Repository @ http://anonsvn.jboss.org/repos/tattletale

Tuesday, March 11, 2014

How to Integrate Struts 1.x with Struts 2.x.

How to Integrate Struts 1.x with Struts 2.x Before diving into the integration of Struts framework,
let us first take a look at the Struts 1.x and 2.x configuration separately. suppose we have an exisisting web Application and we need to integrate struts 1.x application to struts 2.x .

Struts 1.x web.xml file


 <?xml version="1.0" encoding="ISO-8859-1"?>  
 <!DOCTYPE web-app  
  PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN"  
  "http://java.sun.com/j2ee/dtds/web-app_2_2.dtd">  
 <web-app>  
  <!-- Standard Action Servlet Configuration (with debugging) -->  
  <servlet>  
   <servlet-name>action</servlet-name>  
   <servlet-class>  
       org.apache.struts.action.ActionServlet  
      </servlet-class>  
   <init-param>  
    <param-name>application</param-name>  
    <param-value>ApplicationResources</param-value>  
   </init-param>  
   <init-param>  
    <param-name>config</param-name>  
    <param-value>/WEB-INF/struts-config.xml</param-value>  
   </init-param>  
   <init-param>  
    <param-name>debug</param-name>  
    <param-value>2</param-value>  
   </init-param>  
   <init-param>  
    <param-name>detail</param-name>  
    <param-value>2</param-value>  
   </init-param>  
   <init-param>  
    <param-name>validate</param-name>  
    <param-value>true</param-value>  
   </init-param>  
   <load-on-startup>2</load-on-startup>  
  </servlet>  
  <!-- Standard Action Servlet Mapping -->  
  <servlet-mapping>  
   <servlet-name>action</servlet-name>  
   <url-pattern>*.do</url-pattern>  
  </servlet-mapping>  
  <!-- Struts Tag Library Descriptors -->  
  <taglib>  
   <taglib-uri>/WEB-INF/struts-bean.tld</taglib-uri>  
   <taglib-location>/WEB-INF/struts-bean.tld</taglib-location>  
  </taglib>  
  <taglib>  
   <taglib-uri>/WEB-INF/struts-html.tld</taglib-uri>  
   <taglib-location>/WEB-INF/struts-html.tld</taglib-location>  
  </taglib>  
  <taglib>  
   <taglib-uri>/WEB-INF/struts-logic.tld</taglib-uri>  
   <taglib-location>/WEB-INF/struts-logic.tld</taglib-location>  
  </taglib>  
 </web-app>  



Struts 2.x web.xml file


 <!DOCTYPE web-app PUBLIC  
  "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"  
  "http://java.sun.com/dtd/web-app_2_3.dtd" >  
    
 <web-app>  
      <display-name>Struts 2 Web Application</display-name>  
    
      <filter>  
           <filter-name>struts2</filter-name>  
           <filter-class>  
         org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter  
         </filter-class>  
      </filter>  
    
      <filter-mapping>  
           <filter-name>struts2</filter-name>  
           <url-pattern>/*</url-pattern>  
      </filter-mapping>  
    
 </web-app>  

web.xml after Integration
  <!DOCTYPE web-app PUBLIC   
  "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"   
  "http://java.sun.com/dtd/web-app_2_3.dtd" >   
     
  <web-app>   
    <display-name>Struts 2 Web Application</display-name>   
      <!-- mapping for struts 2.x -->    
    <filter>   
       <filter-name>struts2</filter-name>   
       <filter-class>   
      org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter   
      </filter-class>   
    </filter>   
     
    <filter-mapping>   
       <filter-name>struts2</filter-name>   
       <url-pattern>/*</url-pattern>   
    </filter-mapping>   
      <!-- mapping for struts 1.x -->  
            <servlet>  
           <servlet-name>action</servlet-name>  
           <servlet-class>org.apache.struts.action.ActionServlet</servlet-class>  
           <init-param>  
                <param-name>config</param-name>  
                <param-value>/WEB-INF/struts-config.xml</param-value>  
           </init-param>  
           <init-param>  
                <param-name>debug</param-name>  
                <param-value>3</param-value>  
           </init-param>  
          <init-param>  
                <param-name>detail</param-name>  
                <param-value>3</param-value>  
           </init-param>  
           <load-on-startup>0</load-on-startup>  
           </servlet>  
           <servlet-mapping>  
                <servlet-name>action</servlet-name>  
                <url-pattern>*.do</url-pattern>  
           </servlet-mapping>  
             
 <servlet>  
     
  </web-app>   
do let me know your comment.

Tuesday, March 4, 2014

Free Maker template error in Struts 2

While doing struts 2 project deployments we are facing one major issue related to free marker template.

Free Marker Error in Struts 2

Quick solution to fix this issue is either upgrade the jar files struts2-core-2.0.6 and xwork-2.0.1 to higher version or else we need to add below mentioned tag in respective jsp page.
add below mentioned tag in header section of that page.

 <sx:head debug="false" parsecontent="true">  

Jboss 4 to Jboss 5 migration Steps

Jboss 4 to Jboss 5 migration steps

Jboss Application server version 4.x to Jboss Application server version 5.x migration steps


This document is guide for upgrading JBoss Application Server version 4.x to JBoss Application Server 5.x.
I'm sharing here my experience while doing migration from jboss 4 to jboss 5.

Below mentioned Steps we are implemented while doing migration from jboss 4 to jboss 5.

  1. Check Jboss Structure.
  2. Create checklist of jar files.
  3. Keep only application specific jar files in your application.
  4. Check version of jar files like servlet.jar.
  5. Jar file details with version numbers.
  6. Remove Unwanted JAR Files which are conflicting with jboss 5.
  7. Move common files under JBOSS_HOME/common/lib

References :

  1. Jboss Community Upgrade Guide - JBoss 4 to 5 @ https://community.jboss.org/message/757106
  2. D-Zone @ http://java.dzone.com/articles/migrating-jboss-4-jboss-5
  3. Migrating-your-application-jboss-4x-jboss-5x @ migrating-your-application-jboss-4x-jboss-5x