Hi,

We're trying to instrument a war file using Cobertura, and gather the
coverage details when deployed and used under Tomcat.

Below is a thread from the Cobertura list - I'm having problems when I run
tomcat5.exe (which we use in our product) with the instrumented jar.  In
this mode, Cobertura saves the instrumented data when the web server is
shutdown.  If I run tomcat using startup.bat, everything works great.  With
tomcat5.exe, no data is saved when tomcat shuts down.

Does anyone know what is causing this, and how I might work around it?

cheers,

David

----- Forwarded by David Hay/Lex/Lexmark on 02/19/2007 12:30 PM -----
                                                                           
             "John W. Lewis"                                               
             <[EMAIL PROTECTED]                                             
             com>                                                       To 
                                       <[EMAIL PROTECTED]>                  
             02/10/2007 10:42                                           cc 
             AM                        <[EMAIL PROTECTED] 
                                       net>                                
                                                                   Subject 
                                       RE: [Cobertura-devel] creating      
                                       instrumented war                    
                                                                           
                                                                           
                                                                           
                                                                           
                                                                           
                                                                           




This code runs during Cobertura initialization:

 private static void initialize()
 {
  // Hack for Tomcat - by saving project data right now we force loading
  // of classes involved in this process (like ObjectOutputStream)
  // so that it won't be necessary to load them on JVM shutdown
  if (System.getProperty("catalina.home") != null)
  {
   saveGlobalProjectData();

   // Force the class loader to load some classes that are
   // required by our JVM shutdown hook.
   // TODO: Use ClassLoader.loadClass("whatever"); instead
   ClassData.class.toString();
   CoverageData.class.toString();
   CoverageDataContainer.class.toString();
   FileLocker.class.toString();
   HasBeenInstrumented.class.toString();
   LineData.class.toString();
   PackageData.class.toString();
   SourceFileData.class.toString();
  }

I'm wondering if catalina.home is not set when you run as a service?

John

-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
Sent: Friday, February 09, 2007 6:14 PM
To: John W. Lewis
Cc: [EMAIL PROTECTED]
Subject: RE: [Cobertura-devel] creating instrumented war

Hi John,

I see cobertura.ser in the ...\tomcat\bin dir getting updated on startup
(timestamp changes) and log shows it found it too.  Just not on shutdown.
Delay doesn't help.

If you could look for tomcat special case I'd appreciate it.

cheers,

David




             "John W. Lewis"
             <[EMAIL PROTECTED]
             com>                                                       To
                                       <[EMAIL PROTECTED]>
             02/09/2007 05:54                                           cc
             PM                        <[EMAIL PROTECTED]
                                       net>
                                                                   Subject
                                       RE: [Cobertura-devel] creating
                                       instrumented war










It might be due to a different working directory while running as a
service.  Unless you are starting the tomcat jvm while passing in the java
property that tells where the cobertura.ser file is, the file will end up
in the working directory.  I would search the entire hard drive for a
cobertura.ser file.  If you see two, it may be that one was written by the
service.  That would be the working directory.

The other thing is that I would try putting in a delay of about a minute
before calling cobertura-report just to give the java process enough time
to exit.

The other thing is that I do remember some kind of special case code for
tomcat.  I can look for that if the other two things above do not help.

Another thing is that are you sure the instrumented war is in use when you
start it up as a service?

John

-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
Sent: Friday, February 09, 2007 3:59 PM
To: John W. Lewis
Cc: [EMAIL PROTECTED]
Subject: RE: [Cobertura-devel] creating instrumented war

Thanks!  That works - I'd overlooked it.

However, I am running into an issue with Tomcat not updating the
cobertura.ser when it shuts down.  We install it as a service, and when the
service is stopped, nothing gets updated.  Same thing if I start it from
the command line using tomcat5.exe.  However, if I copy the other files
across in the bin directory and start it using "startup.bat", it does
update cobertura.ser.

We'd like to run our acceptance tests on as close as install as possible,
so we'd like to avoid the last option if possible.  Does anyone know why
the service doesn't update the ser file?

cheers,

David
x54680



             "John W. Lewis"
             <[EMAIL PROTECTED]
             com>                                                       To
                                       <[EMAIL PROTECTED]>,
             02/09/2007 10:52          <[EMAIL PROTECTED]
             AM                        net>
                                                                        cc

                                                                   Subject
                                       RE: [Cobertura-devel] creating
                                       instrumented war










Cobertura 1.8 has support for instrumenting a war file.   Try creating the
war, then instrumenting it.

I'm not sure this has been tried with maven though.

John

-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of
[EMAIL PROTECTED]
Sent: Friday, February 09, 2007 10:43 AM
To: [EMAIL PROTECTED]
Subject: [Cobertura-devel] creating instrumented war

Hi,

I'm trying to create an instrumented war file that I can deploy and run
tests against.

I'm using maven, so I am calling the cobertura:on goal in the plugin.
However, this only instruments the non-interface classes, and so when I jar
up this directory, it doesn't contain any interfaces.

I'm trying to avoid having to copy the instrumented files over the
non-instrumented ones to get all the files I need.

Is there a way to get cobertura to include the interface classes (I
understand they're not instrumented, but I would have thought it would make
sense to take a set of java classes and produce a copy of those classes
where all the classes exist and the non-interface classes are
instrumented)?

cheers,

David


-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job
easier.
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Cobertura-devel mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/cobertura-devel



---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to