J2EE startup stuff in portable way


General J2EE: J2EE startup stuff in portable way

  1. J2EE startup stuff in portable way (1 messages)

    Hi all,

      On my current project there is used 4 WLS startup classes to populate caches and initialize singeltons.However I don't like this because :(used API specific to WLS and app. server classpath is poluted->no full redeployment all appl., because EJBs depend on this startup classes)

      I am planning to introduce StartupWebApplication. Which is simple WebApp with 1 startup servlet (set loadonstartup=1 in web.xml. On servlet there is init hook to create and bind objects into JNDI. Destroy method unbinds these from JNDI.
      EJB should be changed to lookup the JNDI for these static objects, if they want to read it.
      One problem is J2EE1.3 server first deploys EJBs and on second place deploys (and runs my startup servlet)WebApplications.
      Is it necessary for EJBs,while deploying EJBs, to have access to the JNDI binded objects ? (because I expect the objects are bind in WebApp after EJB deployment).
      What if I d like to introduce JNDI objects caching in setSessionContext or ejbCreate methods, so that I csn not perform expensive lookups into JNDI everytime.
    Thanks Roman
  2. If the ejbCreate() method is not working for you, you try lazy-loading your JNDI-bound objects:

    private Object jndiObject;

    private Object getJndiObject() {
      if (jndiObject == null) {
        this.jndiObject = // Get object from JNDI
      return this.jndiObject;

    Add type-safety and cast operations as appropriate ...