Is it possible to deploy an executable jar file on Glassfish server? If yes, where should I deploy the jar and its dependencies?
My requirement is that the executable jar file should execute on the server startup.
I don't know GlassFish very well. I only used it briefly for learning about 4 years ago. I used to work with JBoss a lot more. But I think I can contribute something because I do know something about the standards.
GlassFish may have some capabilities of which I know nothing. However, as a JavaEE server it is capable of having either Wars or EJB Ears deployed on it, containing components. Rather than an executable Jar, if I were you I would deploy the jar as a Singleton Session Bean. Here is a quote from one of the tutorials:
Singleton Session Beans
A singleton session bean is instantiated once per application and exists for the lifecycle of the
application. Singleton session beans are designed for circumstances in which a single enterprise
bean instance is shared across and concurrently accessed by clients.
Singleton session beans offer similar functionality to stateless session beans but differ from
them in that there is only one singleton session bean per application, as opposed to a pool of
stateless session beans, any of which may respond to a client request. Like stateless session
beans, singleton session beans can implement web service endpoints.
Singleton session beans maintain their state between client invocations but are not required to
maintain their state across server crashes or shutdowns.
Applications that use a singleton session bean may specify that the singleton should be
instantiated upon application startup, which allows the singleton to perform initialization tasks
for the application. The singleton may perform cleanup tasks on application shutdown as well,
because the singleton will operate throughout the lifecycle of the application.
Establishing EJBs like this is pretty easy nowadays. You don't even need an "ear" file (a "war" or 'web archive' will do, and you won't need Web content if you don't need it). Since you won't even be contacting this one using a client, you won't need anything except the singleton. You only need to lookup the annotations required.
If a chicken that is half full crosses the road, will anyone hear it?