Using Jersey without an application server - java

I am looking to use Jersey without the need of installing an application server such as Tomcat or Glassfish. Ideally I would like to create a lightweight program that listens on a port and allows connections. I believe you can do this with Grizzly + Jersey but I am not sure how easy this is, because from my understanding Grizzly is used to write new http servers from scratch?
Restlet looked good in this regard because it included an internal http server but the documentation provided is extremely meager.

You can use a light-weight servlet container like jetty. you can bundle and ship this with your application. Also building and shipping jetty with your application is very easy.

I've deployed an app recently that uses embedded Jetty in Spring to launch Jersey, so this is 100% possible. Jersey, in fact, has a SpringServlet for easy delegating to a Spring context based REST implementation. If you have additional questions down this route, let me know. It wasn't the most straight forward, but I can talk you through some of it with the appropriate links.

Related

What is the recommended Application Server for Playframework 2.x deployment?

I planned to use jBoss to deploy, manage and monitor playframework applications, but from https://github.com/play2war/play2-war-plugin/wiki/ConfigurationLoggingJBoss7, I found jBoss and playframework doesn't play very well together.
From the official documentation, it only says Apache or Nginx can be used for HTTP server, but no application server is mentioned there. Does anyone have ideas about what would be a suiable application server for Playframework deployment? How about Apache Tomcat or GlassFish?
You don't need any application server to run a Play 2.x application. The application can run stand alone, it internally uses Netty to handle the sockets, Akka to handle the concurrency etc.
Usually Apache or Nginx are used in front of a Play application to offload serving of static resources, HTTPS handling (both can be done directly in the application itself) and above all to allow public access to multiple applications on the same IP and port under different paths.
In Play 1.0 you could build to a war to run in a container like you describe. This feature was removed in Play 2.0 to promote the embedded Netty server as the main way to deploy applications. Now you need the play2war to achieve this functionality.

What are some Servlet Container for Netty

I wanted to build myself a Web based chat application (something like hipchat or facebook chat)I think netty is the way for this since it is event driven, However. Netty does not have any servlet container. So How do I build my own servlet container for netty? or better yet how do you build your own ServletContainer?
Perhaps Netty is too low level for what you are trying to accomplish. If you want an embedded solution in which servlets can be executed, why not trying Jetty instead?
http://www.eclipse.org/jetty/

Restful Webservice Java, server side

I'm trying to develop a small server which would include one restful webservice.
I'd like to use JAX-RS for the webservice part, but every example I'm seeing is using a tomcat server, and I can't use any 'application' server (meaning I can create a server in my code, but can't run it from the outside).
Well anyway I was wondering if anyone had any sample to show, and any advice on which light library I could use to run such a simple server into my code (can't use any gpl /lgpl etc licence, so no jersey for example).
Thank you.
It's possible to embed Tomcat in your application, see here for an example: http://java.dzone.com/articles/embedded-tomcat-minimal
Another popular choice for an embedded servlet container is Jetty, they have a tutorial here.
Edit
The examples provided with Jersey can also be helpful, here's one for running using the Grizzly HTTP library: https://github.com/jersey/jersey/blob/master/examples/helloworld/src/main/java/org/glassfish/jersey/examples/helloworld/App.java
You can even use the HTTP server that's bundled with the JDK (probably not the way to go for a real application): https://github.com/jersey/jersey/blob/master/examples/helloworld-pure-jax-rs/src/main/java/org/glassfish/jersey/examples/helloworld/jaxrs/App.java
Have you checked out http://www.sparkjava.com/?
It's very light-weight and concise.
Building a server into code is nothing. See "Embedding Jetty", for one. There are plenty of other options with varying degrees of difficulty and capabilities, like the Simple Framework, Tomcat, Grizzly, Netty, and Vert.x, to name a few. Then, if you're not stuck with Java, the language, there's Ratpack for a lightweight REST server. Otherwise, running something like Jersey in an embedded server is quite simple. I do it every day in tests.

Containerless deployment of JAX-RS Restful Service In Java

JAX-RS is a specification that helps you develop restful web services in Java.
But JAX-RS seem to be requiring a servlet container like "Tomcat"or "Jetty".
Managing container in a clustered mode is painful and more operations heavy.
Is there way to start JAX-RS service like a normal Java program/application ?
I want to use JAX-RS implementation but I don't want to follow typical"deploy" cycle.
JAX-RS is strongly linked to HTTP, hence most implementations (eg Jersey, Apache CXF) run in a servlet, which in turn runs in a container such as Tomcat or Jetty. I guess you could develop your own standalone JAX-RS implementation, but you'd end up reinventing the wheel as you'd be forced to implement most aspects of a web server.
Your worries about clustering also seem unfounded. Clustering Tomcat is simple, it is a very common thing to do and there's plenty of information available on the subject. It seems like clustering a custom implementation would actually be a much harder job.

Java Web Service for .NET 2.0 Client on Linux (Fedora)

I'm tasked with creating a Java Web Service for a .NET 2.0 client to consume.
What would your suggestions for the implementation be?
The solution doesn't need to be very heavyweight (don't need a full Java EE container I believe) but what do you think is the best solution for this? I have thought about using Glassfish v2 with JAX-WS annotations (#WebService), and JAXB XML Bindings(e.g. #XmlElement), which I assume the .NET client would be able to consume?
Has anyone tried this scenario?
Would Glassfish be overkill though, since I'm merely using the Web Service as a mechanism for .NET on Windows to communicate to the Linux box, the underlying application is extremely small.
Any suggestions are more than welcome :)
Thanks,
James
P.S. Other notes - would you use Axis/CXF instead of Glassfish? Would you use a servlet container such as Tomcat? etc.
I have used Axis2 and it works.
I had the same problem of making Data Exposing API (Web Service in my case) in Java.
I made the web service using Axis2 and Spring (to access database) and the WSDL created via Axis2 was easily consumed via ASP.NET Application via its Add Web Service Dialog Box and the corresponding Proxy Classes were created easily.

Categories