Scrivio Interview library
ConceptFoundations6 min read · updated 12 November 2026

What were Java RMI and Hessian used for, why are they considered legacy, and what has Spring done with its remoting support?

Java RMI let a program call methods on an object in another JVM through a local stub, sending arguments and results with Java serialization, and Hessian did the same over HTTP with a compact binary format. Both are legacy because deserializing object graphs from the network has caused remote code execution vulnerabilities, and because they tie clients and servers to the same Java types and are hard to evolve, balance and observe. Spring deprecated its remoting support, including RmiServiceExporter, HessianServiceExporter and HttpInvoker, in 5.3 and removed it in Spring Framework 6; the replacements are REST with JSON, gRPC or messaging, and @HttpExchange interfaces give a similar programming model.

Why this question is asked

Older Spring applications are full of exporter and proxy beans for remote calls, and anyone upgrading such an application to Spring Boot 3 finds that those classes no longer exist. Interviewers ask about RMI and Hessian to see whether we know why the industry moved away from them, not just that it did. In this answer, we will recap how these technologies worked, look at the security and design problems that made them legacy, see what Spring did with its support, and look at the modern replacements, including the interface-based clients Spring offers today.

1A Quick Recap of RMI and Hessian

Java RMI, Remote Method Invocation, was part of the JDK from its early days. A server registered a remote object, usually in an RMI registry listening on port 1099. A client looked it up and received a stub, a local object that implements the same Java interface. Calling a method on the stub sent the method name and the arguments over the network, the server ran the real method, and the result came back. Arguments and results travelled with Java serialization, the built-in mechanism that turns an object graph into bytes and back.

Hessian, from Caucho, had the same goal over HTTP. It used its own compact binary format instead of Java serialization, so it was faster and had clients in a few other languages, but it still reconstructed whole object graphs on the receiving side. Spring made both easy: an exporter bean on the server published a service interface, and a proxy factory bean on the client created a stub that looked like a local bean.

Java
// Spring 5 style, removed in Spring Framework 6
@Bean(name = "/AccountService")
HessianServiceExporter accountExporter(AccountService service) {
HessianServiceExporter e = new HessianServiceExporter();
e.setService(service);
e.setServiceInterface(AccountService.class);
return e;
}
// Client side: a proxy that looks like a local bean
AccountService remote = /* HessianProxyFactoryBean for http://server/AccountService */;
Account a = remote.find(42L); // looks local, is actually an HTTP call

Notice how convenient that is: the client code cannot tell that find() is a network call. That convenience is part of the problem, as we will see.

2Why Deserialization Made Them Dangerous

When a server deserializes an object graph from the network, the bytes decide which classes are created and what their fields contain. Some classes run code while they are being deserialized, for example in a readObject() method or when a collection rebuilds itself and calls hashCode() or compareTo() on its elements. Attackers found chains of such classes, called gadget chains, in libraries that are on many classpaths, such as old versions of Apache Commons Collections. A crafted payload sent to any endpoint that deserializes untrusted input could make the server run a command of the attacker's choice.

RMI, Spring's HttpInvoker and other Java-serialization endpoints accepted exactly this kind of input, often before authentication. Hessian's format was not Java serialization, but it too instantiates arbitrary classes from the stream, and similar gadget chains were found for it. Spring itself documented this risk for HttpInvoker and other serialization-based endpoints. The root issue is design, not a bug that can be patched once: a protocol that lets the sender pick the classes the receiver creates is dangerous with untrusted input.

Step throughHow a deserialization attack works
  1. Attacker sends crafted bytesto an RMI or HttpInvoker endpoint
  2. Server deserializes the graphthe bytes choose the classes
  3. Gadget class runs code in readObjectfor example via a library on the classpath
  4. Chain reaches a dangerous callsuch as starting a process
  5. Remote code executionoften before any authentication check

5 steps in order. Play them, or step through them one at a time.

3Why They Are Hard to Live With Even Without Attacks

Security aside, these technologies couple systems tightly. Client and server must share the same Java classes, often in a shared jar, so changing a field means releasing both together. A non-Java client cannot call them easily. Serialized object graphs can drag in far more data than intended, such as a lazily loaded collection.

They are also hard to operate. RMI uses its own ports and protocol, which proxies, load balancers and firewalls handle poorly. Binary payloads are hard to log, inspect or trace, so a slow call is difficult to diagnose. And because remote calls look exactly like local calls, developers forget to handle timeouts, retries and partial failures, which are normal on a network.

4What Spring Did With Its Remoting Support

Spring Framework 5.3 deprecated its remoting support: RmiServiceExporter and RmiProxyFactoryBean, HessianServiceExporter and HessianProxyFactoryBean, HttpInvokerServiceExporter and its proxy, and related classes. The reasons given were the deserialization risk and the availability of better options. Spring Framework 6, the base of Spring Boot 3, removed them. So an application that still uses them must migrate before it can move to Spring Boot 3 or later.

5The Modern Replacements

For request and response calls between services, REST with JSON is the default: the payload is data with an explicit schema, mapped onto DTOs, which are classes designed only to carry data, so the receiver decides which types it creates. gRPC is the choice when we want a strict Protobuf contract, generated clients in many languages and efficient binary transport. For work that does not need an immediate answer, messaging with Kafka or a broker decouples the two sides.

Spring also kept the pleasant part of the old model. HTTP interface clients let us declare a Java interface with @HttpExchange or @GetMapping style annotations and let Spring create the implementation, backed by RestClient or WebClient. The calling code looks as clean as the old proxy, but underneath it is a normal, visible, JSON over HTTP call.

Java
interface AccountClient {
@GetExchange("/accounts/{id}")
AccountDto find(@PathVariable long id);
}
@Bean
AccountClient accountClient(RestClient.Builder builder) {
RestClient rest = builder.baseUrl("https://accounts.internal").build();
return HttpServiceProxyFactory.builderFor(RestClientAdapter.create(rest))
.build().createClient(AccountClient.class);
}
AccountDto a = accountClient.find(42L); // GET https://accounts.internal/accounts/42, JSON

Notice the difference from Hessian: the contract is an HTTP path and a JSON shape, the client and server can use different classes, and every call can be logged, traced, cached and load balanced like any other HTTP request.

6Follow-up questions

Is Java serialization itself removed from the JDK?

No. ObjectInputStream still exists, but the JDK added serialization filters, first through JEP 290 and later context-specific filters in JEP 415, so applications can restrict which classes may be deserialized. Using it for untrusted network input is still strongly discouraged.

Can I keep using Hessian on Spring Boot 3?

The Hessian library itself still exists, so we could wire it by hand, but Spring no longer provides the exporter and proxy, and we would keep the security and coupling problems. It is better treated as a temporary bridge while migrating to REST or gRPC.

Was RMI ever used outside application remoting?

Yes, JMX remote management traditionally uses RMI. That is one more reason to restrict and protect JMX ports, since they expose the same deserialization surface.

7Conclusion

In this answer, we saw that RMI and Hessian let Java programs call remote objects through local stubs, using Java serialization or a binary format to send object graphs. Deserializing those graphs from untrusted input led to remote code execution through gadget chains, and the technologies also tied clients and servers to shared Java types and were hard to evolve, load balance and observe. Spring deprecated RmiServiceExporter, HessianServiceExporter and HttpInvoker in 5.3 and removed them in Spring Framework 6. The replacements are REST with JSON, gRPC and messaging, and @HttpExchange interfaces keep the clean interface-based style.

What to say in the interviewAbout 90 seconds aloud

Open with

RMI and Hessian were ways to make a remote call look like a local method call. With RMI, the client got a stub implementing the service interface, and calling it sent the arguments to the server with Java serialization.

Then, if they want more

Hessian did the same over HTTP with its own compact binary format, and Spring made both trivial with exporter beans on the server and proxy factory beans on the client. They are legacy for two main reasons.

The serious one is security: the receiver rebuilds whatever object graph the bytes describe, and attackers found gadget chains in common libraries, so a crafted payload could give remote code execution, often before authentication.

The other reason is design: client and server share the same Java classes, so they must be released together, non-Java clients are awkward, the traffic is hard to load balance and observe, and making network calls look local hides timeouts and failures.

Spring deprecated RmiServiceExporter, HessianServiceExporter, HttpInvoker and the rest of its remoting support in 5.3 and removed them in Spring Framework 6, so Spring Boot 3 applications must migrate.

I would replace them with REST and JSON DTOs, gRPC, or messaging, and if the team likes the interface style, Spring's HTTP interface clients with @HttpExchange give the same feel over plain HTTP.

About this answer

Last updated
12 November 2026
Versions it names
Spring Framework 6, Spring Boot 3, Spring Framework 5
Checked
Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the documentation below. What the checks cover
Where the question comes from
Written by Scrivio for practice. It is not taken from an interview.
Report an issue with this answer

Copy the line below and send it to the author with what you found. It carries the address of this page.

Issue with "What were Java RMI and Hessian used for, why are they considered legacy, and what has...": https://scrivio-interview-library.netlify.app/spring-boot/web-other/516ba08367/