October 26, 2014

How to connect remote machine in Unix

Below command is useful to connect remote machine or server in Unix.

SSH <user>@<host name>


SSH anand@mymachine

October 16, 2014

URL Encoding in Java

Whenever we are passing data to any url or web services, some characters of the data might be un recognised. Hence, it is always better to encode data before sending to URLs or web services, which we call as URL encoding. We have pre defined apis in java to do this encoding.

Below is an example to show how to encode a string in java.

String str="Hello World";
java.net.URLEncoder..encode(str, "UTF-8");

The output for this code would be:


Convert an image to Base64

This post is to show how to generate base64 string to an image file.

Below is the method which will return the base64 string to the given image file.
The input for this method is the full path of the image.

    public String getBase64ForFile(String inFile) throws Exception {
        String base64 = "";
        System.out.println("inFile: " + inFile);
        URL url = new URL(inFile);
        InputStream fin = url.openStream();
        ByteArrayOutputStream bos = new ByteArrayOutputStream();
        int next = 0;
        while ((next = fin.read()) != -1) {
        base64 = "" + org.kobjects.base64.Base64.encode(bos.toByteArray());
        System.out.println("Base64: " + base64);

        return base64;

October 15, 2014

ERROR: Plugin 'Camera' not found, or is not a CDVPlugin. Check your plugin mapping in Cordova.plist

I am developing a MAF application in which I need to collect images from the user for which I provided a button. On click of the button, photo library supposed to be opened, so that the user can select the images. But on click of the button, I am getting the below error.

Plugin 'Camera' not found, or is not a CDVPlugin. Check your plugin mapping in Cordova.plist.

This is because the app is not granted access to required device capabilities.
To give the access, go to maf-application.xml and click on "Device Access", then grant access to required capabilities.

Below is the example where I granted for Camera and Files to avoid the above error.

October 12, 2014

How to enable Contribution Folders in Webcenter Content

If the “Contribution Folders” under Browse Content is not visible, please follow the below procedure to enable it.
  • Login to webcenter content
  • Under Administration menu, go to Admin Server and select “Component Manager” option
  • Select “advanced component manager” option

  • Under disabled components, select “Folders_g” and click on enable button
  • Please note that, while enabling “Folders_g”, if “FrameworkFolders” is enabled, then disable it, because both the options should not be enabled. Either of those should be enabled at a time
  • Now, you will see an alert message to restart the server
  • Restart the content server
  • After restart, if you login to webcenter content and go to “Browse Content”, you can see the “Contribution Folders”

October 10, 2014

How to make an entry of host file in Unix

Below is the procedure to make an entry of host file in Unix

  • Open host file: /etc/hosts
  • Make an entry to the file like below
           <ip> <hostname>
  • Save the file
  • And run below command to flush the DNS cache
           dscacheutil -flushcache

October 7, 2014

ADF_FACES-30108:The view state of the page has expired because of inactivity. Reload the page.

I have several tabs in my portal application, in which some of them are loading data from web services. Some times when I click on those tabs, an alert message with the below error message is displaying and on-click of Ok button, the app is reloading.

The error message:

ADF_FACES-60098:Faces lifecycle receives unhandled exceptions in phase RESTORE_VIEW 1
javax.faces.application.ViewExpiredException: viewId:/oracle/webcenter/portalapp/pages/home.jspx - ADF_FACES-30108:The view state of the page has expired because of inactivity.  Reload the page.


To ignore this error, I have written a filter which validates the app session on every navigation.  And my filter would look like,

package portal;

import java.io.IOException;

import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class MyFilter implements Filter {
    private FilterConfig fc = null;

    public MyFilter() {

    public void init(FilterConfig filterConfig) throws ServletException {
        fc = filterConfig;

    public void doFilter(ServletRequest servletRequest,
                         ServletResponse servletResponse,
                         FilterChain filterChain) throws IOException,
                                                         ServletException {
        String reqSessionID =
        String currentSessionID =
        String requestURI =
        boolean sameSession =
        System.out.println("currentSessionID == reqSessionID? : " + sameSession);
        if (!sameSession && reqSessionID != null) {
            System.out.println("Session is null");
        } else {
            filterChain.doFilter(servletRequest, servletResponse);
            System.out.println("Continue to servlet.");

    public void destroy() {
        fc = null;

Configured the above filter in web.xml file as below.
   <servlet-name>Faces Servlet</servlet-name>

October 6, 2014

How to delete MDS content of an application?

Below steps tell you how to delete MDS content of an application from EM console. 
  • Login to weblogic EM console
  • Under the domain (on left hand side), expand "Metadata Repositories" and select the target MDS. In this example, it is "mds-SpacesDS"
  • You can see the list of partitions under the section "Repository Partitions" 
  • Select the target partition
  • Click on "Delete..." button on top of the list and confirm
  • MDS content of the partition will be deleted.