Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question
You can use embedded Jetty without having to maintain a separate server – Martin Wickman Mar 8 '13 at 11:36
possible duplicate of Which Java framework meets these requirements? – Jarrod Roberson Mar 8 '13 at 12:22
@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. – GlenH7 Mar 8 '13 at 14:32
@GlenH7 I totally agree – Guy L Mar 8 '13 at 17:11
up vote 4 down vote accepted

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.

share|improve this answer
Thanks for the answer, I'll use embedded Jetty and RESTEasy. Still it takes more coding than I thought – Guy L Mar 9 '13 at 10:31

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.

share|improve this answer

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.

share|improve this answer
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 '13 at 10:28
@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. – Michael Borgwardt Mar 9 '13 at 14:57

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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