8 Replies Latest reply on Nov 25, 2009 4:53 PM by Jevgeni Kabanov

    Javarebel style redeployment

    Stuart Douglas Master

      I got sick or redeploying everything in my ear this morning and wrote a java rebel style hot deployment filter. Every request it looks for changed classes inside seam jars deployed in an ear and replaces the definitions with the new ones. This does let it replace the method bodies of EJBs (however you cannot add business methods).


      Would people be interested in this? If so is would there be interest in seeing it included in seam?


        • 2. Re: Javarebel style redeployment
          Jason Long Novice

          I will definitely try this out.  Thanks.


          I have tried connecting the debugger to my application server in eclipse, but this is not that stable.


          Does this method work better that that?


          Also, everyone please vote for EJBTHREE-1096

          • 3. Re: Javarebel style redeployment
            Arbi Sookazian Master

            Me likes :)


            I download the zip file.  Is this compatible with Seam 2.0 and 2.1?


            How about changing the signatures of the business (local and remote interface) methods?


            Will it somehow notify if you added a business method and it didn't pick it up for the ant explode?


            Good job on this bro!  I voted for this JIRA a long time back...


            what is the technical limitation that we cannot capture new business methods as well on ant explode with your solution?

            • 4. Re: Javarebel style redeployment
              Arbi Sookazian Master

              and what about adding non-public methods to an EJB? (e.g. private void foo(), protected void bar())  will it pick that up?


              I guess I should just try it out...

              • 5. Re: Javarebel style redeployment
                Arbi Sookazian Master

                This is implemented as a seam filter...

                So do we need to modify the web.xml for our apps or what?  The only src file is this:


                public class Agent
                {
                    static Instrumentation inst;
                
                    /**
                     * Stores a reference to instrumentation
                     * @param agentArgs
                     * @param i
                     */
                    public static void premain(String agentArgs, Instrumentation i)
                    {
                        if (!i.isRedefineClassesSupported())
                        {
                            System.out.println("Class redfinition not supported");
                        } else
                        {
                            inst = i;
                        }
                
                    }
                    /**
                     * attempts to replace the specified classes while the jvm is running
                     * @param da
                     * @throws UnmodifiableClassException
                     * @throws ClassNotFoundException
                     */
                    public static void replaceClass(ClassDefinition[] da)
                            throws UnmodifiableClassException, ClassNotFoundException
                    {
                        if (inst != null)
                        {
                            inst.redefineClasses(da);
                        } else
                        {
                            System.out.println("Class redfinition not supported");
                        }
                
                    }
                }



                and it doesn't implement a Filter interface.


                ???


                am I missing something here?


                Also recommend using log4j rather than System.out.println...

                • 6. Re: Javarebel style redeployment
                  Stuart Douglas Master

                  There is ClassRedefinitionFilter in the root of the zip, it is the filter and should go in your seam project. Ajent.java is part of hot-deploy.jar, the java agent. When you start jboss start it with the jvm option -javaagent:/path/to/hot-deplloy.jar.


                  This approach uses the java instrumentation api, so it is not as good as javarebel, in that it does not let you delete methods. It may have other limitations depending on what JVM you are using.


                  This is just a quick and dirty version that I knocked up, I am going to try and work on this over easter and try and remove some of the limitations.

                  • 7. Re: Javarebel style redeployment
                    Ale Feltes Quenhan Newbie

                    I was also having problem with EJBs and JavaRebel



                    The context variable was basically used for a different purpose, which is illegal (or you have the hot deployment classloader scenario described above).


                    Stuart's suggestion worked perfect for me.
                    There is only one typo in jar's name on your post (one extra l ).
                    I placed the ClassRedefinitionFilter.java on its corresponding package


                    com.brite.framework




                    and added the jvm option to my Jboss and hot deploy worked like a charm.
                    It also advices you (with a stacktrace) for the code that could not be replaced, wich is also very handy.
                    Thanks for sharing.


                    Ale

                    • 8. Re: Javarebel style redeployment
                      Jevgeni Kabanov Newbie

                      Hi guys, if you want to help get JRebel and Seam working together please sign off here:
                      JRebelAndSeamIntegration