jasig / jspc-maven-plugin Goto Github PK
View Code? Open in Web Editor NEWUNMAINTAINED Maven plugin that compiles JSPs
Home Page: http://unmaintained.tech/
License: Apache License 2.0
UNMAINTAINED Maven plugin that compiles JSPs
Home Page: http://unmaintained.tech/
License: Apache License 2.0
I need in my project access to four jspC parameters - Caching, PoolingEnabled, GenStringAsCharArray and ClassDebugInfo. Can you add access to the parameters in newer plugin version?
Hi,
My web application have several custom taglib and the plugin fails to compile JSP files that use those taglib.
The error log looks like:
The absolute uri: {my custom taglib name shows here} cannot be resolved in either web.xml or the jar files deployed with this application
And web.xml file taglib configuration looks like:
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
version="2.5"
xmlns="http://java.sun.com/xml/ns/javaee"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<jsp-config>
<taglib>
<taglib-uri>{some uri}</taglib-uri>
<taglib-location>{tld file location e.g /WEB-INF/tld/...}</taglib-location>
</taglib>
<!-- few more <taglib></taglib> comes here -->
</jsp-config>
</web-app>
It uses tomcat6, and I uses tomcat6 compiler plugin as well.
I'm looking forward to your answer!
Thanks for the awesome plugin :)
The temporary JAR created by jspc (or the FileUtilJar) seems to embed (or return) OS specific path separators.
In Class TldLocations, line 439 there is the following condition:
if (entryName.startsWith("META-INF/") &&
In my case entryName is "META-INF\blueprint.tld"
For this, the condition will never be true, the jspc breaks with an exception. :-(
Is there a workaround/solution to solve the problem?
I'm running on Windows Vista.
Hi, I have a project with hundreds of jsp pages. Most of them can be compiled, but there are about 20 that are included in other JSP pages, and, therefore, can't be compiled.
I know, that there is sources
parameter in jspc-maven-plugin
, but it's very inconvenient to use it in my situation. Is there exclude
parameter or something like this?
<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
From the documentation, added this to the pom:
<plugin>
<groupId>org.jasig.mojo.jspc</groupId>
<artifactId>jspc-maven-plugin</artifactId>
<version>2.0.0</version>
<configuration>
<includeInProject>false</includeInProject>
</configuration>
</plugin>
Executed:
mvn jspc:compile
Got error:
[ERROR] Failed to execute goal org.jasig.mojo.jspc:jspc-maven-plugin:2.0.0:compile (default-cli) on project webapps-qbo: Execution default-cli of goal org.jasig.mojo.jspc:jspc-maven-plugin:2.0.0:compile failed: Unable to load the mojo 'compile' (or one of its required components) from the plugin 'org.jasig.mojo.jspc:jspc-maven-plugin:2.0.0': com.google.inject.ProvisionException: Unable to provision, see the following errors:
[ERROR]
[ERROR] 1) No implementation for org.codehaus.mojo.jspc.compiler.JspCompilerFactory was bound.
[ERROR] while locating org.codehaus.mojo.jspc.CompileMojo
[ERROR] at ClassRealm[plugin>org.jasig.mojo.jspc:jspc-maven-plugin:2.0.0, parent: sun.misc.Launcher$AppClassLoader@55f96302] (via modules: org.eclipse.sisu.wire.WireModule -> org.eclipse.sisu.plexus.PlexusBindingModule)
[ERROR] while locating org.apache.maven.plugin.Mojo annotated with @com.google.inject.name.Named(value=org.jasig.mojo.jspc:jspc-maven-plugin:2.0.0:compile)
What am I missing?
Trying to compile some JSP with import declaration related to classes included as Maven dependencies it returns a compilation error:
An error occurred at line: 39 in the jsp file: /jsp/search.jsp
[ERROR] DropDownManager cannot be resolved
But the DropDownManager is included as one of the dependencies in the current WAR project where I have declated the plugin.
This is a multi module Maven project where the WAR is one of the modules.
How can I add these dependencies for compiling JSP?
Could you roll out a new release to have the tomcat 8.5.x support also generally available?
It would be really helpful, if the compiler would not stop on the first JSP with compile errors, but continue until the last has been compiled---within the same maven module, of course.
If some users prefer the old way (stop on first compile error), an option like "jspc.failFast" should be introduced.
Additionally, a line showing some statistics would be really nice, like
total: 127 (JSP files) errors: 42 (JSP files)
Also see https://issues.apache.org/bugzilla/show_bug.cgi?id=53011
The jar published for tomcat compiler 7 in maven central(version 2.0.0) is missing jar/META-INF/maven/plugin.xml and build fails when I do mvn install... Maven is expecting a plugin descriptor inside the jar and its not there. Please update a new Jar
I am kind of out of ideas here. This doesnt look like an obvious issue with the plugin but I can't find anyone else sharing a similar issues. Is it possible that a downstream dependency is missing a dependency or do I need to add an additional dependency manually?
I am getting the following stack trace
Caused by: java.lang.ClassNotFoundException: org.apache.jasper.compiler.Node$CustomTag
at org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy.loadClass(SelfFirstStrategy.java:50)
at org.codehaus.plexus.classworlds.realm.ClassRealm.unsynchronizedLoadClass(ClassRealm.java:271)
at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:247)
at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:239)
when running jspc with the config
<plugin>
<groupId>org.jasig.mojo.jspc</groupId>
<artifactId>jspc-maven-plugin</artifactId>
<version>2.0.0</version>
<executions>
<execution>
<phase>compile</phase>
<goals>
<goal>compile</goal>
</goals>
</execution>
</executions>
<configuration>
<sources>
<directory>${basedir}/src/main/webapp</directory>
<includes>
<include>**/*.jsp</include>
</includes>
</sources>
</configuration>
<dependencies>
<dependency>
<groupId>org.jasig.mojo.jspc</groupId>
<artifactId>jspc-compiler-tomcat7</artifactId>
<version>2.0.2</version>
</dependency>
<dependency>
<groupId>javax.servlet.jsp</groupId>
<artifactId>jsp-api</artifactId>
<version>2.1</version>
</dependency>
</dependencies>
</plugin>```
Even if includeInproject is set to false this plugin copies classes in target/classes so firebug checks them.
If I add the additional condition of checking for includeInproject parameter when installing the generated classes into the default output directory, it does work (for me). Snippet ahead:
org.codehaus.mojo.jspc.CompilationMojoSupport.java:402
// Maybe install the generated classes into the default output directory
if (compile && isWar && includeInProject) {
Maybe there's a better way to achieve that.
The current version of tomcat-jasper in tomcat8 compiler is unable to deal with an invocation of a static function on an interface.
I tried bumping the version to 8.5.13 which is the latest but it still fails.
To enable it to work I had to bump tomcat-jasper up to 9.0.0.M19 which allowed compilation to complete successfully.
This may end up being documentation of a known issue more than something that can be fixed but I did note that none of the current compilers use 9.x so maybe planning an upgrade for sometime soon is a good idea.
It looks like at one point the jspc compiler may have accidentally supported this feature and then lost it so it may be that a lower jspc version also works since some of the older tomcat servers can render this properly.
Obviously if you are trying to match your tomcat version this isnt super helpful and the answer may be to refactor the code to not have static methods on interfaces.
I ran into this issue compiling JSPs with scriplets, where it was using a version of guava from the plugin dependency chain that was incompatible with the version in my project dependencies. It looks like the plugin dependencies are available at compile time and are in fact given preferential class loading preference.
I made a repo https://github.com/ksmith97/JSPC-issue to showcase the issue and how I fixed it for the guava case. I'm not sure if its possible to create a general solution but at the very least documenting it might help someone with a similar issue in the future.
I know scriplets are not good practice anymore but for some of us that just inherited a codebase with a large existing number of them we have to support them.
When trying to compile the JSPs in my webapp that relies on Java sourceVersion 1.8 I'm getting this error message:
[ERROR] An error occurred at line: 32 in the jsp file: /foo/bar.jsp
[ERROR] The type new Comparator<RoundVO>(){} must implement the inherited abstract method Comparator<RoundVO>.thenComparing(Function<? super RoundVO,? extends U>)
[ERROR] 29:
[ERROR] 30: <%
[ERROR] 31: List<RoundVO> sortedRounds = new ArrayList<RoundVO>((Collection<RoundVO>) pageContext.getAttribute("rounds"));
[ERROR] 32: Collections.sort(sortedRounds, new Comparator<RoundVO>() {
[ERROR] 33: public int compare(RoundVO round1, RoundVO round2) {
[...]
/foo/bar.jsp:
<%
List<RoundVO> sortedRounds = new ArrayList<RoundVO>((Collection<RoundVO>) pageContext.getAttribute("rounds"));
Collections.sort(sortedRounds, new Comparator<RoundVO>() {
public int compare(RoundVO round1, RoundVO round2) {
[...]
}
});
pageContext.setAttribute("sortedRounds", sortedRounds);
%>
This is the configuration in pom.xml:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<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>
<configuration>
<includeInProject>false</includeInProject>
<showSuccess>false</showSuccess>
<caching>false</caching>
</configuration>
<executions>
<execution>
<goals>
<goal>compile</goal>
</goals>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>org.jasig.mojo.jspc</groupId>
<artifactId>jspc-compiler-tomcat7</artifactId>
<version>2.0.2</version>
</dependency>
</dependencies>
</plugin>
When using jspc-maven-plugin with version 2.0.0 everything runs fine.
Something I found is this thread: http://stackoverflow.com/questions/28203243/not-implementing-all-the-methods-of-an-interface
Doesn't seem to be finding jsps exposed in jars via META-INF/resources
how to use in spring mvc
Using 7.0.59 gives you the following error:
Failed to execute goal org.jasig.mojo.jspc:jspc-maven-plugin:2.0.2:compile (default) on project MY_PROJECT: Execution default of goal org.jasig.mojo.jspc:jspc-maven-plugin:2.0.2:compile failed: An API incompatibility was encountered while executing org.jasig.mojo.jspc:jspc-maven-plugin:2.0.2:compile: java.lang.NoSuchFieldError: loader
If you do, then in org.codehaus.mojo.jspc.compiler.tomcat7.MultiThreadedJspC line 169 will not compile because initServletContext() is not a valid method anymore.
I believe that it's because of this commit to tomcat
https://github.com/apache/tomcat70/commit/28267fd2d338ac649b54a0e0186848ae57e44517
Current TC 7.x is 7.0.68
Aside: why do jspc-compiler-tomcat7 and jspc-compiler-tomcat7-multithreaded use different versions of tomcat?
I wonder, if it would be possible to scan for @weblistener @WebServlet @webfilter annotations in the project (and libs). Then add this definitions into web.xml and set metadata-complete="true".
It would improve application start time.
I'm having some significant memory issues when using this plugin. I have to boost my max mem settings to 2G and heap space to 512 just to compile my JSPs within the context of my maven build.
Is there a way to run this in a forked jvm to reduce the memory footprint?
Is there a reason why it consumes so much memory? Is there a way to track down why/where the memory is being used? Is there be a memory leak somewhere?
Using the jspc-compiler-tomcat8 2.0.2 causes ServletException when trying to run it on latest Tomcat version (e.g. 8.0.36). Version 2.0.2 uses Tomcat 8.0.15.
javax.servlet.ServletException: java.lang.NoSuchMethodError: org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate(Ljava/lang/String;Ljava/lang/Class;Ljavax/servlet/jsp/PageContext;Lorg/apache/jasper/runtime/ProtectedFunctionMapper;Z)Ljava/lang/Object;
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:909)
Fix: Update Tomcat version being used for for compiler.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.