Win a copy of Rust Web Development this week in the Other Languages 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

Startup Classloading in Websphere

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi
I am using WebSphere4.0 AEs.I want to load a class as soon as server starts up. In there any option for that.
For example in weblogic server admin console there is one option called startup and shutdown.
There you can specify the class which you want to load.Is there any option in WebSphere?
Help needed.
Thanks
Sumona
 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can pre load a servlet, and let it perform the tasks at startup time. This can be setup in web.xml file.
<servlet>
<your servlet parameters ... />
<load-on-startup>1</load-on-startup>
</servlet>
 
Rajeev Gupta
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
example:
<servlet>
<your servlet parameters ... />
<load-on-startup>1</load-on-startup> </servlet>
 
Ranch Hand
Posts: 906
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What do you mean by

.I want to load a class as soon as server starts up.


Do you mean as soon as the Admin server starts.
Or as soon as the application server where your application is deployed starts
What kind of class is it ? How are you going to use it ?
Maybe this documentationm from the infocenter could help
 
Ranch Hand
Posts: 213
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
WebSphere has a similar feature, called as Custom Services. But unlike WebLogic, in which you can give any arbitrary class file with a main() method, the custom service in WebSphere *has* to implement a specific interface. When the application server starts up, it will call a particular method on your class. Search the WebSphere docs for specifics on this.
However you must be careful in using this WebSphere feature. WebSphere makes no guarantee about the order in which this custom service will be called. Also there is no guarantee that any app-server services (eg, JNDI naming service, Connection Pools) will be fully initialized when your custom service is called. So if your custom class needs to lookup, say a JNDI reference, it may not be available!
As someone else suggested, the cleanest way is to implement a startup servlet, which simply calls your custom class within the init() method. Using this approach, it is guaranteed that the app-server services will be fully initialized by the time the servlet is loaded.
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic