Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [jetty-users] Load-time weaving of servlets?

On Wed, Jun 4, 2014 at 12:03 AM, Dimitar Georgiev <dimitar.georgiev.bg@xxxxxxxxx> wrote:
Hello Jetty experts,

I am trying to implement integration testing (testing serlets/services through apache HTTP) and code coverage using Jetty, Maven/Failsafe and JaCoCo.
Here is the minimalistic example I am trying to get running.
My coverage does not work - JaCoCo complains that the classes (specificaly Servlets) compiled by javac/maven-compiler-plugin and ones executed at runtime differ. My example only has a dependency on servlet-api and uses no frameworks.

While there are workarounds to this problem in JaCoCo, which I am going to pursue,
- Does jetty modify classes when loading them; if yes, what is the reason?

Jetty itself does not modify classes.
However, there are a plethora of 3rd party libraries that do bytecode manipulation.
 
- Is there any way to prevent this?

Thanks for your time.

Best Regards, Dimitar

You should also be aware of the temp directories that Jetty uses to manage webapps that are deployed.
It is possible that you are decorating the wrong location/classes for your coverage.

Try a server dump, it will show you what classes jetty is using. (it might not be what you assume)

To set this up with the jetty-maven-plugin

Create a jetty-dump.xml (or whatever name you want)

<?xml version="1.0"?>
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure_9_0.dtd">
<Configure id="Server" class="org.eclipse.jetty.server.Server">
  <Set name="dumpAfterStart">true</Set> 
</Configure>

Then configure the plugin to use it ...

<plugin>
  <groupId>org.eclipse.jetty</groupId>
  <artifactId>jetty-maven-plugin</artifactId>
  <configuration>
    <jettyXml>jetty-dump.xml</jettyXml>
  </configuration>
</plugin>

The STDERR / STDOUT should have a lot of extra information in it now.

--
Joakim Erdfelt <joakim@xxxxxxxxxxx>
Expert advice, services and support from from the Jetty & CometD experts



Back to the top