Tuesday 4 February 2014

Useful Linux Commands

Sometimes we need to work on Linux environment during development specially on Linux box hosting the server.As we know Linux is bundled with lots of useful commadline features, file handling is one of them.Here is small list of commands which I feel very useful while working on Linux.

Note : Command syntax/example given below are based on requirements/assignment I worked upon.Every command below may have multiple options,which can be used in different combination based on scenarios(requirement).For example I am redirecting output to a file which can also be displayed on console.

      1.  Secure File Copy.

          Using this feature you can securely copy file from one machine to another machine without login into any of the machine. 
            Syntax : scp user1@machine1:Path of source file user2@machine2:Path of the destination directory
            Example :scp admin@192.168.0.101:/opt/file/Test.jar jboss@192.168.0.109:/opt/jboss/app/lib

      2.  Fetching the specific line range from file and write result to another file.

           Syntax : sed -n 'startLineNumber,EndLineNumberp' fileToBeSearch > resultFile
           Example : sed -n '1,500p' Data.csv > SmallData.csv
 
      3. Fetching the line containing given text from file.
          Syntax :grep searchText SourceFile > FileContainingResultData
          Example : Search For single String
            grep nike BrandData.csv > NikeData.csv

          Example : Search For 2 Strings with OR operation
            grep 'nike\|adidas' BrandData.csv > NikeORAdidasData.csv

          Example : Search For 2 Strings with AND operation  
           grep nike BrandData.csv  | grep shoe > NikeANDShoeData.csv 
 
      4.  Changing file or directory (folder) permissions.
        Sometimes it required to change the permissions of an file or directory in order to perform certain operations.
            Syntax : chmod permissionOctalCode fileOrDirectoryName
            Example : chmod 777 data
            chmod 777 Record.csv
            Note : Use -R option to recursively change the permission of the directory.
           
      5.  Searching file by name.
            find command is very useful to search files.
            Syntax : find directoryToSearch -name fileName
            Example : find / -name 'eaccmd.sh'

      6.  Access environment as different user.
            Using below command you can access the environment as an different user.Mostly it is used to access the environment as more privileged user(root). 
            Syntax : sudo su - userName
            Example : sudo su - admin

      7.  Navigate to previous directory.
             Using below command you can navigate to previous directory from where you have navigated to current directory.
             Syntax : cd - 

      8. Create a zip file.
            Using below command you can add single or multiple files to zip.
            Syntax : zip nameOfZip.zip file1 file2 ...
            Example : zip Log.zip server.log console.log

      9. Unzip the zipped file.
           Use below command to unzip the zipped file.
           Syntax : unzip nameOfZip.zip
           Example : unzip Log.zip
         
    10.  Display content of zip file without extracting it.
           You can display the content of zip file without extracting it.
           Syntax : unzip -l nameOfZip.zip

           Example : unzip -l Log.zip

     11.  Delete all lines containing specific text from a file.Without opening the file.
           You can delete all lines containing 'some string' from a file without opening it.
           Syntax : sed 
--in-place '/some string/d' myfile
           Example : sed --in-place '/nike/d' Brand.csv

For more detail on any of the above commands use man command(manual pages or man pages).

Monday 3 February 2014

Solution for signer information error (occuring at server startup or on browsing) for ATG 10.1 CRS

I have configured CRS (Commerce Reference Store) for ATG 10.1 using CIM (Configuration and Installation Manager). After server startup I tried to browse the application but only header was displaying.Server was throwing below exception.

ERROR [[jsp]] Servlet.service() for servlet jsp threw exception java.lang.SecurityException: class "atg.commerce.order.OrderHolder$$EnhancerByCGLIB$$e9ab456d"'s signer information does not match signer information of other classes in the same package
     at java.lang.ClassLoader.checkCerts(ClassLoader.java:807)
     at java.lang.ClassLoader.preDefineClass(ClassLoader.java:488)
     at java.lang.ClassLoader.defineClassCond(ClassLoader.java:626)
     at java.lang.ClassLoader.defineClass(ClassLoader.java:616)
     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
     at java.lang.reflect.Method.invoke(Method.java:597)
     at net.sf.cglib.core.ReflectUtils.defineClass(ReflectUtils.java:384)
     at net.sf.cglib.core.AbstractClassGenerator.create(AbstractClassGenerator.java:219) 


Solution :  Replace the jboss-eap-5.0/jboss-as/common/lib/cglib.jar with the unsigned version, which can be downloaded from the following URL : http://repository.jboss.com/maven2-brew/cglib/cglib/2.2/cglib-2.2.jar or http://search.maven.org/remotecontent?filepath=cglib/cglib/2.2.2/cglib-2.2.2.jar.
This is due to a problem with the JBoss cglib library.For more details see the JBoss bug https://jira.jboss.org/jira/browse/JBPAPP-2971.