0

I need to instantiate a Java object after all resources are loaded but before my index.xhtml is rendered. This will be a configuration bean, or application context. I have created a Startup Servlet, and set the tag to 1, however; this runs before my .xml files are loaded which is where my configuration is located. Is there a standard or 'best-practices' way of accomplishing this?

My objective is to unmarshall the data using java.xml.bind the location of my xml file is WebContent/WEB-INF/configuration.xml. This operation will be done in a Singleton class which will serve as my application context.

BalusC
  • 992,635
  • 352
  • 3,478
  • 3,452
vhdz04
  • 149
  • 14
  • 1
    This question is way too ambiguous in order to be concretely answerable. You basically added three different possible contexts to the question: Java, JSF and Servlets. Each have their own set of "XML files" and their own lifecycle. Which XML files exactly are you talking about and how exactly are you trying to obtain data from them? – BalusC Dec 02 '17 at 08:39
  • BalusC, thank you for the guidance. I have edited my question to provide more detail. – vhdz04 Dec 02 '17 at 12:48
  • Then I don't understand your problem with "this runs before my .xml files are loaded". That shouldn't make any difference at all. Apparently you're simply accessing them in a wrong way. You can at least access files at that location anytime you have a ServletContext instance at hands. The abovelinked duplicates should get you started. – BalusC Dec 02 '17 at 12:54
  • @BalusC Thank you for the information. This will set me in the right direction. – vhdz04 Dec 02 '17 at 18:22

0 Answers0