Monday, August 26, 2013

Recover Deleted Files in Linux

You need only few microseconds to lose your files which you have done by spending more that few hours or days even. But thanks to Smart guys there are ways to recover it fully or partially.
First of all,  come on, Calm down! it is not only yours but also happened to others.... just follow these simple steps:

  1. Install a tool called "foremost" which  is used for recovering deleted files. Type sudo apt-get install foremost in your shell terminal. 
  2. Find the name of your disk by using the command sudo fdisk -l.  This command lists all the drives found in your system including the pen drives (if plugged)Assume we want to recover the files deleted  from a disk /dev/sdb1 
  3. Create an image of the drive you want to recover by using sudo dd if=/dev/sdb1 of=/home/myimg.img, Where /dev/sdb1 is the name of the drive to be recovered and /home/myimg.img is the out put location and file of the recovered file. 
    Please note that, make sure  to have enough space in out put directory. If you don't have you can use external storage devices.  This step may take long time depending on your disk size and how large your files have been. So be patient and wait until it finish. If you are not patient google for other solutions or redo the work :-) 
  4. Once the recovery  image is created give a permission for the user by typing sudo chown name.name /home/myimg.img Where name is the name of the user in your system. 
  5. Create a directory for your recovery files. Lets use the home directory; use this command  mkdir recovery when recovery can be any valid name  directory.
  6. Use this command and recover your files. foremost -vqQ -o recovery/ -t type -i mypendriveimage.img Where the option -t type specifies the file format (e.g. pdf, doc...) you want to recover from the image.  This tool currently supports some common formats only. As a result ofg this you may not get back the file you are looking. After this step completes check the recovery directory, and you can get the recovered files organized by file format. However, the file name of the files is a number not the original file names. It is a bit difficult to filter your file from very huge (really depends on your files) list of files. Most probably the first file recovered may be the latest file created in your system. You can check audit.txt file created during the recovery to know which is recovered first.  Otherwise use other commands such as grep to get your files or manually (would be very tiresome and may be easier to redo the work :-) ) check each files.... 
Still you don't get your files.... Uhmmmm .... be calm and google around or redo it. Or Write a program that can recover deleted files.... and share to us as welll ;-) 

The best way is DON'T DO SHIFT PLUS DELETE unless you're quite certain that you don't need the files in the future.  

Reference: 

Wednesday, July 24, 2013

'tasksel: aptitude failed (100)' error while Installing LAMP server in Ubuntu

While installing LAMP server in Ubuntu tasksel: aptitude failed (100) may occur. This might be due to a previous installed mysql database server or a trace of mysql in /etc/lib directory. So, the simple solution is to remove mysql database server. Other wise use other methods than 'tasksel' to install LAMP :)

Thursday, June 13, 2013

Alias in Linux to create short cut

To save time it is possible to create a short cut for Linux commands by  creating an alias. To do so: 
  1. open ~/.bashrc or /etc/bash.bashrc in any text editor 
  2. Add each commnad using this formula: 'alias <name>=<"command"> e.g. alias install ="sudo apt-get install" 
  3. Then save it and log out and log in again in to the system
  4. Enjoy :)

Friday, April 5, 2013

Solution for De-serialization problem in EJB entity from a remote client!

In my previous post , I had a problem in calling remote EJB entity from a remote client. The problem was, when retrieving an object from a data base and return to the client CORBA MARSHALING exception is being thrown. Because, may be the entity retrieved and returned to client can't be de-serialized in the same way as the server.  For overcoming this problem, I spent many hours. There are many posts available in web just mentioning the problem and suggesting their idea, but not really a solution.
Finally, I just separate the entity class as java application and add to all EJB session beans, Interfaces, and Client application (web application). With this, it works perfectly. Nevertheless, I don't think this is better solution. This gives access to entity beans for the client.
I am still searching for a better solution.:) 

Wednesday, April 3, 2013

De-Serialization problem in EJB remote client and server using JPA

When I try to retrieve an object passed as a list or so from session bean to a client side application say action class in struts 2 concept, De-Serialization problem occurred. I googled a lot, but no one has came with tangible solution.

Here below the full stack trace of the glass fish server.
WARNING: IOP00810011: Exception from readValue on ValueHandler in CDRInputStream
org.omg.CORBA.MARSHAL: WARNING: IOP00810011: Exception from readValue on ValueHandler in CDRInputStream  vmcid: OMG  minor code: 11 completed: Maybe
 at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
 at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
 at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
 at java.lang.reflect.Constructor.newInstance(Constructor.java:525)
 at com.sun.corba.ee.spi.orbutil.logex.corba.CorbaExtension.makeException(CorbaExtension.java:248)
 ......
 at org.mk.rc.intf.__PublicationBeanRemote_Remote_DynamicStub.searchPublication(org/mk/rc/intf/__PublicationBeanRemote_Remote_DynamicStub.java)
 at org.mk.rc.intf._PublicationBeanRemote_Wrapper.searchPublication(org/mk/rc/intf/_PublicationBeanRemote_Wrapper.java)
 at org.mk.rc.actions.PublicatonAction.searchPublication(PublicatonAction.java:43)
 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
......
 at com.opensymphony.xwork2.interceptor.ModelDrivenInterceptor.intercept(ModelDrivenInterceptor.java:100)
 at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:249)
 ......
atThreadPool$Worker.run(AbstractThreadPool.java:513)
 at java.lang.Thread.run(Thread.java:722)
Caused by: java.lang.NullPointerException
 at com.sun.corba.ee.impl.orbutil.ClassInfoCache$ClassInfo.(ClassInfoCache.java:156)
.....
 at com.sun.corba.ee.impl.io.ValueHandlerImpl.readValue(ValueHandlerImpl.java:274)
 at com.sun.corba.ee.impl.encoding.CDRInputStream_1_0.readRMIIIOPValueType(CDRInputStream_1_0.java:1015)
 ... 96 more

I don't solved it yet. I hope soon :)

Tuesday, March 26, 2013

An annotation processor threw an uncaught exception.

When compiling a EJB project there might be a case in which the java EE API comes before eclipseLink API in the class path. Hence the following error may be generated.

An annotation processor threw an uncaught exception.
Consult the following stack trace for details.
java.lang.ClassFormatError: Absent Code attribute in method that is not native or abstract in class file javax/persistence/PersistenceException
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClassCond(ClassLoader.java:632)
.....
at org.netbeans.core.execution.RunClassThread.run(RunClassThread.java:153)
../..//nbproject/build-impl.xml:839: The following error occurred while executing this line:
../../nbproject/build-impl.xml:258: Compile failed; see the compiler error output for details.
BUILD FAILED (total time: 1 second)

The solution is simple:-) Just make the eclipseLink API first in the project libraries configuration. 

Monday, March 25, 2013

javax.naming.NameNotFoundException: org.mk.rc.intf.StaffsBeanRemote

When calling an EJB, I got an error like the following....

com.sun.enterprise.container.common.spi.util.InjectionException: Exception attempting to inject Remote ejb-ref name=org.mk.rc.client.Client/staffsBean,Remote 3.x interface =org.mk.rc.intf.StaffsBeanRemote,ejb-link=null,lookup=,mappedName=,jndi-name=org.mk.rc.intf.StaffsBeanRemote,refType=Session into class org.mk.rc.client.Client: Lookup failed for 'java:comp/env/org.mk.rc.client.Client/staffsBean' in SerialContext[myEnv={java.naming.factory.initial=com.sun.enterprise.naming.impl.SerialInitContextFactory, java.naming.factory.url.pkgs=com.sun.enterprise.naming, java.naming.factory.state=com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl}
at com.sun.enterprise.container.common.impl.util.InjectionManagerImpl._inject(InjectionManagerImpl.java:703)
at com.sun.enterprise.container.common.impl.util.InjectionManagerImpl.inject(InjectionManagerImpl.java:470)
....

Caused by: javax.naming.NameNotFoundException: org.mk.rc.intf.StaffsBeanRemote#org.mk.rc.intf.StaffsBeanRemote not found
at com.sun.enterprise.naming.impl.TransientContext.doLookup(TransientContext.java:248)
at com.sun.enterprise.naming.impl.TransientContext.lookup(TransientContext.java:215)
..... 

The problem is, I didn't add StaffsBeanRemote bean name to application-client.xml file. Just add as follow and works fine. 

<ejb-ref>
    <ejb-ref-name>StaffsBean</ejb-ref-name>
    <ejb-ref-type>Session</ejb-ref-type>
    <remote>org.mk.rc.intf.StaffsBeanRemote</remote>
 </ejb-ref>

Enjoy :-)


Saturday, March 23, 2013

The module has not been deployed.

When I tried to use Hibernate (JPA 2.0) as a persistence provider in glasfish 3.x application server , I encountered the following problem and my EJB application can't be deployed.


Initializing...
deploy?DEFAULT=/home/alemnew/NetBeansProjects/LMS-ejb/build/classes&name=LMS-ejb&libraries=/home/alemnew/NetBeansProjects/LMSRemote/dist/LMSRemote.jar,/home/alemnew/NetBeansProjects/LMS-ejb/lib/ejb3-persistence.jar,/home/alemnew/NetBeansProjects/LMS-ejb/lib/hibernate-annotations.jar,/home/alemnew/NetBeansProjects/LMS-ejb/lib/hibernate-commons-annotations.jar,/home/alemnew/NetBeansProjects/LMS-ejb/lib/hibernate-validator.jar,/home/alemnew/NetBeansProjects/LMS-ejb/lib/hibernate3.jar,/home/alemnew/NetBeansProjects/LMS-ejb/lib/hsqldb.jar&force=true failed on GlassFish Server 3.1.2 
 Error occurred during deployment: Exception while preparing the app : java.lang.ClassNotFoundException: org.hibernate.ejb.HibernatePersistence. Please see server.log for more details.
/home/alemnew/NetBeansProjects/LMS-ejb/nbproject/build-impl.xml:971: The module has not been deployed.
See the server log for details.
BUILD FAILED (total time: 1 second)
=========================================

As a temporary solution I used eclipseLink (JPA 2.0) instead.  The problem seams like, glassfish doesn't have Hibernate as a persistence provider by default. Hence, manual operation is needed, I think. I will try to solve......

Monday, February 18, 2013

Wifi connection failed problem in Ubuntu 12.04

I have been getting "connection failed activation failed" problem for a days while connecting to some WAP. I have been searching a bit on internet and different peoples suggest  different solutions. Finally I got one post in ubuntu forum says re-install : sudo apt-get install  --reinstall bcmwl-kernel-source, then I tried but failed. I removed sudo apt-get remove cmwl-kernel-source and works fine.


Friday, January 4, 2013

File permissions


Setting Permissions

The chmod command uses as an argument a string which describes the permissions for a file. The permission description can be in the form of a number that is exactly three digits. Each digit of this number is a code for the permissions level of three types of people that might access this file:
  1. Owner (you)
  2. Group (a group of other users that you set up)
  3. World (anyone else browsing around on the file system)
The value of each digit is set according to what rights each of the types of people listed above have to manipulate that file.
Permissions are set according to numbers. Read is 4. Write is 2. Execute is 1. The sums of these numbers give combinations of these permissions:
  • 0 = no permissions whatsoever; this person cannot read, write, or execute the file
  • 1 = execute only
  • 2 = write only
  • 3 = write and execute (1+2)
  • 4 = read only
  • 5 = read and execute (4+1)
  • 6 = read and write (4+2)
  • 7 = read and write and execute (4+2+1)
Permissions are given using these digits in a sequence of three: one for owner, one for group, one for world.
Let's look at how I can make it impossible for anyone else to do anything with my apple.txt file but me:
$ chmod 700 apple.txt
$

http://www.december.com/unix/tutor/permissions.html
http://codex.wordpress.org/Changing_File_Permissions