4

由于我已将一些 Maven 依赖项设置为“提供”而不是“编译”范围,因此在启动码头时出现此错误:

  • JEE5 应用
  • 应该在 WebSphere 7 和 Jetty 7 上运行
  • 春天 3

错误:

java.lang.SecurityException: class "javax.servlet.ServletRequestListener"'s signer information does not match signer information of other classes in the same package
    at java.lang.ClassLoader.checkCerts(ClassLoader.java:806)
    at java.lang.ClassLoader.preDefineClass(ClassLoader.java:487)
    at java.lang.ClassLoader.defineClassCond(ClassLoader.java:625)
    at java.lang.ClassLoader.defineClass(ClassLoader.java:615)
    at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141)
    at java.net.URLClassLoader.defineClass(URLClassLoader.java:283)
    at java.net.URLClassLoader.access$000(URLClassLoader.java:58)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:197)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
    at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClassFromSelf(ClassRealm.java:386)
    at org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy.loadClass(SelfFirstStrategy.java:42)
    at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:244)
    at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:230)
    at org.eclipse.jetty.server.handler.ContextHandler.setEventListeners(ContextHandler.java:554)
    at org.eclipse.jetty.webapp.WebAppContext.setEventListeners(WebAppContext.java:946)
    at org.eclipse.jetty.webapp.WebAppContext.addEventListener(WebAppContext.java:972)
    at org.eclipse.jetty.webapp.TagLibConfiguration.preConfigure(TagLibConfiguration.java:492)
    at org.eclipse.jetty.webapp.WebAppContext.preConfigure(WebAppContext.java:418)
    at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:454)
    at org.mortbay.jetty.plugin.JettyWebAppContext.doStart(JettyWebAppContext.java:256)
    at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:59)
    at org.eclipse.jetty.server.handler.HandlerCollection.doStart(HandlerCollection.java:224)
    at org.eclipse.jetty.server.handler.ContextHandlerCollection.doStart(ContextHandlerCollection.java:167)
    at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:59)
    at org.eclipse.jetty.server.handler.HandlerCollection.doStart(HandlerCollection.java:224)
    at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:59)
    at org.eclipse.jetty.server.handler.HandlerWrapper.doStart(HandlerWrapper.java:90)
    at org.eclipse.jetty.server.Server.doStart(Server.java:260)
    at org.mortbay.jetty.plugin.JettyServer.doStart(JettyServer.java:65)
    at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:59)
    at org.mortbay.jetty.plugin.AbstractJettyMojo.startJetty(AbstractJettyMojo.java:511)
    at org.mortbay.jetty.plugin.AbstractJettyMojo.execute(AbstractJettyMojo.java:364)
    at org.mortbay.jetty.plugin.JettyRunMojo.execute(JettyRunMojo.java:516)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:101)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:319)
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156)
    at org.apache.maven.cli.MavenCli.execute(MavenCli.java:537)
    at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196)
    at org.apache.maven.cli.MavenCli.main(MavenCli.java:141)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352)

Maven部分是:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <packaging>war</packaging>
    <artifactId>myApp.war</artifactId>
    <!--name??-->

    <parent>
        <groupId>com.example</groupId>
        <artifactId>myApp</artifactId>
        <version>0.0.1-SNAPSHOT</version>
    </parent>

    <properties>
        <java-version>1.5</java-version>
        <org.springframework-version>3.0.5.RELEASE</org.springframework-version>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <org.aspectj-version>1.6.9</org.aspectj-version>
        <org.slf4j-version>1.6.1</org.slf4j-version>
        <cxf.version>2.5.2</cxf.version>
        <jetty.version>7.6.3.v20120416</jetty.version>
        <skipTests>true</skipTests>
        <log4j.version>1.2.15</log4j.version>
    </properties>

    <!-- … -->
             <plugin>
                 <groupId>org.mortbay.jetty</groupId>
                 <artifactId>jetty-maven-plugin</artifactId>
                 <version>${jetty.version}</version>

                 <dependencies>
                     <dependency>
                         <groupId>commons-dbcp</groupId>
                         <artifactId>commons-dbcp</artifactId>
                         <version>1.4</version>
                     </dependency>
                     <dependency>
                         <groupId>commons-logging</groupId>
                         <artifactId>commons-logging</artifactId>
                         <version>1.1</version>
                         <type>jar</type>
                     </dependency>
                 </dependencies>

                 <configuration>
                     <scanIntervalSeconds>5</scanIntervalSeconds>
                     <webAppConfig>
                         <contextPath>/</contextPath>
                     </webAppConfig>
                     <connectors>
                         <connector implementation="org.eclipse.jetty.server.bio.SocketConnector">
                             <port>8080</port>
                             <!-- this connector defaults to 1300 for some reason -->
                         </connector>
                     </connectors>
                     <!--
                     <useProvided>true</useProvided>
                     -->
                 </configuration>
             </plugin>

查不出原因。欢迎任何提示;)

4

3 回答 3

5

看起来好像您将 servlet API 作为提供的依赖项包含在内,并将其添加到 Jetty 的类路径中。这与 Jetty 自己捆绑的 servlet API 类发生冲突并导致异常。

将 servlet API 作为提供的依赖项包含在内是绝对正确的——问题出<useProvided>在插件配置中的参数中,即将 servlet API 添加到类路径中。最好将其排除在外,并且,如果您在 Jetty 中还没有具有提供范围的任何其他依赖项,则将它们添加到插件依赖项中,就像您对commons-dbcp.

另请参阅http://jira.codehaus.org/browse/JETTY-429中的评论,其中讨论了类似的潜在混淆。

于 2012-05-22T21:29:46.720 回答
3

javax.servlet我也遇到过类似的问题,因为 Eclipse Libraries/Maven Dependencies 中有 2.4 和 3.0.0 jar 版本。要在 Eclipse 打开项目的 pom.xml、依赖层次结构选项卡中修复它,按“servlet”过滤,选择(鼠标右键)不必要的 2.4(或 2.5)和“排除 Maven Artifact ...”感谢 Valery Gorbunov 的提示: )

于 2012-11-13T07:27:59.350 回答
0

我删除了

             <dependency>
                 <groupId>commons-logging</groupId>
                 <artifactId>commons-logging</artifactId>
                 <version>1.1</version>
                 <type>jar</type>
             </dependency>

在码头,现在它可以工作了......似乎另一个 Logger 实现与公共日志记录冲突?!还没有得到线索,但现在......它工作......有时maven和java不是最好的朋友,或者我太愚蠢了;)

于 2012-05-24T11:36:20.040 回答