Saturday, March 29, 2014

MongoDB: Convert data getting from MongoDB into JSON Format

Today I am working on one of the use case in which I have to integrate MongoDB with Oracle SOA and expose a rest service from Oracle SOA which output the response as a JSON String. As Oracle does not provide any out of box functionality or adapters to connect with mongoDB,  so I am using the mongodb java drivers library to access the Mongo database in SOA using Java embedding activity.
In general we use the json data to interact with mongo db and I am using the same in Oracle SOA to interact with mongo db.

This blog post is about the problem faced by many developers to convert the data getting from mongo db to JSON String. Now query for getting the whole data for particular collection is :
DBCursor cursor = collection.find();
here collection is a object of class com.mongodb.DBCollection and cursor is an object of class 
Now one way to iterate over all the data is to use following:

DBCursor cursor = collection.find( query );
 if( cursor.hasNext() )
 DBObject obj =;

or another way is to convert cursor object into the json string using serialize method of  com.mongodb.util.JSON class and return back this json string as a response.

Please find below the example to convert DBCursor into JSON String.

package poc.nile.test;

import com.mongodb.DBCollection;
import com.mongodb.DBCursor;
import com.mongodb.MongoClient;
import com.mongodb.util.JSON;


public class DBTest {
    public static void main(String arg[]){
         MongoClient mongoClient;
         String host= "localhost";
         int port=27017;
         String dbName="test";
        try {
           mongoClient = new MongoClient(host,port);
           DBCollection collection = mongoClient.getDB(dbName).getCollection("products");
          DBCursor cursor = collection.find();
         JSON json =new JSON();
        String serialize = json.serialize(cursor);
       } catch (UnknownHostException e) {
                // TODO Auto-generated catch block

Wednesday, March 19, 2014

Jdeveloper not able to start: Caused by: org.xml.sax.SAXParseException: : XML-20108: (Fatal Error) Start of root element expected.

Some times it happened that Jdeveloper is not able to start or you create a new application/project in Jdeveloper you are getting the following error:

Caused by: org.xml.sax.SAXParseException: <Line 1, Column 1>: XML-20108: (Fatal Error) Start of root element expected.

And application/project is not created.
I got this error while creating the SOA project in jdeveloper


  1. Go to the system folder i.e C:\Users\username\AppData\Roaming\JDeveloper\system11.
  2. Delete the system folder.
  3. Restart Jdeveloper.
Note: This is just a workaround of this problem. After deleting the system folder you will loose some information like database connection details, MDS connection details, in that case you have to create all those required connection again.

Friday, March 14, 2014

ORA-01110: data file 6: Database not open and can't find the path of data file ""

Reason: Sometimes by mistake you have deleted the DBF files and while accessing the database you get the following exception:

ORA-01110: data file 6: Database not open. Can't find the path of data file "C:\oraclexe\xe\oradata\weblogic_Data01.DBF"


offline drop of datafile:
In Oracle if you wish to delete DBF file and tablespace or schema you run the drop command to delete tablespace and physically remove the DBF file from the disk.
But sometimes you don't need to physically remove the file and just delete the tablespace offline i.e. Oracle will not access the tablespace or DBF file anymore but the file is still on the disk.

In the above problem, you have deleted the physical DBF file from the disk but oracle is still accessing that DBF file. In that case delete the DBF file offline by running the following command:

alter database datafile 'C:\oraclexe\xe\oradata\weblogic_Data01.DBF' offline drop;

then restart the database.

Note: Offlining of datafile is used when you have to delete the tablespace and also you can recover the data file on later date.

Thursday, March 13, 2014

ORA-00838: Specified value of MEMORY_TARGET is too small, needs to be at least 180 M

Reason: This exception occurs when the user is trying to allocate an SGA or PGA size more than what is allocate to the database. This may also occur when the user is trying to allocate the database less memory than the minimum requirement.


1)      First create a temporary pfile from current spfile:
2)      Sql command : Create  pfile=<filepath>/filename from spfile;
3)      Open the pfile and edit value of MEMORY_TARGET and set to required value, then create spfile from this modified pfile:
4)      Sql command: create spfile from pfile=<filepath>/filename
5)      Restart the database using SQL command: Startup

Tuesday, March 11, 2014

Webcenter Content: Java update_51 Applet Security warning : Your security setting have blocked an untrusted application from running

I have updated my java to jdk 1.7.0 update 51, while accessing the java applets I am getting the following error:

 Your security setting have blocked an untrusted application from running


  1. Go to control panel, click on Java.
  2. Click on Security tab.
  3. set the security level medium.
  4. Click on Edit Site List... and add the url i.e
  5. Click Apply and Ok to save changes made to the java control panel.

Wednesday, March 5, 2014

Caused by : java.lang.NoClassDefFoundError: javax.xml.rpc.Service

Exception : java.lang.NoClassDefFoundError: javax.xml.rpc.Service

Reason : This exception occur while calling the webservice proxy client from java application and it is due to the missing of weblogic.jar library.

Workaround :  Add the jar file to the project classpath. you can find this jar file at



you can add the library in jdeveloper like this