10 Replies Latest reply on Nov 5, 2010 1:52 AM by jaikiran

    Dynamic class loading

    frontline2

      How can I get jboss to reload changed classes (or restart the application) like tomcat does?
      So if I have some classes or jar:s under deploy/MyApp.ear/MyStuff.war/WEB-INF/classes and lib/ and I change them, the changes get noticed and the new classes loaded (and the webapp gets reloaded if needed).

      Now it just notices changed jsp-files, and ofcourse hotdeploys .ear files in the deploy-directory.

        • 1. Re: Dynamic class loading
          frontline2

          Allright, should I understand this as jboss not being able to do this??
          Should be simple, but I haven't found any configuration settings that would help with this.
          Come on, throw me a bone. How do you develop your apps without this? Deploy the whole ear all the time?

          • 2. Re: Dynamic class loading
            beyarecords

            frontline,
            I have asked this question before and the reply I got was to re-deploy your web application....

            • 3. Re: Dynamic class loading
              dilipl

              Any luck with this? I need to do the same (change a jar, in web-inf/lib where my code resides) and have jboss pick it up. I have the app copied to the deploy dir in the exploded format. Using Jboss 4.2. Any ideas?

              • 4. Re: Dynamic class loading
                wdfink

                There are two ways do hotdeploy:

                - use a JAR/WAR/EAR file, will be redeployed when changed

                - use an exploded ..., will only be redeployed if (ooh let me think) if META-INF/app.xml WEB-INF/web.xml changed.

                  this is because of performance, only check one file and not the whole directories

                • 5. Re: Dynamic class loading
                  dilipl

                  I understand the two options.

                  For option 1, we do not want to do that as it takes a long time to create the EAR

                  option 2 :- This is what I have been trying. I update the jar in the exploded ear (it's in the web-inf/lib folder of the war, that's how the product we are using has it packaged) and "touch" the application.xml and/or web.xml. But I get an error. Deployment failed (stack trace below) . I am not sure why? Is it because the jar is in web-inf/lib?

                   

                   

                  Stacktrace

                  org.jboss.deployment.DeploymentException: URL file:/C:/Adobe/Adobe LiveCycle ES2/jboss/server/lc_turnkey/deploy/adobe-contentservices.ear/contentservices.war/ deployment failed
                  at org.jboss.web.tomcat.service.TomcatDeployer.performDeployInternal(TomcatDeployer.java:379)
                  at org.jboss.web.tomcat.service.TomcatDeployer.performDeploy(TomcatDeployer.java:104)
                  at org.jboss.web.AbstractWebDeployer.start(AbstractWebDeployer.java:375)
                  at org.jboss.web.WebModule.startModule(WebModule.java:83)
                  at org.jboss.web.WebModule.startService(WebModule.java:61)
                  at org.jboss.system.ServiceMBeanSupport.jbossInternalStart(ServiceMBeanSupport.java:289)
                  at org.jboss.system.ServiceMBeanSupport.jbossInternalLifecycle(ServiceMBeanSupport.java:245)
                  at sun.reflect.GeneratedMethodAccessor3.invoke(Unknown Source)
                  at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
                  at java.lang.reflect.Method.invoke(Unknown Source)
                  at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
                  at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
                  at org.jboss.mx.server.Invocation.invoke(Invocation.java:86)
                  at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
                  at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
                  at org.jboss.system.ServiceController$ServiceProxy.invoke(ServiceController.java:978)
                  at $Proxy0.start(Unknown Source)
                  at org.jboss.system.ServiceController.start(ServiceController.java:417)
                  at sun.reflect.GeneratedMethodAccessor9.invoke(Unknown Source)
                  at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
                  at java.lang.reflect.Method.invoke(Unknown Source)
                  at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
                  at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
                  at org.jboss.mx.server.Invocation.invoke(Invocation.java:86)
                  at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
                  at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
                  at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:210)
                  at $Proxy46.start(Unknown Source)
                  at org.jboss.web.AbstractWebContainer.start(AbstractWebContainer.java:466)
                  at sun.reflect.GeneratedMethodAccessor489.invoke(Unknown Source)
                  at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
                  at java.lang.reflect.Method.invoke(Unknown Source)
                  at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
                  at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
                  at org.jboss.mx.interceptor.AbstractInterceptor.invoke(AbstractInterceptor.java:133)
                  at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
                  at org.jboss.mx.interceptor.ModelMBeanOperationInterceptor.invoke(ModelMBeanOperationInterceptor.java:142)
                  at org.jboss.mx.interceptor.DynamicInterceptor.invoke(DynamicInterceptor.java:97)
                  at org.jboss.system.InterceptorServiceMBeanSupport.invokeNext(InterceptorServiceMBeanSupport.java:238)
                  at org.jboss.ws.integration.jboss42.DeployerInterceptor.start(DeployerInterceptor.java:93)
                  at org.jboss.deployment.SubDeployerInterceptorSupport$XMBeanInterceptor.start(SubDeployerInterceptorSupport.java:188)
                  at org.jboss.deployment.SubDeployerInterceptor.invoke(SubDeployerInterceptor.java:95)
                  at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
                  at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
                  at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
                  at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:210)
                  at $Proxy47.start(Unknown Source)
                  at org.jboss.deployment.MainDeployer.start(MainDeployer.java:1025)
                  at org.jboss.deployment.MainDeployer.start(MainDeployer.java:1015)
                  at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:819)
                  at org.jboss.deployment.MainDeployer.redeploy(MainDeployer.java:588)
                  at org.jboss.deployment.MainDeployer.redeploy(MainDeployer.java:562)
                  at org.jboss.deployment.MainDeployer.redeploy(MainDeployer.java:547)
                  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                  at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
                  at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
                  at java.lang.reflect.Method.invoke(Unknown Source)
                  at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
                  at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
                  at org.jboss.mx.interceptor.AbstractInterceptor.invoke(AbstractInterceptor.java:133)
                  at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
                  at org.jboss.mx.interceptor.ModelMBeanOperationInterceptor.invoke(ModelMBeanOperationInterceptor.java:142)
                  at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
                  at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
                  at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
                  at org.jboss.jmx.adaptor.control.Server.invokeOpByName(Server.java:258)
                  at org.jboss.jmx.adaptor.control.Server.invokeOp(Server.java:223)
                  at org.jboss.jmx.adaptor.html.HtmlAdaptorServlet.invokeOp(HtmlAdaptorServlet.java:262)
                  at org.jboss.jmx.adaptor.html.HtmlAdaptorServlet.processRequest(HtmlAdaptorServlet.java:100)
                  at org.jboss.jmx.adaptor.html.HtmlAdaptorServlet.doPost(HtmlAdaptorServlet.java:82)
                  at javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
                  at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
                  at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
                  at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
                  at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
                  at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
                  at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
                  at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
                  at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
                  at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:179)
                  at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
                  at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
                  at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104)
                  at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:157)
                  at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
                  at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:241)
                  at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
                  at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:580)
                  at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
                  at java.lang.Thread.run(Unknown Source)

                  • 6. Re: Dynamic class loading
                    wdfink

                    You have an ' ' space in you JBoss path, this might not a good idea, often it will bring headache.

                    Can you try without a ' ' in path?

                    • 7. Re: Dynamic class loading
                      dilipl

                      I don't like the space either, but this jboss install (4.2) comes with Adobe and Adobe creates all these directories.

                      However I don't belive ' ' is the issue. I was able to get the ear to dynamically deploy by copying the classes in the web-inf/classes folder. However they will not dynamically deploy, if these classes are "jarred" an the jar is updated in web-inf/lib.

                       

                      Does that make sense? I can conceptually understand that classes that change often (during development) should be in the classes dir, but again we are stuck with adobe.

                       

                      I just want to understand, if I am missing something or if this is how jboss work (changes to web-inf/lib won't be deployed dynamically, but web-inf/classes would). Can I make changes to web.xml to accomodate this?

                      • 8. Re: Dynamic class loading
                        weston.price

                        Try turning on more verbose logging and see 'why' the actual deployment is failing as the stack trace doesn't give much information.  As Wolf-Dieter mentioned, you will need to touch the application.xml file in your exploded deployment to get hot deploy to work.

                         

                        From the JBoss docs

                        3.4.2. Hot Deployment

                        Another JBoss feature that helps agile development is exploded archives. The EAR, EJB3 JAR and WAR files are not necessarily JAR files in the JBoss container. They can be directories containing the contents of the JAR file. For instance, instead of deploying the dvdcatalog.ear file as a single file, you can deploy it as directory.

                        With the exploded directories, you can make changes to any single JSP page or Java class file in the application while the server is running. Then you can touch the META-INF/application.xml file in the exploded directory (i.e., update the file's timestamp to current) to re-deploy the entire EAR application. This further saves significant amount of time for rapid turn-around agile developers.

                        • 9. Re: Dynamic class loading
                          dilipl

                          I always touch the application.xml file. That's how I am able to hot deploy when I save the classes in the web-inf/classes directory (instead of web-inf/lib). I did turn on verbose logging and didn't print much else. On the app side logging, it says a package (or dir) is missing in the jar. Here's what I mean

                           

                          Say the name of the jar, that I am tryong to change in web-inf/lib is a.jar. Within a.jar, I have various class packaged

                          a.jar

                            --com

                            --org

                            --alfresco

                           

                          In the error, it says

                          Offending resource: class path resource [alfresco/bootstrap-context.xml]; nested exception is org.springframework.beans.factory.BeanDefinitionStoreException: Could not resolve bean definition resource pattern [classpath*:alfresco/alfresco-*-bootstrap-context.xml]; nested exception is java.io.FileNotFoundException: JAR entry alfresco/ not found in C:\Adobe\Adobe LiveCycle ES2\jboss\server\lc_turnkey\deploy\adobe-contentservices.ear\contentservices.war\WEB-INF\lib\datasite-cms-7.0.0-SNAPSHOT.jar

                           

                          thanks

                          • 10. Re: Dynamic class loading
                            jaikiran

                            Post that entire exception stacktrace. Who is trying to lookup that file and how?