Jasig / jspc-maven-plugin

UNMAINTAINED Maven plugin that compiles JSPs
http://unmaintained.tech/
Apache License 2.0
24 stars 38 forks source link

Not compatible with guava 21 #49

Open jdkcn opened 7 years ago

jdkcn commented 7 years ago
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.homolo.demo</groupId>
    <artifactId>demo-webapp</artifactId>
    <packaging>war</packaging>
    <version>0.0.1-SNAPSHOT</version>
    <name>demo-webapp Maven Webapp</name>
    <url>http://maven.apache.org</url>
    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <m2eclipse.wtp.contextRoot>demo</m2eclipse.wtp.contextRoot>
    </properties>
    <dependencies>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.8.2</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>javax.servlet-api</artifactId>
            <version>3.0.1</version>
        </dependency>
        <dependency>
            <groupId>javax.servlet.jsp</groupId>
            <artifactId>javax.servlet.jsp-api</artifactId>
            <version>2.3.0</version>
        </dependency>
        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-lang3</artifactId>
            <version>3.4</version>
        </dependency>
        <dependency>
            <groupId>com.google.guava</groupId>
            <artifactId>guava</artifactId>
            <version>21.0</version>
            <type>jar</type>
            <scope>compile</scope>
        </dependency>
    </dependencies>
    <build>
        <finalName>demo-webapp</finalName>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.5.1</version>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.jasig.mojo.jspc</groupId>
                <artifactId>jspc-maven-plugin</artifactId>
                <version>2.0.2</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>compile</goal>
                        </goals>
                        <phase>package</phase>
                    </execution>
                </executions>
                <!-- Use the Tomcat 8 JSP compiler -->
                <dependencies>
                    <dependency>
                        <groupId>org.jasig.mojo.jspc</groupId>
                        <artifactId>jspc-compiler-tomcat8</artifactId>
                        <version>2.0.2</version>
                    </dependency>
                </dependencies>
            </plugin>
        </plugins>
    </build>
</project>

The jsp

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%><%
            String str =  com.google.common.base.CharMatcher.javaIsoControl().removeFrom("Hello");
    %><html>
<body>
<h2>Hello World!</h2>
</body>
</html>
Caused by: org.apache.jasper.JasperException: Unable to compile class for JSP: 

An error occurred at line: 3 in the jsp file: /index.jsp
The method javaIsoControl() is undefined for the type CharMatcher
1: <%@ page language="java" contentType="text/html; charset=UTF-8"
2:     pageEncoding="UTF-8"%><%
3:          String str =  com.google.common.base.CharMatcher.javaIsoControl().removeFrom("Hello");
4:     %><html>
5: <body>
6: <h2>Hello World!</h2>

Stacktrace:
    at org.apache.jasper.JspC.execute(JspC.java:1393)
    at org.codehaus.mojo.jspc.compiler.tomcat7.JspCompilerImpl.compile(JspCompilerImpl.java:130)
    at org.codehaus.mojo.jspc.CompilationMojoSupport.execute(CompilationMojoSupport.java:384)
    ... 23 more
Caused by: org.apache.jasper.JasperException: Unable to compile class for JSP: 

An error occurred at line: 3 in the jsp file: /index.jsp
The method javaIsoControl() is undefined for the type CharMatcher
1: <%@ page language="java" contentType="text/html; charset=UTF-8"
2:     pageEncoding="UTF-8"%><%
3:          String str =  com.google.common.base.CharMatcher.javaIsoControl().removeFrom("Hello");
4:     %><html>
5: <body>
6: <h2>Hello World!</h2>

Stacktrace:
    at org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:103)
    at org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:199)
    at org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:450)
    at org.apache.jasper.compiler.Compiler.compile(Compiler.java:361)
    at org.apache.jasper.JspC.processFile(JspC.java:1221)
    at org.apache.jasper.JspC.execute(JspC.java:1372)
    ... 25 more
ChristianMurphy commented 7 years ago

Hey there! :wave:

Thanks for opening an issue with jspc-maven-plugin. :+1: :bowing_man: At the moment, the jspc maven plugin does not have an active maintainer to process your request. :no_entry: While the Jasig jspc maven plugin is without an active maintainer, we recommend the Apache Sling jspc maven plugin and the Jetty jspc maven plugin as alternatives that are actively maintained. :white_check_mark: If you are interested in becoming a project maintainer, there is a uPortal-dev list post where you can register your interest. :email:

Thanks again for contributing to the jspc-maven-plugin! :sparkles:

ksmith97 commented 7 years ago

I also ran into this issue and reported it but was never able to figure out exactly why its an issue. For some reason the jspc plugin dependencies end up on the compilation path of the jsps. This results in an older version of guava being loaded. I fixed it by explicitly excluding the older version of guava.

<dependency>
    <groupId>org.apache.maven</groupId>
    <artifactId>maven-plugin-api</artifactId>
    <version>3.0.5</version>
    <exclusions>
        <!-- This resolves an issue where a plugin dependency is inappropriatly placed on the
            JSPC compilation path and conflicts with our version of guava -->
        <exclusion>
            <artifactId>sisu-guice</artifactId>
            <groupId>org.sonatype.sisu</groupId>
        </exclusion>
    </exclusions>
</dependency>
jdkcn commented 7 years ago

@ChristianMurphy Thanks, I change to Jetty jspc maven plugin and worked again.