diff --git a/R/pkg/R/backend.R b/R/pkg/R/backend.R
index 49162838b8d1a1c3cea962e589730779c9f447f4..6c81492f8b67503b3f0dc82d658a4d10e22de501 100644
--- a/R/pkg/R/backend.R
+++ b/R/pkg/R/backend.R
@@ -110,6 +110,9 @@ invokeJava <- function(isStatic, objId, methodName, ...) {
 
   # TODO: check the status code to output error information
   returnStatus <- readInt(conn)
+  if (length(returnStatus) == 0) {
+    stop("No status is returned. Java SparkR backend might have failed.")
+  }
   if (returnStatus != 0) {
     stop(readString(conn))
   }