Win a copy of Head First Android this week in the Android forum!

Vijay Kumar Raman

+ Follow
since Oct 19, 2010
Cows and Likes
Total received
In last 30 days
Total given
Total received
Received in last 30 days
Total given
Given in last 30 days
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Vijay Kumar Raman

When a command is executed via SSH connection, often the command execution fails with Exception - "net.schmizz.sshj.connection.ConnectionException: Connection reset Exception is thrown".

Problem description:

I created a SSH connection instance to a host using net.schmizz.sshj.SSHClient. I execute bunch of commands using this SSH connection and finally close the connection.
In times SSH command execution fails with exception saying,

2018-04-11T12:02:51.755Z INFO  c.v.v.u.SSHUtil [executeRemoteSSHCommand:861] [main] - Successfully executed 'tar -C /usr/local/ -zxvf /usr/local/VMware-GuestSDK-10.2.0-8225092.tar.gz --no-same-owner' command on remote ssh host
2018-04-11T12:03:18.121Z ERROR n.s.s.t.TransportImpl [die:589] [reader] - Dying because - {} Connection reset
at Source)
at Source)
2018-04-11T12:03:18.123Z INFO  n.s.s.t.TransportImpl [notifyDisconnect:182] [reader] - Disconnected - UNKNOWN
2018-04-11T12:03:18.127Z ERROR n.s.c.Promise [tryRetrieve:175] [main] - <<chan#6 / open>> woke to: net.schmizz.sshj.connection.ConnectionException: Connection reset

2018-04-11T12:03:18.130Z ERROR c.v.v.e.OutcomePrinter [afterInvocation:40] [main] - exception thrown
net.schmizz.sshj.connection.ConnectionException: Connection reset
at net.schmizz.sshj.connection.ConnectionException$1.chain(
at net.schmizz.sshj.connection.ConnectionException$1.chain(
at net.schmizz.concurrent.Promise.deliverError(
at net.schmizz.concurrent.Event.deliverError(
at net.schmizz.concurrent.ErrorDeliveryUtil.alertEvents(
at net.schmizz.sshj.common.ErrorNotifiable$Util.alertAll(
at net.schmizz.sshj.connection.ConnectionImpl.notifyError(
at net.schmizz.sshj.transport.TransportImpl.die(
Caused by: net.schmizz.sshj.common.SSHException: Connection reset
at net.schmizz.sshj.common.SSHException$1.chain(
at net.schmizz.sshj.common.SSHException$1.chain(
at net.schmizz.sshj.transport.TransportImpl.die(
... 1 common frames omitted
Caused by: Connection reset
at Source)
at Source)
2018-04-11T12:03:18.131Z INFO  c.v.v.e.OutcomePrinter [afterInvocation:47] [main] - OUTCOME:FAIL


often the SSH connection disconnects and reconnects but when I execute a command via this SSH connection and in that time if the disconnect happens, it never reconnects instead net.schmizz.sshj.connection.ConnectionException: Connection reset Exception is thrown.

My Query:

How to overcome this ssh disconnection issue from my Java code especially while executing commands via the SSH connection ?

3 years ago

output : 8

x++ + x++ * --x
2 + x++ * --x
2 + 3 * --x
2 + 3 * 2
2 + 6
result: 8
Is this correct ?
4 years ago
I tried writing a program to throw a Error object explicitly and written try catch block to handle the Error. It is working !!!
Even when I try throwing a Throwable object also it works just fine.
Can anyone tell me why we are allowed to write Throwable or Error in catch block while writing Exception alone would be more relevant :-)

Console output:
at ErrorCheckTry.testingthrowError(
at ErrorCheckTry.main(
Error caught in catch block

Note: I tried adding a recursive call of the testingthrowError() method above. Program terminated throwing StackOverflowError. The catch block does't work here !!!

[Added code tags - see UseCodeTags]
9 years ago
If you see the System class, the reference variable out is not initialized
public final static PrintStream out = nullPrintStream();
where method call nullPrintStream() returns null

then how the out.println() method call works ?
9 years ago
I tried to call a method of a class for which I have created static final reference variable (not instantiating any new object) just like in System.out.println() as below,

The instance variable declaration line in CheckStaticObjRef .java class, "public static final StaticObjClass stob;" is giving compilation error "The blank final field may not have been initialized". I dont know where am missing something in my code.
Kindly help.

[Added code tags - see UseCodeTags]
9 years ago
How to prevent duplicate data entry in hibernate while more than one insertion done being simultaneously (by two different processes) that have auto generated primary key?
Our application will insert record to a mysql table with auto generated primary key and using hibernate 3 and MYSQL 5.5.21. But when the same application is running in more than one PC and both trying to insert record in the table simultaneously, I get the exception as below

org.hibernate.util.JDBCExceptionReporter:logExceptions(78) | Duplicate entry 'somevalue' for key 'PRIMARY'.

Kindly help to resolve this issue.
In Tomcat 6.0 I need to increase the heap memory size to 100MB, Tomcat is not running as windows serive in my PC and I don't have admin rights to change the heap meory size in tomcat6w monitor window.
I tried giving set JAVA_OPTS=-Xmx1024m -Xmx1024m and set CATALINA_OPTS=-Xmx1024m -Xmx1024m in tomcat console and also tried creating a setenv.bat file (since I am working in Windows OS) explicitly in Apache Software Foundation\Tomcat 6.0\bin\ foder but it is also not working it seems.
9 years ago
I have developed a web application that runs on Tomcat6 (run from console \bin and not as windows service) and uses hibernate 3 for OR mapping and MYSQL as database. my requirement is I have to upload files of size upto maximum 100MB and persist them in a table column in the database using hibernate.

I read the FileInputStream directly into Hibernate Blob object using Hibernate.createBlob(FileInputStream obj) method. In hibernate Pojo class and hbm.xml file the corressponding column name type is declared as blob. when I execute this application I am able to upload files of size upto 25MB successfully. but when i try to upload file of size greater than 25MB it is throwing OutOfMemoryError: Java heap space

java.lang.OutOfMemoryError: Java heap space
at com.mysql.jdbc.Buffer.<init>(
at com.mysql.jdbc.MysqlIO.sendSplitPackets(
at com.mysql.jdbc.MysqlIO.send(
at com.mysql.jdbc.MysqlIO.sendCommand(
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(
at com.mysql.jdbc.ConnectionImpl.execSQL(
at com.mysql.jdbc.PreparedStatement.executeInternal(
at com.mysql.jdbc.PreparedStatement.executeUpdate(
at com.mysql.jdbc.PreparedStatement.executeBatchSerially(
at com.mysql.jdbc.PreparedStatement.executeBatch(
at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(
at org.hibernate.jdbc.AbstractBatcher.executeBatch(
at org.hibernate.engine.ActionQueue.executeActions(
at org.hibernate.engine.ActionQueue.executeActions(
at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(
at org.hibernate.event.def.DefaultFlushEventListener.onFlush(
at org.hibernate.impl.SessionImpl.flush(
at org.hibernate.impl.SessionImpl.managedFlush(
at org.hibernate.transaction.JDBCTransaction.commit(

I tried commenting the hibernate; call and I am not getting the OutOfMemoryError.

Note: I am not supposed to use byte array to read the inputstream data into and then store it in database using hibernate since memory is a constraint for me. In mysql the max_allowed_packet size is 1024MB. kindly help.
Thanks for the clarification. I will post my query in hibernate OR mapping forum.
9 years ago
I tried modifiying the JAVA_OPT and CATALINA_OPT environment variable's values to 1GB but still getting the same exception "outofmemoryerror". I believe my current approach which reads the whole file from FileInputStream and stores it in a byte[] array and finally storing the byte[] array to the database is giving problem since it requires the whole file should be stored in memory before persisiting into database. Is there any approach in hibernate 3.0 to store large files in database and without ctoring them in memory (RAM).

I need alternative solution to modify my application code to handle large files rather than modifying the application server environment variables values since my application will be deployed in different application servers.

9 years ago
I need to increase JVM Heap size in Tomcat 6.0 to 100MB. I am running a web application in Tomcat6 using whcih I should upload and download file attachments of size upto 100MB.
I start Tomcat6 from the console mode. i.e, D:\Program Files\Apache Software Foundation\Tomcat 6.0\bin>tomcat6.exe.
I tried increasing heap size from command prompt by setting hte environment variables CATALINA_OPT and JAVA_OPT. it didnt help either. please help. Tomcat is not running as a windows service in my PC either.
9 years ago
I am trying to upload file (size 1MB to 100MB) through my web application running in Tomcat 6 and ultimately storing the file in a database table column using hibernate 3.0 as BLOB data in MySQL database. I am able to upload and save files of size upto 10MB successfully (Though I get the same OutofMemory error). But when I try to upload and save file of size more than 10 MB, I am getting below Error message,

Caused by: java.lang.OutOfMemoryError: Java heap space
at com.mysql.jdbc.Buffer.<init>(
at com.mysql.jdbc.MysqlIO.readRemainingMultiPackets(
at com.mysql.jdbc.MysqlIO.reuseAndReadPacket(
at com.mysql.jdbc.MysqlIO.reuseAndReadPacket(
at com.mysql.jdbc.MysqlIO.checkErrorPacket(
at com.mysql.jdbc.MysqlIO.checkErrorPacket(
at com.mysql.jdbc.MysqlIO.nextRow(
at com.mysql.jdbc.MysqlIO.readSingleRowSet(
at com.mysql.jdbc.MysqlIO.getResultSet(
at com.mysql.jdbc.MysqlIO.readResultsForQueryOrUpdate(
at com.mysql.jdbc.MysqlIO.readAllResults(
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(
at com.mysql.jdbc.ConnectionImpl.execSQL(
at com.mysql.jdbc.PreparedStatement.executeInternal(
at com.mysql.jdbc.PreparedStatement.executeQuery(
at org.hibernate.jdbc.AbstractBatcher.getResultSet(
at org.hibernate.loader.Loader.getResultSet(
at org.hibernate.loader.Loader.doQuery(
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(
at org.hibernate.loader.Loader.doList(
at org.hibernate.loader.Loader.listIgnoreQueryCache(
at org.hibernate.loader.Loader.list(
at org.hibernate.loader.hql.QueryLoader.list(
at org.hibernate.hql.ast.QueryTranslatorImpl.list(
at org.hibernate.engine.query.HQLQueryPlan.performList(
at org.hibernate.impl.SessionImpl.list(
at org.hibernate.impl.QueryImpl.list(

The max_allowed_packet size in MYSQL is 1GB and I tried changing the heap size in tomcat console as set CATALINA_OPTS="-Xms1024m -Xmx1024m -XX:PermSize=128m -XX:MaxPermSize=512m" and JAVA_OPTS="-Xms1024m -Xmx1024m -XX:PermSize=128m -XX:MaxPermSize=512m". Also I explicitly added catalina.bat and files in tomcat/bin folder with the same CATALINA_OPTS and JAVA_OPTS values.

On executing the application in tomcat the uploaded file is correctly copied into D:\Program Files\Apache Software Foundation\Tomcat 6.0\webapps\<MyApp> folder and the logging statment is written upto object ref) method in data layer.

PS: The same application executed as standalone application using main method uploads file of size 120MB successfully without throwing any error.

Kindly help. Thanks.
9 years ago
I have a standalone java application (With a UI screen with login page in Applet and AWT) which i have to distribute to my clients as EXE. The client will simply add the exe in the desktop and on clicking the icon the application should be launched displaying the Login screen. kindly help....
11 years ago