Win a copy of Micro Frontends in Action this week in the Server-Side JavaScript and NodeJS forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

Deploy executable jar on Glassfish

Ranch Hand
Posts: 649
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
Ranch Hand
Posts: 261
Android Angular Framework Spring AngularJS Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, Puspender:
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.

Good luck!
No prison can hold Chairface Chippendale. And on a totally different topic ... my stuff:
the value of filler advertising in 2020
    Bookmark Topic Watch Topic
  • New Topic