• 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:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

Problem with EAR file in a struts app deployed in weblogic

 
Ranch Hand
Posts: 372
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have deployed a struts-based application in weblogic server as an EAR file. I have a servlet that extends ActionServlet. In its init() method I have put some important start up code and in its destroy method, I have put shutdown code. I am loading that servlet on start up in web.xml. Hence its init() method would be getting called on server start up. But we are encountering a strange error

Whenever we deploy a new EAR file in weblogic, the server is starting and the servlet's init() method is getting called. But then immediately after the server starts, destroy of that servlet is getting called and the shutdown code is running. Then again init() is getting called and the start up code gets executed again. This is causing problems as our start up code starts an Orbix daemon and should be executed exactly once. I think what is happening is it is creating an instance of the servlet on start up, then after the server starts, it is destroying that instance and then creating a new instance. This problem happens ONLY when a fresh EAR is deployed. It does not happen when we start the server second time or third time after the EAR is deployed.

Also this problem does not occur when we deploy the web app as a separate WAR file, happens only when deployed as a EAR file and on fresh deployment

We are using weblogic 8.1 SP 2

Has anyone encountered a similar problem? Where else do you think is a reliable place to put our start up code and shut down code in a struts application?
 
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Creattion and destroy of servlets absolutely depends on the web-server. You may not control this behaviour. So in my opinion you shouldn't write such code that depends on web server mechanism.
 
I have a knack for fixing things like this ... um ... sorry ... here is a consilitory tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic