2004 IR Help Posted August 26, 2006 Share Posted August 26, 2006 By: Brandon DuRette - brandond Errors compiling with Ant 2006-01-26 13:02 I have an Ant project set up using the Jasper Reports ant task to compile my reports. When I first set this up, I was having issues with the default compiler not being able to find classes. In fact, it's so bad that the antcompile demo doesn't even compile. I finally gave up on the default compiler and switched to the JRJavacCompiler and that issue went away. All was well until I attempted to add a variable to my report whose class is a bean class in our data model. Now, the report compiler is failing with a ClassNotFound exception. The class *is* in the classpath specified in the ant target. The snippet from my ant file: <!-- A little bit of magic just to confirm the classpath --> <pathconvert property="foobar" refid="java.main.classpath" pathsep="${line.separator}"/> <echo message="${foobar}" /> <mkdir dir="${reports.bin}" /> <jrc destdir="${reports.bin}" tempdir="${temp.dir}" keepjava="true" compiler="net.sf.jasperreports.engine.design.JRJavacCompiler" > <classpath refid="java.main.classpath" /> <src> <fileset dir="${reports.src}" > <include name="**/*.jrxml" /> </fileset> </src> </jrc> The echo line which dumps out the classpath prints the following: [echo] C:Documents and SettingsBrandonMy Documentsmcmycompanylibxmlrpc-2.0.jar [echo] C:Documents and SettingsBrandonMy Documentsmcmycompanylibjasperreportslibitext-1.3.1.jar [echo] C:Documents and SettingsBrandonMy Documentsmcmycompanylibcommons-langcommons-lang.jar [echo] C:Documents and SettingsBrandonMy Documentsmcmycompanylibjasperreportslibjfreechart-1.0.0-rc1.jar [echo] C:Documents and SettingsBrandonMy Documentsmcmycompanylibjasperreportslibpoi-2.0-final-20040126.jar [echo] C:Documents and SettingsBrandonMy Documentsmcmycompanylibjavamailmail.jar [echo] C:Documents and SettingsBrandonMy Documentsmcmycompanylibcommons-fileupload-1.0.jar [echo] C:Documents and SettingsBrandonMy Documentsmcmycompanylibcommons-codec-1.3.jar [echo] C:Documents and SettingsBrandonMy Documentsmcmycompanylibcommons-loggingcommons-logging.jar [echo] C:Documents and SettingsBrandonMy Documentsmcmycompanylibjasperreportsdistjasperreports-1.0.3.jar [echo] C:Documents and SettingsBrandonMy Documentsmcmycompanylibcommons-beanutils.jar [echo] C:Documents and SettingsBrandonMy Documentsmcmycompanylibcommons-iocommons-io.jar [echo] C:Documents and SettingsBrandonMy Documentsmcmycompanylibjafactivation.jar [echo] C:Documents and SettingsBrandonMy Documentsmcmycompanylibtomcatcommonlibservlet-api.jar [echo] C:Documents and SettingsBrandonMy Documentsmcmycompanylibtomcatcommonlibjasper-compiler.jar [echo] C:Documents and SettingsBrandonMy Documentsmcmycompanylibtomcatcommonendorsedxml-apis.jar [echo] C:Documents and SettingsBrandonMy Documentsmcmycompanylibtomcatbinjmx.jar [echo] C:Documents and SettingsBrandonMy Documentsmcmycompanylibtomcatserverlibcatalina-optional.jar [echo] C:Documents and SettingsBrandonMy DocumentsmcmycompanylibtomcatcommonendorsedxercesImpl.jar [echo] C:Documents and SettingsBrandonMy Documentsmcmycompanylibtomcatcommonlibjsp-api.jar [echo] C:Documents and SettingsBrandonMy Documentsmcmycompanylibtomcatserverlibcatalina.jar [echo] C:Documents and SettingsBrandonMy Documentsmcmycompanylibtomcatcommonlibjasper-runtime.jar [echo] C:Documents and SettingsBrandonMy Documentsmcmycompanylibtomcatserverlibtomcat-util.jar [echo] C:Documents and SettingsBrandonMy Documentsmcmycompanycommonresultsclassesmain [echo] C:Documents and SettingsBrandonMy Documentsmcmycompanydatamodelresultsclassesmain The class in question is located in the datamodel directory and I have confirmed manually that the entry in the classpath is the root of the compiled class hierarchy. The exception thrown is: C:Documents and SettingsBrandonMy Documentsmcmycompanybuild-common.xml:214: net.sf.jasperreports.engine.JRRuntimeE xception: com.mycompany.myproduct.datamodel.ModelBean at org.apache.tools.ant.ProjectHelper.addLocationToBuildException(ProjectHelper.java:539) at org.apache.tools.ant.taskdefs.MacroInstance.execute(MacroInstance.java:380) at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275) at org.apache.tools.ant.Task.perform(Task.java:364) at org.apache.tools.ant.Target.execute(Target.java:341) at org.apache.tools.ant.Target.performTasks(Target.java:369) at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1216) at org.apache.tools.ant.Project.executeTarget(Project.java:1185) at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:40) at org.apache.tools.ant.Project.executeTargets(Project.java:1068) at org.apache.tools.ant.Main.runBuild(Main.java:668) at org.apache.tools.ant.Main.startAnt(Main.java:187) at org.apache.tools.ant.launch.Launcher.run(Launcher.java:246) at org.apache.tools.ant.launch.Launcher.main(Launcher.java:67) Some other possibly relevant info: Ant version 1.6.5 Jasper version 1.0.3 Any ideas? --Brandon By: Brandon DuRette - brandond RE: Errors compiling with Ant 2006-01-27 15:38 I think I have figured out what is causing this. In order for the ant task to work, my classes have to be in the classpath given to the task definition as well as the invocation of the task. This makes it nigh impossible to factor out the definition of the jrc task to our common build file which is used to build several subprojects which each could have reports that depend on different classes. Why is it not enough just to give the compiler the classpath at invocation time ala the javac task? Thanks, BrandonPost edited by: tcloonan, at: 2006/08/26 09:29 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now