简体   繁体   English

在Eclipse中执行应用程序时发生链接错误

[英]Linkage Error occured while executing the application in eclipse

I googled about the problem I have then I applied all the given solutions but unluckily I'm still getting the same error (linkage error) while I execute my application. 我用谷歌搜索这个问题,然后我应用了所有给定的解决方案,但是不幸的是,我在执行应用程序时仍然遇到相同的错误(链接错误)。 I also posted some part of pom.xml below that is related to the problem 我还在下面发布了与问题相关的pom.xml的某些部分

<dependency>
        <groupId>javax.el</groupId>
        <artifactId>el-api</artifactId>
        <version>2.2</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>javax.servlet.jsp</groupId>
        <artifactId>jsp-api</artifactId>
        <version>2.2</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>org.glassfish.web</groupId>
        <artifactId>el-impl</artifactId>
        <version>2.2</version>
        <scope>runtime</scope>
    </dependency>
    <dependency>
        <groupId>com.sun.el</groupId>
        <artifactId>el-ri</artifactId>
        <version>1.0</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>servlet-api</artifactId>
        <version>2.5</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>javax</groupId>
        <artifactId>javaee-api</artifactId>
        <version>7.0</version>
        <scope>provided</scope>
    </dependency>

Error message: 错误信息:

SEVERE: Critical error during deployment: 
java.lang.LinkageError: loader constraint violation: when resolving interface method "javax.servlet.jsp.JspApplicationContext.getExpressionFactory()Ljavax/el/ExpressionFactory;" the class loader (instance of org/apache/catalina/loader/WebappClassLoader) of the current class, com/sun/faces/config/ConfigureListener, and the class loader (instance of org/apache/catalina/loader/StandardClassLoader) for resolved class, javax/servlet/jsp/JspApplicationContext, have different Class objects for the type avax/el/ExpressionFactory; used in the signature
at com.sun.faces.config.ConfigureListener.registerELResolverAndListenerWithJsp(ConfigureListener.java:673)
at com.sun.faces.config.ConfigureListener.contextInitialized(ConfigureListener.java:230)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4600)
at org.apache.catalina.core.StandardContext$1.call(StandardContext.java:5097)
at org.apache.catalina.core.StandardContext$1.call(StandardContext.java:5092)
at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)
at java.util.concurrent.FutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)

You should get rid of the following dependency: 您应该摆脱以下依赖性:

<dependency>
    <groupId>org.glassfish.web</groupId>
    <artifactId>el-impl</artifactId>
    <version>2.2</version>
    <scope>runtime</scope>
</dependency>

It's glassfish implementation of el. 这是el的glassfish实现。

Tomcat comes with el-api.jar and jasper-el.jar (it's own implementation) in lib directory. Tomcat在lib目录中带有el-api.jarjasper-el.jar (它自己的实现)。 So you don't need that dependency whatsoever. 因此,您无需任何依赖。

Also: 也:

 <dependency>
    <groupId>com.sun.el</groupId>
    <artifactId>el-ri</artifactId>
    <version>1.0</version>
    <scope>provided</scope>
</dependency>

Is not needed too. 也不需要。 The sun reference implementation is not provided (as said, Tomcat comes with it's own implementation). 没有提供sun参考实现(如上所述,Tomcat带有它自己的实现)。

Also, JEE7 is not provided with Tomcat. 另外,Tomcat不提供JEE7。 So, having the following dependency (in provided scope) is wrong: 因此,在提供的范围内具有以下依赖关系是错误的:

 <dependency>
    <groupId>javax</groupId>
    <artifactId>javaee-api</artifactId>
    <version>7.0</version>
    <scope>provided</scope>
</dependency>

You should remove those three dependencies. 您应该删除这三个依赖项。 The first one is the cause for the exception. 第一个是导致异常的原因。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM