. lang。ClassNotFoundException:javax.servlet.jsp.el.ImplicitObjectELResolver ImplicitObjects美元

时间:2022-03-19 00:01:55

after upgrading to latest version of eclipse Helios 3.6, M2E 1.0 , WTP 3.2.5 and trying to run my maven project which uses JSF 2.1.3 and Spring 3 on tomcat 7, i am getting the following exception:

在升级到最新版本的eclipse Helios 3.6、M2E 1.0、WTP 3.2.5、尝试运行我的maven项目(在tomcat 7上使用JSF 2.1.3和Spring 3)之后,我遇到了以下例外:

java.lang.ClassNotFoundException: javax.servlet.jsp.el.ImplicitObjectELResolver$ImplicitObjects$4
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1678)
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1523)
    at org.apache.catalina.startup.ContextConfig.checkHandlesTypes(ContextConfig.java:2006)
    at org.apache.catalina.startup.ContextConfig.processAnnotationsStream(ContextConfig.java:1969)
    at org.apache.catalina.startup.ContextConfig.processAnnotationsJar(ContextConfig.java:1858)
    at org.apache.catalina.startup.ContextConfig.processAnnotationsUrl(ContextConfig.java:1826)
    at org.apache.catalina.startup.ContextConfig.processAnnotations(ContextConfig.java:1812)
    at org.apache.catalina.startup.ContextConfig.webConfig(ContextConfig.java:1306)
    at org.apache.catalina.startup.ContextConfig.configureStart(ContextConfig.java:896)
    at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:322)
    at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
    at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:90)
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5103)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:148)
    at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:1033)
    at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:774)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:148)
    at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:1033)
    at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:291)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:148)
    at org.apache.catalina.core.StandardService.startInternal(StandardService.java:443)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:148)
    at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:727)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:148)
    at org.apache.catalina.startup.Catalina.start(Catalina.java:621)
    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.apache.catalina.startup.Bootstrap.start(Bootstrap.java:322)
    at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:450)

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 javax/el/ExpressionFactory used in the signature
    at com.sun.faces.config.ConfigureListener.registerELResolverAndListenerWithJsp(ConfigureListener.java:693)
    at com.sun.faces.config.ConfigureListener.contextInitialized(ConfigureListener.java:243)
    at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4723)
    at org.apache.catalina.core.StandardContext$1.call(StandardContext.java:5226)
    at org.apache.catalina.core.StandardContext$1.call(StandardContext.java:5221)
    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
    at java.util.concurrent.FutureTask.run(FutureTask.java:138)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
    at java.lang.Thread.run(Thread.java:662)
Dec 17, 2011 4:56:04 PM org.apache.catalina.core.StandardContext listenerStart
SEVERE: Exception sending context initialized event to listener instance of class com.sun.faces.config.ConfigureListener
java.lang.RuntimeException: 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 javax/el/ExpressionFactory used in the signature
    at com.sun.faces.config.ConfigureListener.contextInitialized(ConfigureListener.java:292)
    at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4723)
    at org.apache.catalina.core.StandardContext$1.call(StandardContext.java:5226)
    at org.apache.catalina.core.StandardContext$1.call(StandardContext.java:5221)
    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
    at java.util.concurrent.FutureTask.run(FutureTask.java:138)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
    at java.lang.Thread.run(Thread.java:662)
Caused by: 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 javax/el/ExpressionFactory used in the signature
    at com.sun.faces.config.ConfigureListener.registerELResolverAndListenerWithJsp(ConfigureListener.java:693)
    at com.sun.faces.config.ConfigureListener.contextInitialized(ConfigureListener.java:243)
    ... 8 more

following is my configuration for maven:

以下是我对maven的配置:

<dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>javax.servlet-api</artifactId>
        <version>3.0.1</version>
        <scope>provided</scope>
       </dependency>


        <dependency>
         <groupId>com.sun.faces</groupId>
         <artifactId>jsf-api</artifactId>
         <version>2.1.3</version>
        </dependency>

        <dependency>
         <groupId>com.sun.faces</groupId>
         <artifactId>jsf-impl</artifactId>
         <version>2.1.3</version>
        </dependency>

        <dependency>
          <groupId>jstl</groupId>
          <artifactId>jstl</artifactId>
          <version>1.2</version>
        </dependency>

am i missing a jar file, or using an incompatible version of a jar ?

我是否丢失了一个jar文件,或者使用了一个不兼容的jar版本?

please advise, thanks.

请通知,谢谢。

UPDATE: what i get so far is that i get the application to run fine by removing the following dependencies from pom file:

更新:到目前为止,我通过从pom文件中删除以下依赖项使应用程序运行良好:

<dependency>
            <groupId>javax.servlet.jsp</groupId>
            <artifactId>javax.servlet.jsp-api</artifactId>
            <version>2.2.1</version>
           <scope>provided</scope>
          </dependency>

          <dependency>
           <groupId>javax.el</groupId>
            <artifactId>javax.el-api</artifactId>
           <version>2.2.2</version>
           <scope>provided</scope>
          </dependency>

i think that they were conflicting with the jars provided by the container.

我认为他们和集装箱提供的罐子有冲突。

WHAT I NEED TO KNOW:

我需要知道的是:

1- Do i have to add the dependencies: javax.servlet.jsp-api , javax.el-api to my pom file as provided or i don't need to add them at all ?

1-我是否必须添加依赖项:javax.servlet。jsp-api javax。如果提供el-api到pom文件,或者我根本不需要添加它们?

2- If i have to add those two dependencies, then how should i add them properly in a way that they will not conflict with tomcat jars, meaning what version, and should i mark the dependency as provided or not ?

2-如果我必须添加这两个依赖项,那么我应该如何正确地添加它们,使它们不会与tomcat jar冲突,这意味着要添加哪个版本,以及是否应该按照提供的方式标记依赖项?

and the important question if i have to add them, why i have to do that, what is the importance of adding them since they are provided by the container, what i understand so far, is that i need to add the javax.servlet-api dependency and mark it as provided since i am using servlets in some classes.

重要的问题是,如果我要添加它们,为什么要添加它们,添加它们的重要性是什么,因为它们是由容器提供的,我目前所理解的是,我需要添加javax。servlet-api依赖项并按照提供的方式进行标记,因为我在某些类中使用servlet。

2 个解决方案

#1


2  

You should add these dependencies only if you require them in your code meaning that they are required to compile your code. If you don't use JSP or EL classes in your code, you can remove the dependencies. So you can test if you need the dependencies by just removing them. If your code still compiles, you don't need them. :)

只有在您的代码中需要这些依赖项时,您才应该添加这些依赖项,这意味着它们需要编译您的代码。如果在代码中不使用JSP或EL类,可以删除依赖项。因此,您可以通过删除依赖项来测试是否需要依赖项。如果代码仍然在编译,则不需要它们。:)

If you need them, you should definitely add them as provided dependencies because the classes are provided by Tomcat during runtime. Just make sure that the versions of the dependencies match the versions provided by Tomcat. Then you won't have any problems. Provided dependencies are just used to compile your code but they are not packaged into the resulting WAR file, which is OK, because Tomcat provides them.

如果您需要它们,您应该将它们添加为提供的依赖项,因为类是在运行时由Tomcat提供的。只需确保依赖项的版本与Tomcat提供的版本匹配。这样你就不会有任何问题了。所提供的依赖项仅用于编译代码,但它们没有打包到生成的WAR文件中,这没有问题,因为Tomcat提供了它们。

#2


1  

I had a similar problem: I was able to run a project in one computer, but in another one, I was obtaining the ClassNotFoundException described in the question.

我有一个类似的问题:我可以在一台计算机上运行一个项目,但在另一台计算机上,我获得了问题中描述的ClassNotFoundException。

The only difference between the 2 environments was the version of the tomcat server: 7.0.26 in the working computer and 7.0.16 in the other one. I installed the same version in both computers (7.0.26) and it solved the issue.

这两个环境之间的惟一区别是tomcat服务器的版本:在工作计算机中是7.0.26,在另一个计算机中是7.0.16。我在两台电脑上都安装了相同的版本(7.0.26),它解决了这个问题。

I hope this answer could be useful to someone.

我希望这个答案对某人有用。

#1


2  

You should add these dependencies only if you require them in your code meaning that they are required to compile your code. If you don't use JSP or EL classes in your code, you can remove the dependencies. So you can test if you need the dependencies by just removing them. If your code still compiles, you don't need them. :)

只有在您的代码中需要这些依赖项时,您才应该添加这些依赖项,这意味着它们需要编译您的代码。如果在代码中不使用JSP或EL类,可以删除依赖项。因此,您可以通过删除依赖项来测试是否需要依赖项。如果代码仍然在编译,则不需要它们。:)

If you need them, you should definitely add them as provided dependencies because the classes are provided by Tomcat during runtime. Just make sure that the versions of the dependencies match the versions provided by Tomcat. Then you won't have any problems. Provided dependencies are just used to compile your code but they are not packaged into the resulting WAR file, which is OK, because Tomcat provides them.

如果您需要它们,您应该将它们添加为提供的依赖项,因为类是在运行时由Tomcat提供的。只需确保依赖项的版本与Tomcat提供的版本匹配。这样你就不会有任何问题了。所提供的依赖项仅用于编译代码,但它们没有打包到生成的WAR文件中,这没有问题,因为Tomcat提供了它们。

#2


1  

I had a similar problem: I was able to run a project in one computer, but in another one, I was obtaining the ClassNotFoundException described in the question.

我有一个类似的问题:我可以在一台计算机上运行一个项目,但在另一台计算机上,我获得了问题中描述的ClassNotFoundException。

The only difference between the 2 environments was the version of the tomcat server: 7.0.26 in the working computer and 7.0.16 in the other one. I installed the same version in both computers (7.0.26) and it solved the issue.

这两个环境之间的惟一区别是tomcat服务器的版本:在工作计算机中是7.0.26,在另一个计算机中是7.0.16。我在两台电脑上都安装了相同的版本(7.0.26),它解决了这个问题。

I hope this answer could be useful to someone.

我希望这个答案对某人有用。