December 26, 2014

Sending Parameters to URL or web service in POST Method

Below code snippet explains how to send parameters to a web url in the POST method.
URL url = new URL(“http://testulr/searchuser”);
HttpURLConnection urlConnection = (HttpURLConnection) url.openConnection();
String params=”userid=”+userid+”&username=”+name;
OutputStream out = new BufferedOutputStream(urlConnection.getOutputStream());
BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(out));
InputStream in = new BufferedInputStream(urlConnection.getInputStream());
BufferedReader reader = new BufferedReader(new InputStreamReader(in));
StringBuilder st = new StringBuilder();
String line = "";
while ((line = reader.readLine()) != null) {
System.out.println("Result: "+st);
If the url is secured then replace HttpURLConnection class with HttpsURLConnection in the above code.

December 11, 2014 file is missing in android application

While working with an android application in eclipse, some times the file may missed out from the application. This is because the XML files in the app may have errors. So, resolve those errors in the XML files and then clean the project. Now the file will be automatically created.

November 20, 2014

android.content.ActivityNotFoundException: Unable to find explicit activity class

I am developing an android application. On the home screen, it has a button, on click of this an activity should be displayed. While testing the app, on click of the button, the app is giving the below error and the app got terminated.

E/AndroidRuntime(Number): java.lang.RuntimeException: Unable to resume activity {app package}: android.content.ActivityNotFoundException: Unable to find explicit activity class {activity class}; have you declared this activity in your AndroidManifest.xml?

The solution for this is,

Every activity created in android application should be configured in AndroidManifest.xml of the app. To do so, open AndroidManifest.xml and goto Application tab. Under Application Nodes, add all the activities. 

November 5, 2014

Error: oracle.jdevimpl.deploy.common.Jsr88RemoteDeployer

I am developing a REST web service. While deploying the web service to the application server, I got the below error.

Remote deployment failed (oracle.jdevimpl.deploy.common.Jsr88RemoteDeployer)

The error occurred because my web service has two methods with the same path name. After changing the path names, the issue got resolved and the web service was deployed successfully to the server. 

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";, "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 = != -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 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.

September 30, 2014

Undeploy app from EM console

This post is to tell how to undeploy an installed application from EM (Enterprise Manager) console.
Below are the steps to do the same.

  • Login into em console
  • Expand the domain
  • Expand Application Deployments and then Internal Applications
  • Select the application and right click on that
  • From Application Deployment menu, select "Undeploy..." option (see the below image)
  • It will open the confirmation screen, click undeploy button on top of the screen and proceed the instructions to undeploy the app.

September 10, 2014

Displaying alert message on AMX page from Managed Bean

Below java code is useful to display alert messages on AMX pages in MAF from managed bean.

   "function(){navigator.notification.alert('<message>',  function(){}, '<alert-title>', '<button-text>');}",
   new Object[] { });


"function(){navigator.notification.alert('Request has been submited.',  function(){}, 'Information', 'OK');}", new Object[] { });

<feature-id> is the id of the feature on which you want to display the alert message
<message> is the message you want to display on the alert box
<alert-title> is the tile you want to display on the alert box
<button-text> is the text to be displayed on the button on alert box

Install apk file in Android emulator

In the command prompt, go to the path of bin folder under android sdk and run the below command.

adb install <apk file>

June 16, 2014

java.sql.SQLException: Protocol violation

Exception in thread "main" java.sql.SQLException: Protocol violation: [1]
                at oracle.jdbc.driver.T4CTTIfun.receive(
                at oracle.jdbc.driver.T4CTTIfun.doRPC(
                at oracle.jdbc.driver.T4C7Ocommoncall.doOLOGOFF(
                at oracle.jdbc.driver.T4CConnection.logoff(
                at oracle.jdbc.driver.PhysicalConnection.close(

Connection con=createConnection();

Here, commit() is invoked after the connection is closed, hence the above exception occurred.

java.lang.ArrayIndexOutOfBoundsException while executing batch Statements in Java

I have created a PreparedStatement to execute a batch of insert statements. But while executing,  the below exception occurred.

java.lang.ArrayIndexOutOfBoundsException: 22 at oracle.jdbc.driver.T4CNumberAccessor.unmarshalOneRow( at oracle.jdbc.driver.T4C8Oall.readRXD( at oracle.jdbc.driver.T4CTTIfun.receive( at oracle.jdbc.driver.T4CTTIfun.doRPC( at oracle.jdbc.driver.T4C8Oall.doOALL( at oracle.jdbc.driver.T4CPreparedStatement.doOall8( at oracle.jdbc.driver.T4CPreparedStatement.executeForRows( at oracle.jdbc.driver.OraclePreparedStatement.executeForRowsWithTimeout( at oracle.jdbc.driver.OraclePreparedStatement.executeBatch( at oracle.jdbc.driver.OracleStatementWrapper.executeBatch( at XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX 


After googling, I realized that the PreparedStatement is not accepting more than 6 parameters. Below is the statement I have used.
PreparedStatement stmtQuestions = conDB.prepareStatement("INSERT INTO "+Properties.DB_TABLE +" values(?,?,?,?,?,?,?)");
I changed the statement to below which avoid the above exception and program was executed successfully.
Statement stmtQuestions=conDB.createStatement();
String query="INSERT INTO "+Properties.DB_TABLE +" values('"+id+"',"+sid+","+qid+",'"+sqText+"','"+sqSText+"','"+qType+"','"+qoType+"')";

May 14, 2014

Using excel file as DB and read data from Java

We can use an excel file as a data base. Using java we can create connection to excel file and execute sql query as we do with database. Use the below code to use excel file as a DB and read data from it using java.

String stExcelFile=”c:\\temp\\test.xls”;
String stSheetName=”Sheet1”;
        Connection conExcel =
            DriverManager.getConnection("jdbc:odbc:Driver={Microsoft Excel Driver (*.xls)};DBQ=" +
                                        stExcelFile +
        Statement stmtExcel = conExcel.createStatement();
        ResultSet rsExcel =stmtExcel.executeQuery("Select * from [" + stSheetName + "$]");
while ( {
System.out.println(“id: ”+rsExcel.getString(“id”)));
System.out.println(“name: ”+rsExcel.getString(“name”)));

April 24, 2014

oracle.jbo.DMLException: JBO-27200: JNDI failure. Unable to lookup Data Source at context jdbc/Connection1DS


<LifecycleImpl> <_handleException> ADF_FACES-60098:Faces lifecycle receives unhandled exceptions in phase RENDER_RESPONSE 6
oracle.jbo.DMLException: JBO-27200: JNDI failure. Unable to lookup Data Source at context jdbc/Connection1DS
                at oracle.jbo.server.DBTransactionImpl.lookupDataSource(
                at oracle.jbo.server.DBTransactionImpl2.connectToDataSource(
                at oracle.jbo.common.ampool.DefaultConnectionStrategy.connect(
                at oracle.jbo.server.ApplicationPoolMessageHandler.doPoolConnect(
                at oracle.jbo.server.ApplicationPoolMessageHandler.doPoolMessage(
                at oracle.jbo.server.ApplicationModuleImpl.doPoolMessage(
                at oracle.jbo.common.ampool.ApplicationPoolImpl.sendPoolMessage(


Check the connection in AppModule. To check,

  • Right click on AppModule
  • Select Configurations option
  • In the Names, select AppModule Local, the corresponding properties will be displayed on the right side of the window
  • Check the JDBC Name/Data source value. It should be the name which you have given to the connection created in your application. If the value is not correct, Select the property and click on Edit button to change the value

February 25, 2014

Invoking constructor twice in JSFF with panelTabbed component

I have a JSFF page which has panelTabbed component with four tabs and one of the tabs is displaying data from a managed bean. While loading the page, the bean constructor is being called twice. To avoid this add the below property to the panelTabbed tag,  which will avoid loading the tab data until it shows.


February 24, 2014

Fitting ADF application in an html iFrame

If you want to display or fit an ADF application in an iFrame, you have to add below  statement to web.xml file.


Content Compression

Add the below statement to the web.xml to disable content compression so that we can see the fusion css classes to each component.


Including a JSF page into another JSF page

Like jsp page, we can also include a JSF page into another JSF page by using the same jsp directive jsp:include.


<jsp:include page="test.jspx" flush="true"></jsp:include>