Friday, October 10, 2014

MongoDB in Windows- error system cannot find the file specified

When you start MongoDB from the command prompt (not from the bin folder), you may get this error saying "error system cannot find the specified". This doesn't give you enough information on what triggers this error. Go to the respective bin folder of MongoDB and start the MongoDB, you will get the below error. The default db path for mongodb is /data/db/, MongoDB checks if /data/db/ is present and if the user has access to it. In your case, there is no such directory and hence the error.

mongod.exe --help for help and startup options
2014-10-10T17:45:58.896+0530 [initandlisten] MongoDB starting : pid=10100 port=27017 dbpath=\data\db\ 64-bit host=EEI3054
2014-10-10T17:45:58.897+0530 [initandlisten] targetMinOS: Windows 7/Windows Server 2008 R2
2014-10-10T17:45:58.897+0530 [initandlisten] db version v2.6.5
2014-10-10T17:45:58.897+0530 [initandlisten] git version: e99d4fcb4279c0279796f237aa92fe3b64560bf6
2014-10-10T17:45:58.897+0530 [initandlisten] build info: windows sys.getwindowsversion(major=6, minor=1, build=7601, platform=2
2014-10-10T17:45:58.898+0530 [initandlisten] allocator: system
2014-10-10T17:45:58.898+0530 [initandlisten] options: {}
2014-10-10T17:45:58.903+0530 [initandlisten] exception in initAndListen: 10296
ERROR: dbpath (\data\db\) does not exist.
Create this directory or give existing directory in --dbpath.
, terminating

However you can override the default db path using the --dbpath argument of mongod. Try running the below command. I have provided dbpath of my configuration, you can change it where you want to have it.

mongod.exe --dbpath "c://data/db"

In this case instead of checking for /data/db/ mongoDB check for c://data/db. In your case, you have the specified directory and you have access to it and hence it runs.

Happy Programming...!!!

Saturday, May 10, 2014

Hadoop File System (HDFS)

In this tutorial we will see, some of the common unix shell commands applied on the HDFS. To execute the commands on the HDFS (Hadoop Distributed File System), make sure that the Hadoop is running.

All unix shell commands, will executed against the default home directory in HDFS. What is the default home directory in HDFS? A user’s home directory in HDFS is located at /user/username. For example, my home directory is /user/mramanujam.

Lets start with some commands, make sure that hadoop is running, if not please start hadoop.


Once started, let's create the HDFS home directory, it the same unix shell command to create a directory.

$ hadoop fs -mkdir -p /user/mramanujam

Now list the files in your home directory

$ hadoop fs -ls This is will list the files in our HDFS directory.

Lets create a file and move it to the HDFS

$ vi newFile.txt

Now copy the file create from the local directory to the HDFS directory

$ hadoop fs -copyFromLocal newFile.txt newFile.txt

Now list the files in your home directory now

$ hadoop fs -ls It will show Found 1 item and the relevant details.

To get the list of all commands, please visit here

Happy Programming...!!!

Saturday, April 19, 2014

java.lang.IllegalStateException: ArrayAdapter requires the resources ID to be a TextView

Recently i was creating ListActivity for my Android application. After doing the necessary work, when i try to run the application, i was spatted with the error java.lang.IllegalStateException: ArrayAdapter requires the resources ID to be a TextView. What causes this issue?.

When you are passing an layout to the constructor like this new ArrayAdapter(this, R.layout.list_employee, this.employeeList). You need to make sure that your layout file list_employee wasn't wrapped by another layout. Unfortunately, my layout was wrapped with the RelativeLayout , which results in the above exception.

Below is the layout of my activity, which results in the exception

 <RelativeLayout xmlns:android=""  
     android:text="@string/employee_list_heading" />  

To Resolve the issue, i have just removed the layout element which just wrapped my TextView, and modified my XML as below

 <?xml version="1.0" encoding="utf-8"?>  
 <TextView xmlns:android=""  
   // other attributes of the TextView  

Happy Programming...!!!

Sunday, January 26, 2014

Hibernate mapping exception: Could not determine type for columns: [org.hibernate.mapping.Column]

Recently when i was implementing Many to Many with Join columns with Additional column, i was getting the following error when i was building my application. Below is the exception from my application stack.

Invocation of init method failed; nested exception is org.hibernate.MappingException: 
Could not determine type for: com.expense.domain.Medicine, at table: Medicine_Shop, for columns: [org.hibernate.mapping.Column(medicine)]

This is because my application doesn't find all of your annotations, because I was annotating both fields and methods. You have to use only one strategy.
Either annotate in fields else methods, here in my case, i was annotating at field level in all classes, except in one class, where i have annotated at the method level (getter/setter) because of that annotation doesn't have any effect. Below is the sample code, which triggers the above exception, where you can see in the MedicineShop class, i have Annotated @EmbeddedId at the method level instead of the field level, Once i move the annotation to the field level, the issue is resolved.

public class Medicine{
 private int id;
 private String name;
 private String companyName;
 @OneToMany(fetch=FetchType.LAZY, mappedBy="pk.medicine", cascade=CascadeType.ALL)
 private Set medicineShop= new HashSet();

   joinColumns= @JoinColumn(name = "medicine_id")),
   joinColumns= @JoinColumn(name = "shop_id"))
public class MedicineShop implements Serializable 
 private MedicineShopId pk = new MedicineShopId ();
 @Column(name="capacity", length=10, nullable=false)
 private int capacity;
 public MedicineShopId getPk() {
  return pk;
 public void setPk(MedicineShopId pk) { = pk;

Happy Programming...!!!