11 Replies Latest reply on Jun 9, 2003 7:56 AM by Jon Barnett

    Cache invalidation - How to?

    svaret Newbie

      Hi all,

      I am developing an ordinary web application with ordinary Java classes. In fact I am using Struts but I don't think that it matters.

      However, when I am recompiling one of my Java classes and try to test my web application, it is always the version of the class-file that was present at the time when the JBoss server was started.

      Isn't there some configuration I can change so that my classes automatically reloads at least within some seconds.

      I have tried to change the <max-bean-age>-element to zero within the <cache-policy-conf> but no success.

      Has anybody bumped into this one?

      Best regards


        • 1. Re: Cache invalidation - How to?
          Jon Barnett Master

          If you are using a JBoss distribution 3.x, and you have the deployment as a WAR directory (rather than a packed WAR file), then touch the web.xml of your web application (change the date stamp on the web.xml file). This will cause JBoss to redeploy the web application and reload the classes and libraries in the web application. When you redeploy the web application as WAR file, JBoss checks the date on the WAR file instead.

          Hope that helps.

          • 2. Re: Cache invalidation - How to?
            svaret Newbie


            I am using Win XP and I am not familiar with any touch command under DOS, but maybe there is and I'll try to find it. I am planning to install linux but not right now.

            I was thinking of some configuration parameter I could set and in that way make JBoss to always load the class file whenever requested. Something like auto-reload=true, no-cache=true, auto-invalidation=true.

            But maybe there is no such parameter.

            Best regards


            • 3. Re: Cache invalidation - How to?
              svaret Newbie

              Downloading cygwin right now. I think I can run touch from there. But I still would like it more if I could configure it in a JBoss conf-file.

              Best regards


              • 4. Re: Cache invalidation - How to?
                svaret Newbie

                Not drowning in answers here ;-)

                I downloaded cygwin.
                Started JBoss.
                Changed the source code for my Java class.
                Compiled it.
                Ran touch on my directory called logon.war.
                The directory got a new fresh timestamp.


                No reaction in the JBoss console and
                no difference visibile according to the change I made in my Java source =(

                • 5. Re: Cache invalidation - How to?
                  svaret Newbie


                  Didn't read your answer carefully enough. However I ran touch on the web.xml file as well but JBoss does not react at all. At least I don't see anything happening in the JBoss console :-(


                  • 6. Re: Cache invalidation - How to?
                    svaret Newbie

                    btw running JBoss 3.2.0 ;-)

                    • 7. Re: Cache invalidation - How to?
                      Jon Barnett Master

                      Well, you didn't actually need to run cygwin. When I said "touch", you could have just opened the web.xml file and saved it without changing anything. Or if you are using Ant, you could have used its capabilities to touch the file. All you are trying to do is update the datestamp on the file.

                      As for why your web application is not seeming to update:
                      1) Are you running the default instance of JBoss and is your web application deployed in a directory server/default/deploy/myapp.war of your JBoss distribution where myapp is your particular web application name?
                      2) Is your web.xml located in server/default/deploy/myapp.war/WEB-INF/web.xml?
                      3) Are your log levels set to at least INFO?
                      4) Information on updates should also be contained in server/default/log/server.log. Do you see any information about the update occurring in there?
                      5) Have you tried doing the same with the JBoss jmx-console web application? You can change the datestamp on server/default/deploy/jmx-consol.war/WEB-INF/web.xml.

                      Your output in server.xml should look something like this and I copy the line indicating that JBoss successfully started to mark the beginning (if your console logging is also set to INFO you will get similar output to the console):
                      2003-06-09 12:25:26,984 INFO [org.jboss.system.server.Server] JBoss (MX MicroKernel) [3.2.0 (build: CVSTag=JBoss_3_2_0 date=200304110033)] Started in 57s:102ms
                      2003-06-09 12:25:52,010 INFO [org.jboss.deployment.MainDeployer] Undeploying file:/C:/Java/jboss-3.2.0/server/default/deploy/jmx-console.war/
                      2003-06-09 12:25:52,010 INFO [org.jboss.jbossweb] Stopped WebApplicationContext[/jmx-console,file:/C:/Java/jboss-3.2.0/server/default/deploy/jmx-console.war/]
                      2003-06-09 12:25:52,010 INFO [org.jboss.jbossweb] Deregister jboss.web:Jetty=0,JBossWebApplicationContext=8,context=/jmx-console
                      2003-06-09 12:25:52,010 INFO [org.jboss.jbossweb] Deregister jboss.web:Jetty=0,JBossWebApplicationContext=8,context=/jmx-console,name=HtmlAdaptor
                      2003-06-09 12:25:52,010 INFO [org.jboss.jbossweb] Deregister jboss.web:Jetty=0,JBossWebApplicationContext=8,context=/jmx-console,name=DisplayMBeans
                      2003-06-09 12:25:52,010 INFO [org.jboss.jbossweb] Deregister jboss.web:Jetty=0,JBossWebApplicationContext=8,context=/jmx-console,name=DisplayOpResult
                      2003-06-09 12:25:52,010 INFO [org.jboss.jbossweb] Deregister jboss.web:Jetty=0,JBossWebApplicationContext=8,context=/jmx-console,name=InspectMBean
                      2003-06-09 12:25:52,010 INFO [org.jboss.jbossweb] Deregister jboss.web:Jetty=0,JBossWebApplicationContext=8,context=/jmx-console,name=jsp
                      2003-06-09 12:25:52,020 INFO [org.jboss.jbossweb] Deregister jboss.web:Jetty=0,JBossWebApplicationContext=8,context=/jmx-console,HashSessionManager=0
                      2003-06-09 12:25:52,020 INFO [org.jboss.jbossweb] Deregister jboss.web:Jetty=0,JBossWebApplicationContext=8,context=/jmx-console,name=invoker
                      2003-06-09 12:25:52,020 INFO [org.jboss.jbossweb] Deregister jboss.web:Jetty=0,JBossWebApplicationContext=8,context=/jmx-console,name=default
                      2003-06-09 12:25:52,020 INFO [org.jboss.jbossweb] Successfully undeployed file:/C:/Java/jboss-3.2.0/server/default/deploy/jmx-console.war/
                      2003-06-09 12:25:52,020 WARN [org.jboss.deployment.DeploymentInfo] Not deleting localUrl, it is null or not a copy: file:/C:/Java/jboss-3.2.0/server/default/deploy/jmx-console.war/
                      2003-06-09 12:25:52,020 INFO [org.jboss.deployment.MainDeployer] Undeployed file:/C:/Java/jboss-3.2.0/server/default/deploy/jmx-console.war/
                      2003-06-09 12:25:52,020 INFO [org.jboss.deployment.MainDeployer] Starting deployment of package: file:/C:/Java/jboss-3.2.0/server/default/deploy/jmx-console.war/
                      2003-06-09 12:25:52,181 INFO [org.jboss.jbossweb] Registered jboss.web:Jetty=0,JBossWebApplicationContext=13,context=/jmx-console
                      2003-06-09 12:25:53,342 INFO [org.jboss.jbossweb] Started WebApplicationContext[/jmx-console,file:/C:/Java/jboss-3.2.0/server/default/deploy/jmx-console.war/]
                      2003-06-09 12:25:53,362 INFO [org.jboss.jbossweb] Registered jboss.web:Jetty=0,JBossWebApplicationContext=13,context=/jmx-console,name=DisplayMBeans
                      2003-06-09 12:25:53,362 INFO [org.jboss.jbossweb] Registered jboss.web:Jetty=0,JBossWebApplicationContext=13,context=/jmx-console,name=DisplayOpResult
                      2003-06-09 12:25:53,372 INFO [org.jboss.jbossweb] Registered jboss.web:Jetty=0,JBossWebApplicationContext=13,context=/jmx-console,name=InspectMBean
                      2003-06-09 12:25:53,382 INFO [org.jboss.jbossweb] Registered jboss.web:Jetty=0,JBossWebApplicationContext=13,context=/jmx-console,name=jsp
                      2003-06-09 12:25:53,392 INFO [org.jboss.jbossweb] Registered jboss.web:Jetty=0,JBossWebApplicationContext=13,context=/jmx-console,name=HtmlAdaptor
                      2003-06-09 12:25:53,392 INFO [org.jboss.jbossweb] Registered jboss.web:Jetty=0,JBossWebApplicationContext=13,context=/jmx-console,name=default
                      2003-06-09 12:25:53,402 INFO [org.jboss.jbossweb] Registered jboss.web:Jetty=0,JBossWebApplicationContext=13,context=/jmx-console,name=invoker
                      2003-06-09 12:25:53,412 INFO [org.jboss.jbossweb] Registered jboss.web:Jetty=0,JBossWebApplicationContext=13,context=/jmx-console,HashSessionManager=0
                      2003-06-09 12:25:53,412 INFO [org.jboss.jbossweb] successfully deployed file:/C:/Java/jboss-3.2.0/server/default/deploy/jmx-console.war/ to /jmx-console
                      2003-06-09 12:25:53,423 INFO [org.jboss.deployment.MainDeployer] Deployed package: file:/C:/Java/jboss-3.2.0/server/default/deploy/jmx-console.war/

                      • 8. Re: Cache invalidation - How to?
                        svaret Newbie

                        Ok yes, that's also a way of "touch"-ing the file, that's right.


                        1) Yes, I am running the default instance of JBoss but No, I am not deploying to server/default/deploy/myapp.war.
                        However, I have modified the jboss-service.xml file so that I can deploy my webapps in a "clean" directory where no JBoss specific files or directories exist.


                        This works when I copy a war archive file there. It deploys nicely. But, changing the timestamp of the web.xml file does not trigger anything.
                        Changing the timestamp of a web.xml file located in the server/default/deploy directory does however trigger a re-deploying of the application. Seem to be some difference of the location of the web-app although correctly configured in the jboss-service.xml file.

                        2) Yep, the web.xml file is located in that directory. It's the structure of a web application which I follow.

                        3) I get log info in the JBoss console window where a lot of lines starting with [INFO] and I get output there when things are deploying ( or for that reason some error occur). I haven't changed the log level after installing JBoss. I don't think this is a problem.

                        4) No, nothing special ocurring in that file that I don't see in the console window.

                        5) Yep, see answer to question 1)

                        Where can I find documentation (free?) on JBoss config-files? Is there really no config file where I can state that all class files should always be reloaded?


                        • 9. Re: Cache invalidation - How to?
                          Jon Barnett Master

                          Most likely your problem is that you are not telling JBoss to check all directories under your additional deploy directory. You need to tell it to scan further down the directory tree. Add a trailing slash.


                          • 10. Re: Cache invalidation - How to?
                            svaret Newbie


                            Super. You spotted my problem there. After adding the slash it works down the directory tree and detects the new timestamp on the web.xml.

                            Yes, I am using ant so I will surely use the touch its touch-funcionality.

                            As I have understood it when reloading a single class you have to reload all classes that this class depends on so that no anomalies occurs in not loading other classes that the class of interest depends on.

                            1) But, do you know of any documentation explaining how to use the config-files of JBoss (do I have to buy a book? ).
                            2) Is there some config parameter that can make JBoss container auto-reload newly compiled class-files?

                            I am very grateful for your help and assistance. Thanks a lot jonlee. Highly appreciated.

                            Best regards


                            • 11. Re: Cache invalidation - How to?
                              Jon Barnett Master

                              You can buy the documentation from this website. Go to the downloads area and there will be a documentation ad on the right side. The new 3.2.x documentation is available.

                              The container does not scan exploded archives (unpacked ones). The scan uses a low resource scan looking only for changes in the deployment files (the .xml). However, for packed archives deployed at the top directory, it will redeploy every time it detects a time stamp change on WAR, EAR, SAR or JAR archives.

                              Most of the configuration files are well documented internally, and you acquire knowledge as you need it. Since the source is available and is also well documented, you can always track down things. The thing is to not have to know everything at once.

                              The rest is available through the forum or the mailing-list.

                              Hope that helps.