You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Максим Фастовец <fa...@gmail.com> on 2020/07/22 12:01:45 UTC

Why does Tomcat 8.0.36 compile huge JSPs fine but precompiling JSPs with jspc + javac fails with 'code too large' error? And how to fix it?

Hi!

We're working on moving an old legacy Servlet/JSP web app from WebSphere to
Tomcat to cut our expenses. I figured out that the latest version of Tomcat
where our web app runs without 'The code of method
_jspService(HttpServletRequest, HttpServletResponse) is exceeding the 65535
bytes limit' error is 8.0.36. I also needed to tune some init-params in
${TOMCAT8.0.36.HOME}/conf/web.xml for JspServlet section:

<init-param>
   <param-name>mappedfile</param-name>
   <param-value>false</param-value>
</init-param>
<init-param>
   <param-name>classdebuginfo</param-name>
   <param-value>false</param-value>
</init-param>
<init-param>
   <param-name>displaySourceFragment</param-name>
   <param-value>false</param-value>
</init-param>
<init-param>
   <param-name>dumpSmap</param-name>
   <param-value>false</param-value>
</init-param>
<init-param>
   <param-name>suppressSmap</param-name>
   <param-value>true</param-value>
</init-param>
<init-param>
   <param-name>trimSpaces</param-name>
   <param-value>true</param-value>
</init-param>

I also figured out that it is jasper.jar and jasper-el.jar which somehow
serve to precompile JSPs. So if I replace $TOMCAT9_HOME/lib/jasper.jar and
$TOMCAT9_HOME/lib/jasper-el.jar with $TOMCAT8.0.36_HOME/lib/jasper.jar and
$TOMCAT8.0.36_HOME/lib/jasper-el.jar respectively I'll get our legacy web
app running on Tomcat 9 as well without that '64k bytes limit' error.

But when I follow this suggestion to precompile JSPs using Tomcat 8.0.36
distr dir as ${tomcat.home} I am getting  'error: code too large public
void _jspService(final javax.servlet.http.HttpServletRequest request, final
javax.servlet.http.HttpServletResponse response)' error. I added all the
init-params to jasper ant task I added to JspServlet section in
${TOMCAT8.0.36.HOME}/conf/web.xml but still precompilation fails

<jasper
  validateXml="false"
  mappedFile="false"
  smapDumped="false"
  smapSuppressed="true"
  trimSpaces="true"
  classdebuginfo="false"
  uriroot="${webapp.path}"
  failOnError="false"
  webXmlFragment="${webapp.path}/WEB-INF/generated_web.xml"
  outputDir="${webapp.path}/WEB-INF/src" />

I also tried running the <jasper /> task without 'compiler' attribute and
changing 'compiler' attribute to all possible values mentioned here:
https://ant.apache.org/manual/Tasks/javac.html#compilervalues but looks
like it doesn't affect the task at all.

I tried it with ant 1.9.15 and with 1.9.7 and still got that 'code too
large' error.

Can you please tell why Tomcat 8.0.36 compiles huge JSPs fine but
precompiling JSPs with jspc + javac fails with code too large error? And
how to fix it? Thank you!

I also raised this question on StackOverflow but still haven't got any
answers: https://stackoverflow.com/q/62955156/6807541

Kind Regards,
Maks.

Re: Why does Tomcat 8.0.36 compile huge JSPs fine but precompiling JSPs with jspc + javac fails with 'code too large' error? And how to fix it?

Posted by Максим Фастовец <fa...@gmail.com>.
Thank you!

Re: Why does Tomcat 8.0.36 compile huge JSPs fine but precompiling JSPs with jspc + javac fails with 'code too large' error? And how to fix it?

Posted by Максим Фастовец <fa...@gmail.com>.
> On Wed, Jul 22, 2020 at 6:58 PM Mark Thomas <ma...@apache.org> wrote:
>> On 22/07/2020 15:49, Максим Фастовец wrote:
>> Please advise where do I get that  Eclipse Compiler for Java?
> It is ecj-*.jar in $CATALINA_HOME/lib in your Tomcat installation.

Cold you also please tell how to run it via ant? How to define such an ant
task?

Maks

Re: Why does Tomcat 8.0.36 compile huge JSPs fine but precompiling JSPs with jspc + javac fails with 'code too large' error? And how to fix it?

Posted by Mark Thomas <ma...@apache.org>.
On 22/07/2020 15:49, Максим Фастовец wrote:
>> On Wed, Jul 22, 2020 at 3:32 PM Mark Thomas <ma...@apache.org> wrote:
>>> On 22/07/2020 13:01, Максим Фастовец wrote:
>>> Can you please tell why Tomcat 8.0.36 compiles huge JSPs fine but
>>> precompiling JSPs with jspc + javac fails with code too large error? And
>>> how to fix it? Thank you!
>>
>> Possibly because Tomcat doesn't use javac to compile JSPs. At least not
>> by default. It uses the Eclipse Compiler for Java.
> 
> Thank you for your reply.
> Please advise where do I get that  Eclipse Compiler for Java? Cannot find
> it via google.

It is ecj-*.jar in $CATALINA_HOME/lib in your Tomcat installation.

Mark

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Why does Tomcat 8.0.36 compile huge JSPs fine but precompiling JSPs with jspc + javac fails with 'code too large' error? And how to fix it?

Posted by Leonardo <so...@gmail.com>.
Hi Максим, try there:
https://mvnrepository.com/artifact/org.eclipse.jdt.core.compiler/ecj

Em qua., 22 de jul. de 2020 às 12:07, Максим Фастовец <fa...@gmail.com>
escreveu:

> > On Wed, Jul 22, 2020 at 3:32 PM Mark Thomas <ma...@apache.org> wrote:
> >> On 22/07/2020 13:01, Максим Фастовец wrote:
> >> Can you please tell why Tomcat 8.0.36 compiles huge JSPs fine but
> >> precompiling JSPs with jspc + javac fails with code too large error? And
> >> how to fix it? Thank you!
> >
> > Possibly because Tomcat doesn't use javac to compile JSPs. At least not
> > by default. It uses the Eclipse Compiler for Java.
>
> Thank you for your reply.
> Please advise where do I get that  Eclipse Compiler for Java? Cannot find
> it via google.
>
> Maks
>


-- 
https://sombriks.com.br

Re: Why does Tomcat 8.0.36 compile huge JSPs fine but precompiling JSPs with jspc + javac fails with 'code too large' error? And how to fix it?

Posted by Максим Фастовец <fa...@gmail.com>.
> On Wed, Jul 22, 2020 at 3:32 PM Mark Thomas <ma...@apache.org> wrote:
>> On 22/07/2020 13:01, Максим Фастовец wrote:
>> Can you please tell why Tomcat 8.0.36 compiles huge JSPs fine but
>> precompiling JSPs with jspc + javac fails with code too large error? And
>> how to fix it? Thank you!
>
> Possibly because Tomcat doesn't use javac to compile JSPs. At least not
> by default. It uses the Eclipse Compiler for Java.

Thank you for your reply.
Please advise where do I get that  Eclipse Compiler for Java? Cannot find
it via google.

Maks

Re: Why does Tomcat 8.0.36 compile huge JSPs fine but precompiling JSPs with jspc + javac fails with 'code too large' error? And how to fix it?

Posted by Mark Thomas <ma...@apache.org>.
On 22/07/2020 13:01, Максим Фастовец wrote:
> Hi!
> 
> We're working on moving an old legacy Servlet/JSP web app from WebSphere to
> Tomcat to cut our expenses. I figured out that the latest version of Tomcat
> where our web app runs without 'The code of method
> _jspService(HttpServletRequest, HttpServletResponse) is exceeding the 65535
> bytes limit' error is 8.0.36. I also needed to tune some init-params in
> ${TOMCAT8.0.36.HOME}/conf/web.xml for JspServlet section:
> 
> <init-param>
>    <param-name>mappedfile</param-name>
>    <param-value>false</param-value>
> </init-param>
> <init-param>
>    <param-name>classdebuginfo</param-name>
>    <param-value>false</param-value>
> </init-param>
> <init-param>
>    <param-name>displaySourceFragment</param-name>
>    <param-value>false</param-value>
> </init-param>
> <init-param>
>    <param-name>dumpSmap</param-name>
>    <param-value>false</param-value>
> </init-param>
> <init-param>
>    <param-name>suppressSmap</param-name>
>    <param-value>true</param-value>
> </init-param>
> <init-param>
>    <param-name>trimSpaces</param-name>
>    <param-value>true</param-value>
> </init-param>
> 
> I also figured out that it is jasper.jar and jasper-el.jar which somehow
> serve to precompile JSPs. So if I replace $TOMCAT9_HOME/lib/jasper.jar and
> $TOMCAT9_HOME/lib/jasper-el.jar with $TOMCAT8.0.36_HOME/lib/jasper.jar and
> $TOMCAT8.0.36_HOME/lib/jasper-el.jar respectively I'll get our legacy web
> app running on Tomcat 9 as well without that '64k bytes limit' error.

Unlikely.

What you will get is a completely unsupported configuration that may
exhibit subtle bugs that you will have sole responsibility for fixing.
If you really want to go that route and you are happy that it works for
you then, fair enough, that is your choice. But if you go down that
route you are entirely on your own.

> But when I follow this suggestion to precompile JSPs using Tomcat 8.0.36
> distr dir as ${tomcat.home} I am getting  'error: code too large public
> void _jspService(final javax.servlet.http.HttpServletRequest request, final
> javax.servlet.http.HttpServletResponse response)' error. I added all the
> init-params to jasper ant task I added to JspServlet section in
> ${TOMCAT8.0.36.HOME}/conf/web.xml but still precompilation fails
> 
> <jasper
>   validateXml="false"
>   mappedFile="false"
>   smapDumped="false"
>   smapSuppressed="true"
>   trimSpaces="true"
>   classdebuginfo="false"
>   uriroot="${webapp.path}"
>   failOnError="false"
>   webXmlFragment="${webapp.path}/WEB-INF/generated_web.xml"
>   outputDir="${webapp.path}/WEB-INF/src" />
> 
> I also tried running the <jasper /> task without 'compiler' attribute and
> changing 'compiler' attribute to all possible values mentioned here:
> https://ant.apache.org/manual/Tasks/javac.html#compilervalues but looks
> like it doesn't affect the task at all.
> 
> I tried it with ant 1.9.15 and with 1.9.7 and still got that 'code too
> large' error.
> 
> Can you please tell why Tomcat 8.0.36 compiles huge JSPs fine but
> precompiling JSPs with jspc + javac fails with code too large error? And
> how to fix it? Thank you!

Possibly because Tomcat doesn't use javac to compile JSPs. At least not
by default. It uses the Eclipse Compiler for Java.

I suspect your time would be better spent refactoring the JSPs that are
currently exceeding the 64k limit and then running on a supported
configuration.

Mark

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org