Domanda

I am trying to use the metrics-jetty project from Coda Hale: http://metrics.codahale.com/manual/jetty/

The thing is, I really dont know how to configure jetty to use the classes.

I added the projects into my pom.xml, but when using a jetty.xml:

<Call name="addConnector">
  <Arg>
      <New class="com.yammer.metrics.jetty.InstrumentedSelectChannelConnector">
        <Set name="host"><Property name="jetty.host" /></Set>
        <Set name="port"><Property name="jetty.port" default="9090"/></Set>
        <Set name="maxIdleTime">300000</Set>
        <Set name="Acceptors">2</Set>
        <Set name="statsOn">false</Set>
        <Set name="confidentialPort">8443</Set>
    <Set name="lowResourcesConnections">20000</Set>
    <Set name="lowResourcesMaxIdleTime">5000</Set>
      </New>
  </Arg>
</Call>

(Copied from the jetty-distribution), i am getting this error:

Caused by: java.lang.ClassNotFoundException: com.yammer.metrics.jetty.InstrumentedSelectChannelConnector

EDIT

Doing this directly in the jetty-maven-plugin has the same effect:

    <plugin>
            <groupId>org.mortbay.jetty</groupId>
            <artifactId>jetty-maven-plugin</artifactId>
            <version>${jetty.version}</version>
            <configuration>
                <scanIntervalSeconds>0</scanIntervalSeconds>
                <stopKey>foo</stopKey>
                <stopPort>9999</stopPort>
                <reload>manual</reload>
                <connectors>
                    <connector
                        implementation="org.eclipse.jetty.server.nio.SelectChannelConnector">
                        <port>8080</port>
                    </connector>
                    <connector
                        implementation="com.yammer.metrics.jetty.InstrumentedSelectChannelConnector">
                    </connector>
                </connectors>
                <webAppSourceDirectory>${basedir}/src/main/webapp</webAppSourceDirectory>
                <!-- <jettyXml>${project.basedir}/src/main/resources/jetty.xml</jettyXml> -->
            </configuration>
            <executions>
                <execution>
                    <id>start-jetty</id>
                    <phase>pre-integration-test</phase>
                    <goals>
                        <goal>run</goal>
                    </goals>
                    <configuration>
                        <scanIntervalSeconds>10</scanIntervalSeconds>
                        <daemon>true</daemon>
                    </configuration>
                </execution>
                <execution>
                    <id>stop-jetty</id>
                    <phase>post-integration-test</phase>
                    <goals>
                        <goal>stop</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>

Thanks in advance Björn

È stato utile?

Soluzione

This seems like a pretty straight forward classpath issue. Where do you have the jars containing the instrumented connector?

In the distribution you need to have it in the server classpath, either under lib/ext or as a declared option on startup. In the plugin you need the artifact declared as a dependency of the plugin itself.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top