I have a big database controller which is written in Java. The controller reads information from the database, and interprets it into data structures which are then displayed in a CLI.

Java was chosen because writing code in it is fast and easy. Now I want to create an RPC server on top of the controller (XML-RPC or JSON-RPC for future AJAX calls), but it looks like I need a servlet container for my RPC service. I am confused because last year when I needed this kind of capability for another project in python, it took me less than 5 minutes to create the same functionality using the SimpleXMLRPCServer

The same ease of creation applies also to C# as far as I recall.

But in Java the story is different; now I need a servlet and therefore a servlet container (i.e Tomcat, Jetty) which means I need to install and maintain web servers. From what I can tell, JSON-RPC requires Spring framework in order to work.

I have already spent around two hours in learning the design and sort-of how Tomcat works without writing even one line of code.

I searched the web and found out that I have standalone options: I can use this library, but it doesn't seem maintained and it is also somewhat complex (I'm looking for something with decorators / annotations).
The other option I found is to use the so called "embedded" jetty and then trying to set it and configure it by code which also seems a tedious task.

Why isn't there a standalone mechanism for such a popular interface? Am I missing out something here?

  • 1
    You can use embedded Jetty without having to maintain a separate server wiki.eclipse.org/Jetty/Tutorial/Embedding_Jetty Mar 8, 2013 at 11:36
  • 1
    possible duplicate of Which Java framework meets these requirements?
    – user7519
    Mar 8, 2013 at 12:22
  • 1
    @JarrodRoberson - I think this question is similar, but a bit different than the link you suggest. The other question has a laundry list of requirements whereas this one is focused on a stand-alone requirement.
    – user53019
    Mar 8, 2013 at 14:32
  • @GlenH7 I totally agree
    – Guy L
    Mar 8, 2013 at 17:11

4 Answers 4


Incorrect assumptions

Your assumption that you need servlets and a server is mis-guided and incorrect. there are plenty of embeddable HTTP servers in Java, some are single classes, they aren't full featured servers, but an HTTP server is just a TCP/IP Socket based protocol. The Servlet API is just a nice abstraction away from the details.

You don't want to do RPC, you want to do REST

You will need a minimal Servlet container to use something that will accelerate your development like RESTEasy.

  • Thanks for the answer, I'll use embedded Jetty and RESTEasy. Still it takes more coding than I thought
    – Guy L
    Mar 9, 2013 at 10:31
  • @GuyL Take a look at Spring Boot. Integrated Tomcat started from a main method and you just need two annotations to turn any method into a "webmethod" / "REST-method" that can return JSON. With Spring Boot you can rest even easier.
    – ASA
    Mar 8, 2017 at 9:27

The enterprise features of Java (as in those in JEE) are not implemented by Oracle/Sun and are instead contained within the Java Enterprise Edition specification.

As a result there are numerous implementations of application servers - Tomcat, Jetty, WebSphere, etc, all of which implement different parts of the JEE specification.

Because you are using enterprise Java features, you need an application server - hence your present situation.

Jetty is a very lightweight server and you might have some luck there if you're having trouble with Tomcat.

I understand where you're coming from, doing this sort of thing in .NET is trivially easy, Java needs a little bit more work to get there but the result in the end is the same.


It is possible to simply start a Jetty instance from code, without a web.xml file or any kind of servlet configuration.

That's possible by implementing a custom Handler and passing it to the server instance, thus completely bypassing the servlet API.

HttpServletRequest and HttpServletResponse are still used, so everything is extremely similar, except it feels a lot more like doing a similar thing in python ^^

The downside is that it's way less common to do this, so google may not be entirely as helpful.

On the other hand, the differences from using the servlet API are really small, so when something goes profoundly wrong, you will likely end up with very similar exception messages and stack traces, so you're not entirely on your own in case things should one day decide to take a little side track downhill ^^


You want to create a server and you're surprised you have to install and maintain server software?

The "concept or vision" that you're running up against is the idea that if you're running a server, you really should use something solid and mature that can be monitored with standard tools, instead of just running some code and starting to roll your own admin tools as soon as you want to do anything more with it.

Besides, it's not as if setting up Tomcat (let alone Jetty) were all that complex. You don't have to understand all its capabilities to use it for a simple project like this.

  • I disagree (though I didn't -1), look at the XML-RPC server in python... 5 minutes and you get what you want. My scenarios are very simple, so I don't need a complex solution
    – Guy L
    Mar 9, 2013 at 10:28
  • 3
    @Guy L: My point is that if you want to do more than experiment and actually run this server permanently, you quickly want more than such a simple solution can provide. You are correct though in that the Java ecosystem often prioritizes making everything possible at the expense of making simple things harder than necessary. Mar 9, 2013 at 14:57
  • 1
    A big project does not suddenly turn into a web server just because it starts listening to a socket and handle http requests. This may be a tiny fraction of what it does and should not require putting this tiny fraction into the driver seat and maybe even let it own the main method. Imagine every part of a project demanded this kind of attention... Sometimes, a socket serving http requests is just a socket serving http requests.
    – yeoman
    Mar 7, 2017 at 22:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.