Wednesday, January 26, 2011

Turned on the Jasper Validation in IntelliJ Idea and facing weird / illogical errors?

So we are in the process of migrating our web application from Resin to Tomcat. The first major problem was that Resin does not use Jasper for compiling the JSP files. So it’s obvious since we were running on Resin ,we had the “Jasper Validation On Build” option in the Idea IDE turned off.

Since Tomcat uses Jasper for its compilation we needed to turn this option on. After doing that what you think happened?? Approx 400 compile issues!!

So we fixed most of the issues and we came down to just 10 errors which were all caused because of a package that could not be resolved. Thinking this was some setting problem we dug through this for nearly 2 days and we nearly pulled our hair out .I say nearly pulled our hair out because Idea IDE was acting weird and completely illogical .We changed the name of the package and it suddenly detected the new package and all the errors disappeared .What was even worse the other packages which was on the same level were getting detected .If we had say “com.rein.test” and “com.rein.newtest” ,the latter was found . “com.rein.test” was physically present but to Idea it just could not find it. Ok let me stop and tell you how we knew it was an IntelliJ Idea issue.

We used Jasper libraries in Tomcat to do the validation and compilation via an ant script and voila it worked .Build Successful !! is what we got. I’ve added the ant script below so that you to don’t go through the same “What the hell is wrong here?” state

// Begin Ant Script

<project name=”JSP Compilation”>
<property name=”tomcathome.dir” location=” “/>
<property name=”webapps.dir” location=” “/>
<target name=”jsp_jasper_compilation”>
<taskdef resource=”org/apache/catalina/ant/catalina.tasks”>
<classpath>
<fileset file=”${ tomcathome.dir}/bin/tomcat-juli.jar”/>
<fileset file=”${ tomcathome.dir}/lib/jasper.jar”/>
<fileset file=”${ tomcathome.dir}/lib/jasper-el.jar”/>
<fileset file=”${ tomcathome.dir}/lib/el-api.jar”/>
<fileset file=”${ tomcathome.dir}/lib/jsp-api.jar”/>
<fileset file=”${ tomcathome.dir}/lib/servlet-api.jar”/>
<fileset file=”${ tomcathome.dir}/lib/catalina-ant.jar”/>
</classpath>
</taskdef>
<jasper uriroot=”${ webapps.dir }”
outputDir=”${webapps.dir }/WEB-INF/compiledJSP” failonerror=”true”/>
</target>
</project>

// End Ant Script

I am not saying don’t use IntelliJ idea to validate your Jsps. But if you ever face weird /illogical errors, don’t break your head but instead try the ant script.
Till next time…

No comments:

Post a Comment