0

I am working with Jboss JBoss EAP 6.4.5.GA (AS 7.5.5.Final-redhat-3) and I have a problem with web.xml. Here is the part of web.xml that I have:

<servlet>
    <servlet-name>Servlet1</servlet-name>
    <servlet-class>classPath.servlet1</servlet-class>
    <load-on-startup>0</load-on-startup>
</servlet>
<servlet>
    <servlet-name>Servlet2</servlet-name>
    <servlet-class>classPath.servlet2</servlet-class>
    <load-on-startup>1</load-on-startup>
</servlet>

When I start the JBOSS server, I see that my configuration is not preserved, because sometimes Servlet2 starts before Servelt1, but this should not happen. When I delete data, tmp and logs catalogs and then start JBOSS it starts Servlet1 before Servlet2, but after JBOSS restart I see Servlet2 is running before Servlet1.

Have someone ever had that kind of situation or similar and can help me with this? Maybye there is a special tag, which can tells the JBOSS "start Servelet2 exaclly after Servlet1" and it's not 'load-on-startup'".

* EDIT * I have to add interesting info about this situation. In debug mode in fresh start (delete those catalogs) first init() method starts in Servlet1 and after it in Servlet2, but after JBOSS reboot only init() in Servlet2 starts and I don't know why...

KayV
  • 12,987
  • 11
  • 98
  • 148
Kacu
  • 438
  • 4
  • 23
  • It can be done using @WebFilter Annotations – sForSujit Aug 02 '17 at 08:42
  • @WebFilter is not using to Filter instead of Servlet? – Kacu Aug 02 '17 at 08:44
  • Programatically one can suppress the servlet2 to start. i.e. by checking the presence of session variable and if it is set, start servlet2 part, so during execution, thought servlet2 tried to get started, by the checking of session variable condition, the flow stops – priya raj Aug 02 '17 at 08:51
  • How do you know that "but after JBOSS restart I see Servlet2 is running before Servlet1"? Servlets do not "run" per se, they respond to incoming requests after they have been initialised. – Steve C Aug 02 '17 at 14:20
  • Becasue I set the breakpoint when method init() starts in those servlets and turn on debug in my IDE just after start jboss and I see which one is first. As I said earlier, after fresh start everything is in correct order but after restart it is not. – Kacu Aug 03 '17 at 09:01

1 Answers1

0

Maybe you can check what does "<load-on-startup>0</load-on-startup>" exactly mean in web.xml.

I remember that this attribute not only mean the sequence but also other stuff especially when it's 0.

astrologer
  • 11
  • 1