We have a monitoring app (Java Spring app) that performs a bunch of tests for various web services, web apps, databases, etc. and notifies us when things have gone wrong.
The apps we're monitoring are Java web apps (written in Vaadin), and occasionally they will lose their database connection and we don't find out until a user tries to do something that hits the database and it fails.
The apps are running on Tomcat servers, using jndi -- what are some lightweight/easy to implement options for programmatically figuring out whether our Tomcat servers still have good connections to their databases?
Keep in mind that the monitoring app as well as the other apps are all running on different Tomcat servers on different boxes.
Unfortunately, there are no web services that we can call for these apps, otherwise we would just do that.
I have a java server application which uses sockets to communicate with clients. Application needs to have load balancing, session sharing among instances and database connection pooling. Currently this is an standalone application without load balancing.
Is it possible to use an application server like GlassFish to host this server application? If it is, how should I do it?
I need to remind that this is NOT a web application.
My thoughts:
It is possible. Web apps can create their own threads or thread pools. Unless prevented from doing so by a security policy, they can open sockets and listen.
You won't benefit from glassfish session management, as that is part of the HTTP stack. You'll have to have a servlet, or servlet-context-listener whose only job is to initialize your application on startup. That is a bit weird, when there is no web content, but I guess it is ok. Web apps are often deployed on machines that might only have web ports open to them in the firewall (80, 443, etc). You could add a HTTP page to the app for administration/monitoring, and make it a web app, at least partially.
I am a little confused about the roles of a java application server and its differences from a web server.
I found many sites explaining the same difference between the two but not to my satisfaction.
So please explain me about the two following cases:-
1)App. Server and its difference with web server:
From these two links:
Difference between an application server and a servlet container?
What is the difference between application server and web server?
web server: It handles everything through http protocol by accepting requests from clients and sending
responses to them with the help of its servlet container(e.g Apache Tomcat)
App. Server: An application server supports the whole of JavaEE like JMS,JPA,RPC etc.
Now what I am confused with is that how can I use a lot of JavaEE APIs like JMS,JPA etc. with my Tomcat
by adding their jar files in my web application ?
Does that mean that if I use an appliation server I don't have to add those jar files?(I don't think so)
2)The roles of an appl. server (This is very important to me)
From Wikipedia
http://en.wikipedia.org/wiki/Application_Server
An application server provides services such as security,transaction support etc.
"The term is often used for web servers which support the JavaEE" -- It sounds like if we add the required jar files of JavaEE APIs a web server becomes an appl. server.What about it.
Now my question is how an application server performs the tasks of security control or transaction management by itself ?
E.g. in my web application using Spring framework I am providing security by using spring-security and transaction management by using #Transactional annotation and all those things you know.
So does the appl. server have anything to do with my security or transaction management or it has its own ways ?
Forgive my ignorance.
Using Spring, you're in fact embedding some kind of Java EE container inside your application. But even when using Spring, if you need JTA support (because you need distributed XA transactions), you'll need to use an additional transaction manager. If you need JMS, you'll need to install an additional JMS broker. If you need connection pooling, you'll need to use an additional connection pool. Sometimes it's as simple as adding additional jars to the classpath and properties or XML files. Sometimes it's harder.
A Java EE app server comes with everything bundled. You have less flexibility, but you don't need to install, configure and make everything work by yourself.
When you use the Java EE framework, that is a specification. So the application server, if it is Java EE compliant, needs to implement this. So once it is implemented the specification, then it will address Security,transaction etc because it is mentioned in the spec. So it is a contract. Whereas, in a web server, it will just pull out your static resource. There is no need for handling other stuff.
In case of the Spring framework, the framework knows how to handle transaction, security etc. So particularly the developer need not look into these aspects which are implemented by the Application Server in the other scenario.
how an application server performs the tasks of security control or transaction management by itself
It is rather the specification that address these issues, not the application server. So, the duty of the app server is to implement these.
So, if your application is Java EE compliant, then these areas will be addressed and the implementation would have been done by the app server.
May be this is oversimplification,
A web server is basically a HTTP server serving contents over http protocol. So a web server is simply about serving the contents over http protocol. A typical example would be Apache web server. This is simply a file server.
Now the question is where does the web server gets the contents from ? Possible sources are
Static contents (the contents like images/css etc) which are not generated on request but statically served.
Dynamic contents: Simply put, the contents to be served are generated upon the user request.
For the static contents, the web server does not need anything as it simply reads the file and serves it.
For dynamic contents, the web server might need help of additional components which will generate the contents to be served.
Here the Application Server comes into picture.
Now these additional components referred earlier, might interact with database or some other system etc.
In a web environment where your website is exposed to huge number of users (intended/unintended), you need typical services like transaction/security/concurrency etc. so that the user get expected responses and do not see inconsistencies in the behavior of the application.
An application server has inbuilt abilities to manage transaction/security/concurrency/resource management. generally these are referred as Managed services and environment offered by them is called Managed Environment where these basic services are managed by the application server and programmer does not have be bother for them.
Application Server needs web servers or we can say Web servers use Application server's services to generate dynamic contents.
For example, JBoss uses Tomcat as inbuilt web server. Whereas web logic has its own web server. Tomcat again can be called as application server (in principle) as it also offers managed environment for servlets (it manages concurrency and instance pool of servlets/JSPs ).
Coming your your example of Spring:
An Application server will come inbuilt with transaction/security etc whether you need it or not. The Spring offers a very nice way handling this. Spring has all these things BUT you use what you need. Not just these, but just a Java Web Sever like Tomcat is sufficient to build a full fledged services that needs an application server.
How can I connect a realtime application which has a totally different life-cycle with WebApp to JBoss or GlassFish?
I need it to create a realtime reporting system. Using Sockets is not possible.
Is it possible to attach an application rather than a web applications to Java application servers so they can work together?
Yes. Java EE defines application clients, that can be any java apps.
With some full Java EE profiles, connections via CORBA should be possible and you could then also use C++ clients.
Another option to hook up any client could be messaging.
I am trying to understand how to manage (scale/start/stop/upgrade) webservices written using Spring WS/REST. If you typically deploy a web application on tomcat, you can easily stop it, restart it. If I deploy Spring WS, will they be deployed in similar fashion to webapp? Would they be accessible as individual applications in tomcat (or any WS container) admin page?