GeeCON Prague 2014*
The moose likes Ant, Maven and Other Build Tools and the fly likes Problem with JspC taskdef Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Engineering » Ant, Maven and Other Build Tools
Bookmark "Problem with JspC taskdef" Watch "Problem with JspC taskdef" New topic
Author

Problem with JspC taskdef

Sudharsan Govindarajan
Ranch Hand

Joined: Jul 03, 2002
Posts: 319
I have a build script which tries to pre-compile JSPs. It compiles all the JSPs except the ones in which I have a custom tag. When it hits a JSP which has my custom tag, ant quits and says 'BUILD' failed.
I get the following error:

This is the build.xml fragment.

The {catalina.home}/common/lib folder has the servlet.jar which has the impln for the TagSupport class.
I'm frustrated by this behaviour. Any pointers or help is appreciated.
thanks
Sudharsan
Sudharsan Govindarajan
Ranch Hand

Joined: Jul 03, 2002
Posts: 319
I solved this problem. The culprit seems to be the jasper version. jasper41 is the version which is compatible with Servlet 2.3 & JSP 1.2 spec. The taskdef for some reason was ignoring the 'compiler="jasper41"' option. so, then I switched to the jspc task itself. This task accept the 'compiler="jasper41"' and I no more get that NoClassDefFoundError.
-Sudharsan
prashant patel
Ranch Hand

Joined: May 02, 2000
Posts: 69
hi,
I have been able to generate the java from jsp and compile the same with the ant jspc task. when Compiling with the jspc task i can generate class in proper package structure i have specified in the task config. But when tomcat compiles the class file are put in the same dir with the jsp file.
e.g jsps file in the following structure
jsp
| admin | admin.jsp
|ccirs | deal.jsp
java and class files get generated through the jspc task like this in the workfolder with package structure cds.jsp (specified)
jsp / jsp file structure
cds/jsp
| admin | admin_jsp.java
| admin | admin_jsp.class
| ccirs | deal_jsp.java
| ccirs | deal_jsp.class

when compiled by tomcat

jsp
|admin | admin_jsp.java
|admin | admin_jsp.class

|ccirs | deal_jsp.java
|ccirs | deal_jsp.class
how do i tell the tomcat compiler to compile the jsp java files in the cds.jsp package structure, so it can use the precompile class files from the ant task.
thanks.


prashz
Sudharsan Govindarajan
Ranch Hand

Joined: Jul 03, 2002
Posts: 319
How do you compile the generated java files? I use the ant 'javac' task. Here is my compile task

The 'destdir' attribute helps me in putting the classes in the right place.
HTH,
Sudharsan
prashant patel
Ranch Hand

Joined: May 02, 2000
Posts: 69
<target name="compilejsp" depends="init">
<jspc
srcdir="${basedir}/jsp"
destdir="${tomcat.workdir}"
compiler="jasper41"
classpathref="classpath.compilation"
verbose="9">
<include name="**/*.jsp" />
</jspc>
<javac classpathref="classpath.compilation"
srcdir="${tomcat.workdir}"
destdir="${tomcat.workdir}"
compiler="javac1.4"
listfiles="yes"
/>
</target>
Sudharsan Govindarajan
Ranch Hand

Joined: Jul 03, 2002
Posts: 319
your 'srcdir' and 'destdir' in the javac task are the same. Change the 'destdir' attribute to whereever you want the class files to be.
hth,
sudharsan
prashant patel
Ranch Hand

Joined: May 02, 2000
Posts: 69
Actually the jsp java file which get generated are according to the package structure eg. if i had given cds.jsp or default org.apache.jsp, then the files get generated in the dir org.apache.jsp.xxxjsp_java.class. but i have give the dest same as src just coz i wanted the behavior same as jasper compiler, where the jsp java files which gets compiled by jasper are in the same dir irrespective of the package structure given the jsp_java file. e.g even if the package is org.apache.jsp the class file will be in the jsp.admin dir.
A way around world be to enable jikes as the compiler in the jasper servlet init param since the external compiler will respect the package structure and put the class file in the correct dirs. what do u think.
Sudharsan Govindarajan
Ranch Hand

Joined: Jul 03, 2002
Posts: 319
I'm sorry, I don't think I got ur problem right..
 
GeeCON Prague 2014
 
subject: Problem with JspC taskdef