Marcel Stör
Marcel Stör

Reputation: 23525

How to use Jetty Jspc Maven Plugin for Tomcat 7

I use the Jetty Jspc Maven Plugin 9.3.11 as per https://www.eclipse.org/jetty/documentation/current/jetty-jspc-maven-plugin.html. The compiled JSPs fail to run due to

java.lang.ClassNotFoundException: org.apache.jasper.runtime.JspSourceImports

JspSourceImports is an interface introduced with Tomcat 8 and hence not available on Tomcat 7. The Jetty Jspc Maven Plugin doesn't allow me to configure against which Tomcat/JSP version to compile.

I assume that implicitly comes with the specific version of the plugin. So, the question is how to use the Jetty Jspc Maven Plugin for Tomcat 7?

Upvotes: 0

Views: 2666

Answers (2)

Marcel Stör
Marcel Stör

Reputation: 23525

The solution seems to be exactly as anticipated in my comment above:

<plugin>
  <!-- https://www.eclipse.org/jetty/documentation/9.3.x/jetty-jspc-maven-plugin.html -->
  <groupId>org.eclipse.jetty</groupId>
  <artifactId>jetty-jspc-maven-plugin</artifactId>
  <version>${jetty-jspc-plugin.version}</version>
  <dependencies>
    <dependency>
      <groupId>org.apache.tomcat</groupId>
      <artifactId>tomcat-jasper</artifactId>
      <version>${tomcat.version}</version>
    </dependency>
  </dependencies>
  <executions>
    <execution>
      <id>jspc</id>
      <goals>
        <goal>jspc</goal>
      </goals>
    </execution>
  </executions>
</plugin>

${tomcat.version} is some version from the 7.x branch. There's no need to have it match the runtime version exactly, just needs to be API-compatible.

Upvotes: 0

Joakim Erdfelt
Joakim Erdfelt

Reputation: 49462

If older JSP support is what's required, could you use the older Jetty 8 jspc plugin?

Note: Jetty 8 is EOL (End of Life) now, and it used the Glassfish Jasper 2.2.2 JSP engine (which has been completely deprecated and replaced with Apache Jasper 8.5.4 in Jetty 9)

So for Jetty 8, you'll be at:

  • JSP 2.2
  • JSTL 1.2

See: org.mortbay.jetty:jetty-jspc-maven-plugin:8.1.16.v20140903

Upvotes: 1

Related Questions