AntClassLoader cannot be added to URLClassLoader

I have an Ant task to compile jsp files using Jasper. The first step is to generate java files:

<java classname="org.apache.jasper.JspC" fork="no" failonerror="true">
    <classpath refid="my.class.path" />
    <arg value="-uriroot" />
    <arg value="${apps}" />
    <arg value="-d" />
    <arg value="${jsp}" />
    <arg value="-p" />
    <arg value="my.package.jsp" />
    <arg value="-webinc" />
    <arg value="${apps}/META-INF/gen-mappings.xml" />
    <arg value="-webapp" />
    <arg value="${apps}" />
</java>

When I run this task, I get:

BUILD FAILED
java.lang.ClassCastException: org.apache.tools.ant.AntClassLoader cannot be cast
 to java.net.URLClassLoader
        at org.apache.jasper.compiler.JspRuntimeContext.<init>(JspRuntimeContext
.java:113)
        at org.apache.jasper.JspC.initServletContext(JspC.java:1257)
        at org.apache.jasper.JspC.execute(JspC.java:1118)
        at org.apache.jasper.JspC.main(JspC.java:243)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        ...

How can I deal with this problem? Thanks!

Claudio

+3
source share
3 answers

Found a problem. For the wrong dependency chain between Ant tasks, the web application folder was empty, without JSP. The chain was fixed and the jasper task was launched with some JSPs, everything is in order. Thanks for the help. Claudio

+1
source

, JspC . Tomcat Ant , .

http://tomcat.apache.org/tomcat-6.0-doc/jasper-howto.html#Web%20Application%20Compilation

<jasper 
         validateXml="false" 
         uriroot="${webapp.path}" 
         webXmlFragment="${webapp.path}/WEB-INF/generated_web.xml" 
         outputDir="${webapp.path}/WEB-INF/src" /> 
+2

Try

fork="true"

to run a separate JVM, rather than inherit the JVM Ant.

+1
source

Source: https://habr.com/ru/post/1723117/


All Articles