Google Analytics

Friday, November 25, 2016

Oracle ADF weservice call org.xml.sax.SAXParseException

Oracle ADF soap Web service returns org.xml.sax.SAXParseException in debug mode.  When we validate the response XML, we observed some validation errors related/same to below error.

Error: org.xml.sax.SAXParseException: The prefix "urn" for element "urn:Coxxxxx-Interface-XXXXXXXXXX" is not bound.

Problem is resolved once we deploy the ADF EAR to the Standalone weblogic server. However we couldn't debug with intergrated weblogic.

Sunday, November 20, 2016

Java for loop escape one loop

To avoid an iteration use CONTINUE key word. Presentation

for (Vehicle printVehicle : getParkedVehicles()) {
if("VAN".equals(printVehicle.getVehicleType().toUpperCase())){
vanCount++;
if(vanCount == 2){
vanCount = 0;
continue;//SKip the iteration related to additional Van record
}
}
}

Collection.sort() method override

If need to sort a object considering it attributes, we can do as below.


//Some class
private void sortList(){
   // Sorting
   Collections.sort(getParkedVehicles(), new Comparator<Vehicle>() {
   @Override
    public int compare(Vehicle vehicle2, Vehicle vehicle1)
    {
          DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy/MM/dd HH:mm:ss");
          return LocalDateTime.parse(vehicle1.getEntryTime(),formatter).compareTo(                                                                                    LocalDateTime.parse(vehicle2.getEntryTime(),formatter));
                }
            });
    }

public class Vehicle {
    private String idPlate;
    private String brand;
    private String entryTime;



    public String getIdPlate() {
        return idPlate;
    }

    public void setIdPlate(String idPlate) {
        this.idPlate = idPlate;
    }

    public String getBrand() {
        return brand;
    }

    public void setBrand(String brand) {
        this.brand = brand;
    }

    public String getEntryTime() {
        return entryTime;
    }

    public void setEntryTime(String entryTime) {
        this.entryTime = entryTime;
    }
}


More details:
http://stackoverflow.com/questions/18441846/how-to-sort-an-arraylist-in-java

Java 8 Locale date

Existing classes (such as java.util.Date and SimpleDateFormatter) aren’t thread-safe and use package java.time

More info:
http://www.oracle.com/technetwork/articles/java/jf14-date-time-2125367.html
http://stackoverflow.com/questions/25747499/java-8-calculate-difference-between-two-localdatetime

Example:
Current date time:

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

LocalDateTime dt =  LocalDateTime.now();
//Format date time to String:
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy/MM/dd HH:mm:ss");
String entryDateTime = dt.format(formatter);

//Reverse formatting to LocalDateTime

LocalDateTime fromStartDateTime = LocalDateTime.parse(entryDateTime );
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy/MM/dd HH:mm:ss");
String strCurrDateTime = LocalDateTime.now().format(formatter);
LocalDateTime toCurrentDateTime =   LocalDateTime.parse(strCurrDateTime);//now    



Tuesday, November 8, 2016

Derby connection error ERROR XJ041: DERBY SQL error: ERRORCODE: 40000 in Oracle ADF 12C Alta UI

This issue occurred due to java version issue. Use Java 8 (Environment variable JAVA_HOME, set java path to Jdeveloper installation inbuilt JDK) with oracle ADF 12C.

More Details
http://stackoverflow.com/questions/33097205/derby-client-jdbc-driver-connection-error-failed-to-create-database-sample

Thursday, November 3, 2016

Tomcat Server Default Password

In tomcat add below lines to server.xml

<role rolename="manager-gui"/>
<user username="admin" password="admin" roles="manager-gui"/>


More details refer below:
https://www.mkyong.com/tomcat/tomcat-default-administrator-password/

Wednesday, November 2, 2016

tomcat server start java.net.SocketTimeoutException: Read timed out

If you see below errors it means you changed the port in the wrong place of the Server.xml .

Errors:
tomcat server start java.net.SocketTimeoutException: Read timed out
tomcat server standardserver.await: invalid command '' received

Locate 8080 port from server.xml and change the port to not using port