1 2 Previous Next 15 Replies Latest reply on Nov 25, 2010 1:54 PM by jpsabadini

    Deployment Order - HTTPServlet lifecycle

    jpsabadini

      Hi all,

       

      I'm facing a little issue with two Servlets and its deployment order.

       

      My application is composed by an ear module and a war module (two separated files). In the ear module I have a Servlet named ServletA and in war module I have ServletB. I need to request from ServletB (from a method called by init() ) to ServletA. So far nothing special about it, but the problem appears when the JBoss is starting because the ServletA isn't available until the JBoss completes its startup procedure. My first approach was to change the deployment order to force the ear be the first one, but even so the ServletA is not available when ServletB calls it.

       

      So I need a way to determine when the ServletA is available for requests! How can I do this?

       

      JBoss version: 4.2.2GA

      Java(TM) SE Runtime Environment (build 1.6.0_20-b02)

       

      Any help will be appreciated!

       

       

      Regards

      JP

        • 1. Re: Deployment Order - HTTPServlet lifecycle
          wdfink

          Problem is that the deployment is done in the following order

          *.deployer, *.sar, *-service.xml, *.rar, *-ds.xml, *.jar, *.war, *.ear

          same files are deployed in alphabetic order.

           

          What help is to move the war file into the deploy/deploy.last folder.

          This folder is scanned after all other.

          • 2. Re: Deployment Order - HTTPServlet lifecycle
            jpsabadini

            Hi,

             

            I already change the deployment order... Jboss is deploying ear before war files, but even so the ServletA isn't available until the JBoss startup procedure is done!

             

            Thanks for your help!

            JP

            • 3. Re: Deployment Order - HTTPServlet lifecycle
              wolfc

              TomcatService adds a NotificationListener on the server. Once the server is started the connectors are started up.

              • 4. Re: Deployment Order - HTTPServlet lifecycle
                jpsabadini

                So, I could implement a NotificationListener that "waits" until the ear is available for requests?

                 

                regards,

                JP

                • 5. Re: Deployment Order - HTTPServlet lifecycle
                  wdfink

                  I'm not sure whether it will work because there is a WAR included in the EAR file.

                  Do you test the deploy.last directory (without changing the deploy order)?

                  • 6. Re: Deployment Order - HTTPServlet lifecycle
                    jpsabadini

                    The war and ear modules are in separated files!

                     

                    I also tried to deploy without alter deploy order, but couldn't solve the issue.

                     

                    Regards

                    JP

                    • 7. Re: Deployment Order - HTTPServlet lifecycle
                      wdfink

                      How your ServletA is deployed?

                      Is it accessible if you only deploy your EAR?

                      • 8. Re: Deployment Order - HTTPServlet lifecycle
                        jpsabadini

                        ServletB is in app2.war, that mainly has a jsp and a Servlet (ServletA.java).

                         

                        Servletb is like this:

                         

                        public class ServletB extends HttpServlet {

                         

                            private static final long serialVersionUID = -6262725994880383230L;

                         

                            /**
                             * Constructor of the object.
                             */
                            public ServletB() {
                                super();
                            }

                         

                            /**
                             * Destruction of the servlet. <br>
                             */
                            public void destroy() {
                                super.destroy(); // Just puts "destroy" string in log
                                try {
                                    finalizeChronJobs();
                                   } catch (SchedulerException e) {
                                    e.printStackTrace();
                                }
                            }

                         

                            public void doGet(HttpServletRequest request, HttpServletResponse response)
                                    throws ServletException, IOException {
                               
                                String command = request.getParameter("command");
                                if("recreateHashmap".equals(command)){
                                    recreateCameraMonitor();
                                } else if("refreshHashmap".equals(command)){
                                    initilizeCameraMonitor();
                                }
                            }

                         

                            /**
                             * The doPost method of the servlet. <br>
                             *
                             * This method is called when a form has its tag value method equals to post.
                             *
                             * @param request the request send by the client to the server
                             * @param response the response send by the server to the client
                             * @throws ServletException if an error occurred
                             * @throws IOException if an error occurred
                             */
                            public void doPost(HttpServletRequest request, HttpServletResponse response)
                                    throws ServletException, IOException {

                         

                            }

                         

                            /**
                             * Initialization of the servlet. <br>
                             *
                             * @throws ServletException if an error occure
                             */

                        public void init() throws ServletException {
                                initilizeCameraMonitor();
                            }
                           
                            private void finalizeChronJobs() throws SchedulerException{
                                SchedulerFactory schedFactory = new StdSchedulerFactory();
                                Scheduler sched = schedFactory.getScheduler();
                                boolean isDeleted = sched.deleteJob("CheckMessageAge", "CAMSTATUS_CHRONGROUP");
                                if(isDeleted)
                                    System.out.println("Job was deleted");
                                else
                                    System.out.println("Job was not deleted");
                                sched.shutdown();
                            }
                           
                            private void initilizeCameraMonitor(){
                                String cgiResponse = ConnectionUtils.getCamerasToWatchFromVmon();
                                System.out.println(cgiResponse);
                                CameraHashMap cameraHashMap = CameraHashMap.getInstance();
                               
                                try {
                                    cameraHashMap.addCameraMonitor(cgiResponse);
                                } catch (JDOMException e) {
                                    // TODO Auto-generated catch block
                                    e.printStackTrace();
                                } catch (SchedulerException e) {
                                    // TODO Auto-generated catch block
                                    e.printStackTrace();
                                } catch (IOException e) {
                                    // TODO Auto-generated catch block
                                    e.printStackTrace();
                                }
                            }
                           
                            private void recreateCameraMonitor(){
                                CameraHashMap cameraHashmap = CameraHashMap.getInstance();
                                cameraHashmap.resetCameraHashmap();
                                initilizeCameraMonitor();
                            }
                        }

                         

                        So in init() method I call to initilizeCameraMonitor(), that throws a Exception because queries to ServletA and ServletA isn't available when Jboss is deploying the modules. Remember, I modified the deploying order, so in my Jboss ear files are first.

                         

                        Thank for your reply!

                        JP

                        • 9. Re: Deployment Order - HTTPServlet lifecycle
                          jpsabadini

                          Sorry, I explained ServletB, but you asked about ServletA. ServletA is in a war that in turn is inside an ear.

                          There is nothing special about it. Just reponds to requests (GET method)

                           

                          Regards.

                          JP

                          • 10. Re: Deployment Order - HTTPServlet lifecycle
                            jpsabadini

                            Hi,

                             

                            I was searching arround the forum and I didn't find the solution for this... I'm really stuck here. Let me rephrase the problem:

                             

                            I want that b.war waits until a.war is available for requests.

                            Remember that a.war is in an ear.

                             

                            Any hints?

                             

                            Regards,

                            • 11. Re: Deployment Order - HTTPServlet lifecycle
                              wdfink

                              As far as I understand,

                              ServletA packed in a WAR that is part of an EAR

                              ServletB is in a WAR and need ServletA within the init()

                               

                              So I would try to store ServletB.WAR in deploy/deploy.last to ensure it is the last in deploy order.

                              For me that works for a SAR that need services from an application (EAR)

                              • 12. Re: Deployment Order - HTTPServlet lifecycle
                                jpsabadini

                                Yes, is exactly as you said.

                                But, what did you mean by store ServletB.war in deploy/deploy.last ? Is a dir that I could create in order to modify deployment order?

                                 

                                Thanks for your help!

                                 

                                Regards,

                                • 13. Re: Deployment Order - HTTPServlet lifecycle
                                  jpsabadini

                                  Just for the record, my org.jboss.deployment.MainDeployer-xmbean.xml is configured like this:

                                   

                                  <attribute access='read-write' setMethod='setEnhancedSuffixOrder' getMethod='getEnhancedSuffixOrder'>
                                        <description>Allows the override of the suffix order declared by subdeployers, using the syntax [order:]suffix
                                        </description>
                                        <name>EnhancedSuffixOrder</name>
                                        <type>[Ljava.lang.String;</type>
                                        <!--
                                           Statically set one or more enhanced suffix orders, independent of the value proposed by subdeployers.
                                           Some deployers may also allow the suffixes/orders to be set locally, so that's preferable too.
                                           For reference, this is the list of enhanced suffixes likely to be set by deployers (it may not
                                           be completely up-to-date, or there can be user-defined deployers).
                                          
                                           050:.deployer,050:-deployer.xml,100:.aop,100:-aop.xml,150:.sar,150:-service.xml,200:.beans,250:.rar,300:-ds.xml,350:.har,400:.jar,400:.ejb3,400:.par,500:.war,600:.wsr,650:.ear,700:.jar,750:.zip,800:.bsh,900:.last
                                          
                                           Until we resolve some startup issues, we'll setup some static enhanced suffix orders bellow
                                           and leave the rest of the suffixes contributed dynamically by registering deployers.
                                        -->
                                        <descriptors>
                                           <value value="250:.rar,300:-ds.xml,400:.jar,550:.jse,600:.ear,650:ServletB.war,750:.war,800:.bsh"/>
                                        </descriptors>
                                     </attribute>

                                   

                                   

                                  ServletB.war is actually deploying after ServletA.war, but I getting a timeout error, because ServletA.war isn't available yet, even it is deployed!

                                  • 14. Re: Deployment Order - HTTPServlet lifecycle
                                    wdfink

                                    If you create a deploy.last directory within the deploy folder and place some deployable here it will be deployed after files in the deploy folder.

                                    1 2 Previous Next