Non-blocking Web Server for java - java

I was reading about "Tornado Web Server".
It says that it is non-blocking web server.
Is there any non-blocking server for java web app ?

You're thus looking for a Java servletcontainer/applicationserver which supports NIO (Non Blocking IO).
Pretty much all of them supports NIO: Apache Tomcat, JBoss AS, Oracle Glassfish, etcetera. On some of them (e.g. Apache Tomcat), you've to make some configuration changes first (see also its HTTP connector documentation with regard to NIO). Glassfish uses under the covers Grizzly as NIO implementation of the HTTP connector.
As to which one to choose, that depends on what parts provided by the huge Java EE 6 API you'd like to utilize. If it's just JSP/Servlet, then Tomcat suffices. If you need a bit more than just JSP/Servlet, the Glassfish Web Profile may suffice. If you'd like to utilize the entire Java EE 6 API, then go ahead with JBoss AS or Glassfish Full Platform.

Also there is a non-blocking library in java called Netty and you can use Netty to write asyn network servers like web servers.

Non-blocking sockets have been available in Java in the java.nio pacakges since Java 1.4.
The Grizzly server is a servlet container based exclusively on NIO. Most established Java webservers are older than the NIO feature and have added support for it at some point.

Besides servers that BalusC listed, there is also Grizzly.
Here is a nice description of it's non-blocking operation.

Related

Is it a good idea to host Java JAX-RS web services on IIS?

We are required to build some Java JAX-RS web services that will connect to some other external web services to retrieve data. Logically, we should host these new JAX-RS web services on a container like WebLogic. Due to cost saving measures by management, we are told to use IIS to host these JAX-RS web services as it is supposedly cheaper than WebLogic. They want the services to be written in Java because it is OS independent, so using .NET is out of the question.
(1) Is using IIS to host Java JAX-RS web services instead of a fully J2EE compliant container like WebLogic to save cost a good idea?
(2) How do we host Java JAX-RS web services on IIS 7.5? What are the required add ons?
Thanks in advance.
First of all, IIS does not support Java. See this old post in MSDN (2005)
IIS can never directly support the use of JSP because it requires an add-on to run Java code in a JVM to Load,
Therefore you always require a J2EE server to execute J2EE services, and the IIS add-on isapi_redirect (see the link). The add-on will capture the requests and forward them to the J2EE server (in the example is used tomcat)
So the answer to your question
(1) Is using IIS to host Java JAX-RS web services instead of a fully J2EE compliant container like WebLogic to save cost a good idea?
No, because you allways need a J2EE server., so the cost parameter is non applicable (without considering other aspects). I suggest also to consider some free of charge servers like Jboss, Tomcat or Jetty
Note also you do not need a fully compliant J2EE server to use JAX-RS. Latest versions of JVM are shipped with an implementation of JAX-RS.

what is the role of apache server in java swing application (3 tier)?

I have made a Java Swing application, in the GUI the user can select the type of element and choose a date then the element's informations will be shown on a JTable.i used easyPHP to create the DB.
so what is the role of apache server in this case!
can i consider it like an application server ?
A Java swing application (AFAIK out of the box, for alternatives see below) is not available over HTTP/S (and is therefore not classified as a web application) and Apache is a web server (with features such as proxy, TLS terminator etc.). Therefore there would be no need for a web server such as Apache to front your Swing application.
Apache web server is not an application server for a Swing application per se. Although it can run applications in different programming languages such as php through loading of modules. It however does not run Java web applications.
An application server in a Java perspective would be Tomcat, Glassfish, JBoss, WebLogic etc. An application server hosts an application and could provide a set of services such as Naming, HTTP processing and so on.
Perhaps you are referring to Apache Tomcat instead of Apache Web Server. If so, you would be right on the mark as that is an application server for Java web applications.
If you would like to make your application available through HTTP and enjoy the myriad and expansive benefits of an application server, I would recommend you to rethink on using Swing and utilize a technology built over Java Servlets such as JSPs, Spring MVC and so on.
If you would still like to make the Swing application available through a web server (through HTTP/S) there are some solutions out there but I have not tried any of those. Please do a search on "Swing available on HTTP" in that case. I have also provided a link as well.
You can read up on Application Servers on this wiki link.
You can read up on an HTTP end point for a Swing application here.
This Apache is not used in your application. You installed easyPHP so Apache comes with that to provide PHP programming environment.
Moreover Apache is a web server. So any web based application can be deploy here. PHP is a web programming language sot it requires Apache or any other web server.
But your application is standalone developed with JAVA SWING. So you can stop Apache server and check everything is running fine or not.

Java EE TCP Server

I'm developing a web application in Java EE/Spring/SpringWEB.
A part of the application needs to communicate with mobile devices through TCP/UDP (not HTTP). I want that all infrastructure runs in the Java EE container (Tomcat for instance). I wonder whether there's any standard or part of the Java EE container (Tomcat) I can reuse for having a TCP Server for free?
I mean I do not want to implement my own TCP server which needs to be scalable/reliable and efficent. I want to reuse as much as possible and use standards where applicable.
Well, Tomcat is not a true Java EE server, but rather the web servlet part of the Java EE stack. There is no real official TCP server lib included in Java EE, except the Java SE socket libraries. I suggest you use the open source library Apache MINA for TCP/UDP server features. It should work with Tomcat. A full Java EE stack (glassfish, websphere, weblogic, geronimo..) might disallow setting up TCP listeners, so be careful if you migrate from Tomcat to a full java ee stack.
There isn't anything in Java EE, not sure about Spring. For implementing on your own, I would highly recommend using netty as the main building block for your tcp server.

CXF and standalone web services

I'm currently writing a few applications that contain web service clients and servers, as complete standalone applications, eg without any web application server / servlet engine. I'm using plain Java 6, and for the "server" part I'm using the sun HttpServer. Working like a charm.
(actually I am using CXF, but only for their wsdl2java tool, which is more flexible than the one that ships with Java 6).
I've been wondering now if there is any benefit for me to look at frameworks like CXF. Strangely enough, I can't find any information on the CXF web site on such a scenario, they just seem to blindly assume that everybody uses an applications server (and worse, maven).
One of the reasons why I'm looking at CXF is that in the near future I expect that I need to support AIX as well, and there I can't use:
reqcontext.put(BindingProviderProperties.CONNECT_TIMEOUT, connect_timeout);
reqcontext.put(BindingProviderProperties.REQUEST_TIMEOUT, request_timeout);
CXF has this thing called an HTTPClientPolicy which would nicely fit the bill.
Does anybody have any links to articles discussing using CXF without any application server / servlet engine? Are there any other benefits that CXF could give me over the current Java 6 JAX-WS implementation?
Maarten
Almost all the samples that come in the CXF distribution are setup specifically as a "main method" type service that starts up the service and clients and such as standalone applications without any use of an app server (or even Tomcat). The CXF samples would be a good place to start.
That said, they do all use Maven now. :-)

Servlet container; What is it and do I need it in my case?

I have just ordered a VPS from my provider.
I have some Q however...
My website uses Solr, which requires the following according to their website:
"Solr requires Java 1.5 and an Application server (such as Tomcat) which supports the Servlet 2.4 standard"
I also need php 5, MySql, and the usual javascript etc...
The OS is Ubuntu 9.10
1- So what do I need to install then?
2- What is a servlet container?
3- The solr I have downloaded came with Jetty. Is Jetty a Servlet container?
Thanks
3- The solr I have downloaded came
with Jetty. Is Jetty a Servlet
container?
Yes, Jetty is a Web server and Servlet container. A servlet container is a web server that interacts with servlets, and you need one of those to host your servlets, execute them, etc.
An application server typically hosts many other facilities, such as security, authentication, Java Mail, EJB container, and many others.
PHP: Hypertext Preprocessor is a widely used, general-purpose scripting language that was originally designed for web development to produce dynamic web pages.
PHP 5 included new features such as improved support for object-oriented programming, the PHP Data Objects extension (which defines a lightweight and consistent interface for accessing databases), and numerous performance enhancements.
Servlets are Java programming language objects that dynamically process requests and construct responses. Jetty is the simplest/smallest servlet container that could be run easily in a cross platform way. That does not imply that Solr runs better under Jetty, or that Jetty is only good enough for demos, it's just that Jetty makes demo setup easier.
Users should decide for themselves which Servlet Container they consider the easiest/best for their use cases based on their needs/experience. For high traffic scenarios, investing time for tuning the servlet container can often make a big difference.
A Servlet container is basically a web server for Java Servlets and JSP pages.
Tomcast and Jetty are both Servlet containers.
In the phrase you quoted, it is using the phrase "Application server" interchangeably with "Servlet container". While Solr may only require a Servlet container, it shouldn't use the terms interchangeably.
The Servlet container is only part of a J2EE application server. Some other application servers (that also include Servlet containers) are JBoss and Apache Geronimo; Geronimo uses either Tomcat or Jetty depending on which set you install.
If you also need PHP, a Servlet Container won't be enough... you'll also need a normal webserver.
Installing the libapache2-mod-php5 module from the Ubuntu repository should install both PHP5 and Apache 2.2 for you. To install MySQL, install the mysql-server and php5-mysql packages.
Assuming you only have command-line access, installing packages on Ubuntu is done using the aptitude or apt-get programs; aptitude is preferred.
Before you install new programs, you should always run aptitude update, which updates the local index of which programs are available. Afterwards, you can upgrade existing packages with aptitude safe-upgrade and install new packages with aptitude install <packagename> (without the <>)
Ubuntu is usually pretty good about keeping the available package list up to date, and will periodically tell you on login that some packages have available upgrades. Since upgrades are almost always security updates, it is a good idea to check for them.
I also need php 5, MySql, and the usual javascript etc... The OS is Ubuntu 9.10
1- So what do I need to install then?
Use Apache HTTPD server for PHP, use Apache Tomcat for JSP/Servlet, use mod_jk to let HTTPD play proxy for Tomcat so that you can run PHP and JSP at one same site.
Since JavaScript is a client side language, you don't need to worry about it at the server side.
2- What is a servlet container?
A webserver with a JSP/Servlet API implementation. An application server is usually more than that. JSP/Servlet is only a little part of the huge Java EE API. A fullfledged application server implements pretty much all of Java EE API.
3- The solr I have downloaded came with Jetty. Is Jetty a Servlet container?
Yes, it is. It however doesn't support PHP. You need Apache HTTPD for PHP. However I am not aware of ways to connect Jetty with HTTPD.

Categories

Resources