UNIX: How to Automate SSH Login

Yesterday, I was working on some shell script piece for my project and I came across a situation where I have to copy some files from one server to another using ‘scp’ command and also some time have to execute some command on other server.  One requirement was we don’t need to pass the password of functional id inside the script.

User should be able to login to other server without password using command  “ssh -l username remotehost”.

For this I used SSH public key based authentication as below:-

Continue reading

Posted in HowTo, linux, unix | Tagged , | Leave a comment

java.io.NotSerializableException

I was getting this error today during writing a program

java.io.NotSerializableException: com.xxxx.xxx.xxx.thunderhead.Project
    at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1156)
    at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:326)
    at java.util.ArrayList.writeObject(ArrayList.java:570)

 

Continue reading

Posted in Java, Troubleshoot | Leave a comment

java.security.NoSuchAlgorithmException: Cannot find any provider supporting RSA/NONE/OAEPPADDING

Got below error during web service request:-

java.security.NoSuchAlgorithmException: Cannot find any provider supporting RSA/NONE/OAEPPADDING
at javax.crypto.Cipher.getInstance(DashoA12275)
at org.apache.ws.security.util.WSSecurityUtil.getCipherInstance(WSSecurityUtil.java:703)
at org.apache.ws.security.processor.EncryptedKeyProcessor.handleEncryptedKey(EncryptedKeyProcessor.java:145)
at org.apache.ws.security.processor.EncryptedKeyProcessor.handleEncryptedKey(EncryptedKeyProcessor.java:114)

Continue reading

Posted in Articles | Leave a comment

java.security.InvalidKeyException: Illegal key size or default parameters

I was working on webservice call where my code was breaking in RAD during decrypting the password of keystore. I encountered below error:

Caused by: java.security.InvalidKeyException: Illegal key size or default parameters
    at javax.crypto.Cipher.a(DashoA13*..) ~[na:1.6]
    at javax.crypto.Cipher.a(DashoA13*..) ~[na:1.6]
    at javax.crypto.Cipher.a(DashoA13*..) ~[na:1.6]
    at javax.crypto.Cipher.init(DashoA13*..) ~[na:1.6]
    at javax.crypto.Cipher.init(DashoA13*..) ~[na:1.6]

Continue reading

Posted in Axis2, Java, Rampart | Tagged , , , | 1 Comment

Caused by: java.security.UnrecoverableKeyException: Cannot recover key

During deployment of my code on server I faced below issue signature issue:

org.apache.axis2.AxisFault: Error in signature with X509Token
    at org.apache.rampart.handler.RampartSender.invoke(RampartSender.java:70)
    at org.apache.axis2.engine.Phase.invoke(Phase.java:318)
    at org.apache.axis2.engine.AxisEngine.invoke(AxisEngine.java:254)
    at org.apache.axis2.engine.AxisEngine.send(AxisEngine.java:419)
    at org.apache.axis2.description.OutInAxisOperationClient.send(OutInAxisOperation.java:402)
    at org.apache.axis2.description.OutInAxisOperationClient.executeImpl(OutInAxisOperation.java:229)
    at org.apache.axis2.client.OperationClient.execute(OperationClient.java:165)
 Caused by: org.apache.rampart.RampartException: Error in signature with X509Token
    at org.apache.rampart.builder.AsymmetricBindingBuilder.doSignature(AsymmetricBindingBuilder.java:746)
    at org.apache.rampart.builder.AsymmetricBindingBuilder.doSignBeforeEncrypt(AsymmetricBindingBuilder.java:419)
    at org.apache.rampart.builder.AsymmetricBindingBuilder.build(AsymmetricBindingBuilder.java:95)
    at org.apache.rampart.MessageBuilder.build(MessageBuilder.java:147)
    at org.apache.rampart.handler.RampartSender.invoke(RampartSender.java:64)
    … 102 more

Caused by: org.apache.ws.security.WSSecurityException: Signature creation failed; nested exception is:
    java.security.UnrecoverableKeyException: Cannot recover key
    at org.apache.ws.security.message.WSSecSignature.computeSignature(WSSecSignature.java:721)
    at org.apache.rampart.builder.AsymmetricBindingBuilder.doSignature(AsymmetricBindingBuilder.java:737)
    … 106 more
Caused by: java.security.UnrecoverableKeyException: Cannot recover key
    at sun.security.provider.KeyProtector.recover(KeyProtector.java:311)
    at sun.security.provider.JavaKeyStore.engineGetKey(JavaKeyStore.java:121)
    at sun.security.provider.JavaKeyStore$JKS.engineGetKey(JavaKeyStore.java:38)
    at java.security.KeyStore.getKey(KeyStore.java:763)
    at org.apache.ws.security.components.crypto.CryptoBase.getPrivateKey(CryptoBase.java:216)
    at org.apache.ws.security.message.WSSecSignature.computeSignature(WSSecSignature.java:713)
    … 107 more

Continue reading

Posted in Axis2, Java, Rampart | Tagged , , , | Leave a comment

java.lang.IllegalStateException: Cannot map handler [controller] to URL path : There is already handler

I am using Spring 3.0 for my new application…I am not very familiar with annotation but learning them they are cool.  Today I faced “Cannot Map Handler [XXX] to URL Path” error, while running my page.

Later debug I found that I duplicated the Controller definition stuff inside XXX-Servlet.xml as below. Continue reading

Posted in Java, Spring | Tagged , | 1 Comment

Count lines of multiple similar files in unix

In continuation to my earlier post regarding concatenation similar files into one. I am writing this post to demonstrate counting lines of similar kind of files in a given directory and sub-directory.

Below command will find all the logs with given name pattern inside the directory including sub directories and then WC will count it’s lines and display on screen in total.

Continue reading

Posted in HowTo, unix | Tagged , , , | Leave a comment

Concatenate/merge/join Multiple Text Files in Windows

Last night I got many log files from 8 different servers, all the servers have date wise log files. I separated out similar logs and kept in a folder, now as per requirement team needs the one type of log in consolidated manner means “USAGE.log” of all days and servers in one USAGE-Consildated.log file.

I was searching for some utility on Google but not get any. Later I thought about DOS Batch command to do the same but a simple copy command did it for me.

Continue reading

Posted in Articles, HowTo | Tagged | 2 Comments

Use of String variable in Java Switch Statement

There is no way to perform a true switch on a String in Java. With the arrival of JDK 5.0 and its implementation of enum, a reasonably close approximation of this can be done using the following code.

Create an enum :

 public enum Months{ JAN, FEB, MAR, APRIL;}

 

Continue reading

Posted in Articles | Tagged | Leave a comment

uncaught exception: [Exception… “Not enough arguments” (NS_ERROR_XPC_NOT_ENOUGH_ARGS)

I was testing my web application on FireFox5 , I faced “not enough arguments” issue. During investigation what I found is while opening the page we are hitting actual issues inside ‘addEventListener’ function. I searched web around behavior of ‘addEventListener’ in firefox and found that it expect third argument as well so I replaced below code locally and it worked for me =)

addEventListener(“load”, function(event) {
      _init();
);

with Continue reading

Posted in Articles, javascript | Tagged | Leave a comment