【发布时间】:2013-08-01 13:24:13
【问题描述】:
我正在使用 Jetty 9.0.4v20130625 使用 maven-jetty-plugin 运行它。我已经实现了自己的LoginService 类来处理登录到领域的用户。在其中一行中,我尝试使用 org.eclipse.jetty.util.security.Credential 类,但在执行期间它会在该行抛出 NoClassDefFoundError。
我的target 目录包含部署到 Jetty 实例的所有内容。其中WEB-INF/lib 文件夹不包含预期的jetty-util-9.0.4.v20130625.jar,因为插件应该已经拥有它,所以我相信排除了冲突的jar。那么是什么原因导致 jetty 实例找不到这个 jar 呢?
我正在使用 eclipse,它在代码中没有显示错误。我将它设置为 Maven 项目,Maven 处理依赖项。我将其设置为不打包码头罐子,因为它们应该在部署时由码头提供。这是我的 pom.xml:
<project ...>
...
<packaging>war</packaging>
...
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-webapp</artifactId>
<version>9.0.4.v20130625</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.mongodb</groupId>
<artifactId>mongo-java-driver</artifactId>
<version>2.11.2</version>
</dependency>
</dependencies>
<build>
<finalName>...</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
<plugin>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>9.0.4.v20130625</version>
<configuration>
<scanIntervalSeconds>10</scanIntervalSeconds>
<webApp>
<contextPath>/...</contextPath>
</webApp>
<login-config>
<auth-method>FORM</auth-method>
<realm-name>Test Realm</realm-name>
<form-login-config>
<form-login-page>/loginAuth.html?param=redirect</form-login-page>
<form-error-page>/loginAuth.html?param=failed</form-error-page>
</form-login-config>
</login-config>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-scm-plugin</artifactId>
<version>1.8.1</version>
<configuration>
<connectionType>developerConnection</connectionType>
</configuration>
</plugin>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.7</version>
<executions>
<execution>
<phase>install</phase>
<configuration>
<tasks>
<ant target="deploy" />
</tasks>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>com.jcraft</groupId>
<artifactId>jsch</artifactId>
<version>0.1.50</version>
</dependency>
<dependency>
<groupId>org.apache.ant</groupId>
<artifactId>ant-jsch</artifactId>
<version>1.9.2</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
</project>
我检查以确保插件依赖于 jetty-util.jar 并且它确实如 here 所见
可能是问题的一部分:为了实现一个新的 LoginService 接口类,我正在扩展已经实现 LoginService 的 MappedLoginService 类(它在 Jetty jars 中)并且我覆盖了一些它的方法。这会导致问题吗?
【问题讨论】:
标签: jetty maven-3 noclassdeffounderror maven-jetty-plugin