You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Liferay 6.1+Tomcat7.0环境下javax.servlet-api-3.0.1.jar无法加载问题排查

问题分析与解决方案

Hey, I’ve run into this exact issue with Liferay portlets before—let’s break down what’s causing the error and how to fix it quickly.

为什么会出现这个报错?

The error message points to a key rule from the Servlet Spec 2.3, Section 9.7.2: your web application is trying to include a jar file that contains core Servlet API classes, which are already provided by the Tomcat server bundled with Liferay.

Here’s the breakdown:

  • Liferay 6.1.1 CE GA2 uses Tomcat 7.0.27, which already includes its own copy of the Servlet API (matching Servlet 3.0 spec).
  • Your custom SiteSkills_CMS-portlet has packaged javax.servlet-api-3.0.1.jar inside its WEB-INF/lib directory. This jar contains the javax.servlet.Servlet.class—a class that Tomcat already manages.
  • To avoid class loading conflicts, Tomcat refuses to load your duplicate jar, which prevents the entire web app from starting up.

怎么解决这个问题?

There are two straightforward fixes, depending on how you build your portlet:

If you’re using a build tool like Maven or Gradle, mark the Servlet API dependency as provided. This tells the build tool not to package the jar into your portlet’s WEB-INF/lib folder, since the server (Tomcat/Liferay) will provide it at runtime.

Maven example:

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

Gradle example:

providedCompile 'javax.servlet:javax.servlet-api:3.0.1'

2. Manually remove the conflicting jar

If you’re not using a build tool, simply:

  • Locate your portlet’s WEB-INF/lib directory (in the temp folder mentioned, or your packaged WAR file)
  • Delete the javax.servlet-api-3.0.1.jar file
  • Redeploy the portlet to Liferay

After making either change, restart your Liferay server (or just redeploy the portlet) and the error should disappear.

内容的提问来源于stack exchange,提问作者rahul

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.28 09:59:22