Showing posts with label java. Show all posts
Showing posts with label java. Show all posts

Monday, July 27, 2015

Useful Java syntaxes.

org.apache.commons.lang3.Validate

This class assists in validating arguments. The validation methods are based along the following principles:  

———————————————————————————

Monday, April 27, 2015

Pretty printing SOAP messages. (60 of 285 technotes for 2015)

Handy Java code to print SOAPMessages

References: - http://bit.ly/1dkVWoW


public static String getSOAPMessageAsString(SOAPMessage soapMessage) {
     try {

        TransformerFactory tff = TransformerFactory.newInstance();
        Transformer tf = tff.newTransformer();

        // Set formatting
       
        tf.setOutputProperty(OutputKeys.INDENT, "yes");
        tf.setOutputProperty("{http://xml.apache.org/xslt}indent-amount",
              "2");
       

        Source sc = soapMessage.getSOAPPart().getContent();

        ByteArrayOutputStream streamOut = new ByteArrayOutputStream();
        StreamResult result = new StreamResult(streamOut);
        tf.transform(sc, result);

        String strMessage = streamOut.toString();
        return strMessage;
     } catch (Exception e) {
        System.out.println("Exception in getSOAPMessageAsString "
              + e.getMessage());
        return null;
     }

  }

Saturday, February 28, 2015

How to Configure Tomcat 7 Eclipse Luna IDE for JEE Developers

Step 1. Install Java 

image

Step 2. Download Tomcat from web site to a location where you want to install Tomcat. for eg: C:xxxxapache-tomcat-7.0.57

Step 3. Create environment variables 

JAVA_HOME=C:Program FilesJavajdk1.8.0_25

JRE_HOME=C:Program FilesJavajre1.8.0_25

Step 4. Download eclipse and unzip at a proper location C:xxxxeclipse-jee-luna-R-win32-x86_64

image

Step 5: Follow the remaining steps below to configure tomcat in eclipse

image
image
image

Double click on the server and select the server location -> to use Tomcat installation.

image


Step 6. Configure Users and Groups for Tomcat

Open tomcat-users.xml file under C:xxxxapache-tomcat-7.0.57conf and add the user and the roles.

 <role rolename=“manager-gui”/>
 <role rolename=“admin-gui”/>
 <user password=“tomcat” roles=“manager-gui,admin-gui” username=“tomcat”/>


Step 7. Start the server. The admin console url is http://localhost:8080/

image