java.lang.LinkageError:加载器约束冲突:解析接口方法 javax.servlet.jsp.JspApplicationContext.getExpressionFactory() 时

发布于 2024-12-14 04:40:43 字数 1195 浏览 0 评论 0原文

我在 Eclipse IDE 中使用 JSF 2.0。当我尝试实现 JSP 和 Servlet 时,出现以下错误:

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/jasper/servlet/JasperLoader) of the current class,      
     org/apache/jsp/exCrop_jsp, 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 org.apache.jsp.exCrop_jsp._jspInit(exCrop_jsp.java:31)
at org.apache.jasper.runtime.HttpJspBase.init(HttpJspBase.java:49)
at org.apache.jasper.servlet.JspServletWrapper.getServlet(JspServletWrapper.java:181)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:370)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:389)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:333)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)

这是如何引起的以及如何解决它?

I am using JSF 2.0 in Eclipse IDE. When I tried to implement JSP and Servlet, I get the following error:

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/jasper/servlet/JasperLoader) of the current class,      
     org/apache/jsp/exCrop_jsp, 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 org.apache.jsp.exCrop_jsp._jspInit(exCrop_jsp.java:31)
at org.apache.jasper.runtime.HttpJspBase.init(HttpJspBase.java:49)
at org.apache.jasper.servlet.JspServletWrapper.getServlet(JspServletWrapper.java:181)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:370)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:389)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:333)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)

How is this caused and how can I solve it?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

违心° 2024-12-21 04:40:43

你的类路径一团糟。

这个特殊的异常表明您在 web 应用程序的 /WEB-INF/lib 文件夹中随意下载了 servletcontainer make/version 的 servletcontainer 特定库,该库与您实际部署的 servletcontainer 不兼容网络应用程序到.特定的异常消息表明您的 /WEB-INF/lib 包含 jsp-api.jarj2ee.jar 和/或 javaee.jar 文件。

您应该删除它们。 servletcontainer已经随 JSP 一起提供。您永远不应该复制/移动特定于 servletcontainer 的库。它只会与目标运行时发生冲突。如果您这样做是为了解决 IDE 中的编译错误,那么您应该以不同的方式解决它。也就是说,您应该将目标 servlet 容器集成到 IDE 中,然后将其作为目标运行时与项目关联。这样,IDE 将在编译时类路径中自动使用 servletcontainer 的库。

另请参阅:

Your classpath is a mess.

This particular exception suggests that you've littered the webapp's /WEB-INF/lib folder with arbitrarily downloaded servletcontainer-specific libraries of a servletcontainer make/version which is incompatible with the servletcontainer where you're actually deploying the webapp to. The particular exception message suggests that your /WEB-INF/lib contains jsp-api.jar, j2ee.jar and/or javaee.jar files.

You should remove them. The servletcontainer already ships with JSP. You should never copy/move servletcontainer-specific libraries around. It would only clash with the target runtime. If you did this to workaround compilation errors in your IDE, then you should have solved it differently. Namely, you should integrate the target servletcontainer in your IDE and then associate it with the project as Targeted Runtime. This way the IDE will automatically use the servletcontainer's libraries in the compile time classpath.

See also:

感情废物 2024-12-21 04:40:43

将项目从 WAS6 迁移到 WAS 7 时,我遇到了同样的错误。修复方法如下:

  1. 更新 web.xml:
    • 打开 Project_name\src\main\webapp\WEB-INF\web.xml
    • 添加以下侦听器:Com.sun.faces.config.ConfigureListener
    • 构建项目并将其部署到 Websphere
  2. 更改装载机顺序:
    • 打开 Websphere 应用程序服务器控制台
    • 转至:应用>>>应用程序类型>> WebSphere 企业应用程序
    • 点击项目
    • 点击“类加载和更新检测”
    • 选择“首先使用父加载器加载类”
    • 点击“应用”
  3. 禁用 JSP 类重新加载
    • a.转到:应用>>应用程序类型>> WebSphere 企业应用程序
    • 点击项目
    • 单击 JSP 和 JSF
      选项
    • 取消选中“JSP 启用类重新加载”
    • 点击“确定”
  4. 更改 JSF 实现
    • 转至:应用>>>应用程序类型>>企业版WebSphere
      应用
    • 点击项目
    • 单击 JSP 和 JSF 选项
    • 在 JSF 实施下选择“MyFaces 1.2”
  5. 启动项目

I had the same error when migrating a project from WAS6 to WAS 7. Here is the fix:

  1. Update web.xml:
    • Open Project_name\src\main\webapp\WEB-INF\web.xml
    • Add the following listener: Com.sun.faces.config.ConfigureListener
    • Build the project and deploy it to Websphere
  2. Change loader order:
    • Open Websphere application server Console
    • Go to: Applications >> Application Types >> WebSphere enterprise applications
    • Click at the project
    • Click “Class loading and update detection”
    • Choose “Classes loaded with parent loader first”
    • Click Apply
  3. Disable JSP class reloading
    • a. Go to: Applications >> Application Types >> WebSphere enterprise applications
    • Click at the project
    • Click at JSP and JSF
      options
    • Uncheck “JSP enable class reloading”
    • Click OK
  4. Change JSF Implementation
    • Go to: Applications >> Application Types >> WebSphere enterprise
      applications
    • Click at the project
    • Click at JSP and JSF options
    • Choose “MyFaces 1.2” under JSF Implementation
  5. Start the Project
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文