Jump to content
We've recently updated our Privacy Statement, available here ×

Error Compiling with Ant


jgaughan

Recommended Posts

My company integrates JasperReports into another Java product, and we use Ant to build our software. I recently upgraded from JasperReports 2.0.5 to 3.5.1: as well I also instructed the development team to use iReport 3.5.1, and I updated all of our JRXML files by loading and saving in iReport 3.5.1 to use the new format. Everything works great when building locally in Eclipse and running the application.

 

Our build server fails miserably. It cannot compile any reports. I looked at the system properties, classpath, etc. and tracked it down to something with Ant. I understand that this is the JasperReports forum, but I am hoping that someone has seen this issue before because I am quite puzzled.

 

When I compile reports on our build server (also locally) using Ant 1.7.1, I get the following exception chain:

 

net.sf.jasperreports.engine.JRRuntimeException: Error creating SAX parser at net.sf.jasperreports.engine.xml.JRReportSaxParserFactory.createParser(JRReportSaxParserFactory.java:113) at net.sf.jasperreports.engine.xml.JRXmlDigesterFactory.createParser(JRXmlDigesterFactory.java:1310)

......(snipped for brevity)........

Caused by: org.xml.sax.SAXNotSupportedException: Property 'http://java.sun.com/xml/jaxp/properties/schemaLanguage' must be set before setting property 'http://java.sun.com/xml/jaxp/properties/schemaSource'. at org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.setProperty(Unknown Source) at org.apache.xerces.jaxp.SAXParserImpl.setProperty(Unknown Source) at net.sf.jasperreports.engine.xml.JRReportSaxParserFactory.configureParser(JRReportSaxParserFactory.java:146) at net.sf.jasperreports.engine.xml.JRReportSaxParserFactory.createParser(JRReportSaxParserFactory.java:108) ... 38 more

 

Looking in the source code for both JasperReports and xerces, I can see exactly where xerces is throwing the exception and it appears to be valid. However, from the JasperReports source code:

 

        parser.setProperty("http://java.sun.com/xml/jaxp/properties/schemaLanguage",
            "http://www.w3.org/2001/XMLSchema");
        parser.setProperty("http://java.sun.com/xml/jaxp/properties/schemaSource",
            schemaLocations.toArray(new String[schemaLocations.size()]));
 

I cannot understand how these properties are being set in the wrong order, when according to the source code that is simply not true. They are clearly being set correctly

 

The weird thing is that when I compile using the version of Ant supplied with Eclipse 3.4.2 (Ant version 1.7.0), the problem goes away. If I use the official Ant 1.7.0 or 1.7.1, I get this error.

 

All I can think of is that there is some strange classpath or version issue going on, but tracing the class versions at the JVM level is giving bogus information. It says pretty much every class not in the JRE came from ant.jar, so my guess is Ant is using a custom classloader that is corrupting this data.

 

Has anyone seen this problem or anything like it? Does anyone have any ideas? I already looked through the documentation and googled, but pretty much every common issue is related to getting the JRC task to work in the first place. JRC is running, it successfully loads the SAX parser, but the SAX parser appears to be unhappy.

 

Code:
net.sf.jasperreports.engine.JRRuntimeException: Error creating SAX parser	at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:116)	at org.apache.tools.ant.Task.perform(Task.java:348)	at org.apache.tools.ant.Target.execute(Target.java:357)	at org.apache.tools.ant.Target.performTasks(Target.java:385)	at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1337)	at org.apache.tools.ant.helper.SingleCheckExecutor.executeTargets(SingleCheckExecutor.java:38)	at org.apache.tools.ant.Project.executeTargets(Project.java:1189)	at org.apache.tools.ant.taskdefs.Ant.execute(Ant.java:416)	at org.apache.tools.ant.taskdefs.CallTarget.execute(CallTarget.java:105)	at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:288)	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)	at java.lang.reflect.Method.invoke(Method.java:585)	at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)	at org.apache.tools.ant.Task.perform(Task.java:348)	at org.apache.tools.ant.Target.execute(Target.java:357)	at org.apache.tools.ant.Target.performTasks(Target.java:385)	at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1337)	at org.apache.tools.ant.Project.executeTarget(Project.java:1306)	at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)	at org.apache.tools.ant.Project.executeTargets(Project.java:1189)	at org.apache.tools.ant.Main.runBuild(Main.java:758)	at org.apache.tools.ant.Main.startAnt(Main.java:217)	at org.apache.tools.ant.launch.Launcher.run(Launcher.java:257)	at org.apache.tools.ant.launch.Launcher.main(Launcher.java:104)Caused by: net.sf.jasperreports.engine.JRRuntimeException: Error creating SAX parser	at net.sf.jasperreports.engine.xml.JRReportSaxParserFactory.createParser(JRReportSaxParserFactory.java:113)	at net.sf.jasperreports.engine.xml.JRXmlDigesterFactory.createParser(JRXmlDigesterFactory.java:1310)	at net.sf.jasperreports.engine.xml.JRXmlDigesterFactory.createDigester(JRXmlDigesterFactory.java:1285)	at net.sf.jasperreports.engine.xml.JRXmlLoader.load(JRXmlLoader.java:203)	at net.sf.jasperreports.engine.xml.JRXmlLoader.load(JRXmlLoader.java:168)	at net.sf.jasperreports.engine.xml.JRXmlLoader.load(JRXmlLoader.java:152)	at net.sf.jasperreports.engine.JasperCompileManager.compileReportToFile(JasperCompileManager.java:115)	at net.sf.jasperreports.ant.JRAntCompileTask.compile(JRAntCompileTask.java:413)	at net.sf.jasperreports.ant.JRAntCompileTask.execute(JRAntCompileTask.java:259)	at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:288)	at sun.reflect.GeneratedMethodAccessor14.invoke(Unknown Source)	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)	at java.lang.reflect.Method.invoke(Method.java:585)	at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)	... 25 moreCaused by: org.xml.sax.SAXNotSupportedException: Property 'http://java.sun.com/xml/jaxp/properties/schemaLanguage' must be set before setting property 'http://java.sun.com/xml/jaxp/properties/schemaSource'. 	at org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.setProperty(Unknown Source)	at org.apache.xerces.jaxp.SAXParserImpl.setProperty(Unknown Source)	at net.sf.jasperreports.engine.xml.JRReportSaxParserFactory.configureParser(JRReportSaxParserFactory.java:146)	at net.sf.jasperreports.engine.xml.JRReportSaxParserFactory.createParser(JRReportSaxParserFactory.java:108)	... 38 more--- Nested Exception ---net.sf.jasperreports.engine.JRRuntimeException: Error creating SAX parser	at net.sf.jasperreports.engine.xml.JRReportSaxParserFactory.createParser(JRReportSaxParserFactory.java:113)	at net.sf.jasperreports.engine.xml.JRXmlDigesterFactory.createParser(JRXmlDigesterFactory.java:1310)	at net.sf.jasperreports.engine.xml.JRXmlDigesterFactory.createDigester(JRXmlDigesterFactory.java:1285)	at net.sf.jasperreports.engine.xml.JRXmlLoader.load(JRXmlLoader.java:203)	at net.sf.jasperreports.engine.xml.JRXmlLoader.load(JRXmlLoader.java:168)	at net.sf.jasperreports.engine.xml.JRXmlLoader.load(JRXmlLoader.java:152)	at net.sf.jasperreports.engine.JasperCompileManager.compileReportToFile(JasperCompileManager.java:115)	at net.sf.jasperreports.ant.JRAntCompileTask.compile(JRAntCompileTask.java:413)	at net.sf.jasperreports.ant.JRAntCompileTask.execute(JRAntCompileTask.java:259)	at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:288)	at sun.reflect.GeneratedMethodAccessor14.invoke(Unknown Source)	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)	at java.lang.reflect.Method.invoke(Method.java:585)	at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)	at org.apache.tools.ant.Task.perform(Task.java:348)	at org.apache.tools.ant.Target.execute(Target.java:357)	at org.apache.tools.ant.Target.performTasks(Target.java:385)	at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1337)	at org.apache.tools.ant.helper.SingleCheckExecutor.executeTargets(SingleCheckExecutor.java:38)	at org.apache.tools.ant.Project.executeTargets(Project.java:1189)	at org.apache.tools.ant.taskdefs.Ant.execute(Ant.java:416)	at org.apache.tools.ant.taskdefs.CallTarget.execute(CallTarget.java:105)	at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:288)	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)	at java.lang.reflect.Method.invoke(Method.java:585)	at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)	at org.apache.tools.ant.Task.perform(Task.java:348)	at org.apache.tools.ant.Target.execute(Target.java:357)	at org.apache.tools.ant.Target.performTasks(Target.java:385)	at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1337)	at org.apache.tools.ant.Project.executeTarget(Project.java:1306)	at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)	at org.apache.tools.ant.Project.executeTargets(Project.java:1189)	at org.apache.tools.ant.Main.runBuild(Main.java:758)	at org.apache.tools.ant.Main.startAnt(Main.java:217)	at org.apache.tools.ant.launch.Launcher.run(Launcher.java:257)	at org.apache.tools.ant.launch.Launcher.main(Launcher.java:104)Caused by: org.xml.sax.SAXNotSupportedException: Property 'http://java.sun.com/xml/jaxp/properties/schemaLanguage' must be set before setting property 'http://java.sun.com/xml/jaxp/properties/schemaSource'. 	at org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.setProperty(Unknown Source)	at org.apache.xerces.jaxp.SAXParserImpl.setProperty(Unknown Source)	at net.sf.jasperreports.engine.xml.JRReportSaxParserFactory.configureParser(JRReportSaxParserFactory.java:146)	at net.sf.jasperreports.engine.xml.JRReportSaxParserFactory.createParser(JRReportSaxParserFactory.java:108)	... 38 more
Link to comment
Share on other sites

  • Replies 11
  • Created
  • Last Reply

Top Posters In This Topic

That worked, thank you. Reports now compile both in my workspace and on our build server and everything just works.

 

I am very impressed with the ease of upgrading from 2.0.5 to 3.5.1 given the large number of changes and fixes. The only issues I have encountered are related to our antiquated Ant scripts, so far the actual Java side of things has run flawlessly. You guys have done a good job not breaking things (can't say that much for the maintainers of Castor) as well as adding value to the new versions.

Link to comment
Share on other sites

  • 4 weeks later...

lucianc
Wrote:

This is known to happen when net.sf.jasperreports.compiler.xml.validation is set to false, directly as a property or via JRAntCompileTask's xmlvalidation attribute.

If you exclude this cause, you should check whether you have the same Xerces version in both the environments.

Regards,

Lucian

Hi,

I use iReport 3.5 in my web application to generate pdf reports and I am facing this problem. How do I set this property programatically using java?

Thanks.

Eric

Link to comment
Share on other sites

  • 11 months later...

lucianc
Wrote:

This is known to happen when net.sf.jasperreports.compiler.xml.validation is set to false, directly as a property or via JRAntCompileTask's xmlvalidation attribute.

If you exclude this cause, you should check whether you have the same Xerces version in both the environments.

Regards,

Lucian

 Hi,

Using Java 6 and JR 3.7.2, I got the very same stacktrace (with root cause : Caused by: org.xml.sax.SAXNotSupportedException: Property 'http://java.sun.com/xml/jaxp/properties/schemaLanguage' must be set before setting property 'http://java.sun.com/xml/jaxp/properties/schemaSource') when disabling validation on compilation.

With Java 5, the error doesn't show up.

What configuration can I use to be able to set "net.sf.jasperreports.compiler.xml.validation" to false and use Java 6?

 

Link to comment
Share on other sites

In fact we experienced huge memory problems when compiling .jrxml files on the fly (whether those files were subreports or not).

A quick look in the heap dump showed that some Xerces XML Grammar object was holding most of the memory, without freeing it . We tried with schema caching option on and off, but it didn't change anything.

Turning the validation on compilation off logically solved the problem, but then we got this issue when using Java 6.

We will try to avoid compilation at run time as much as possible, but if some templates are badly designed (ie containing instructions to compile subreports), then we don't want to be in front of a potential memory issue or being forced not to use Java 6!

 

Link to comment
Share on other sites

  • 2 weeks later...
  • 2 weeks later...
  • 2 weeks later...

net.sf.jasperreports.compiler.xml.validation=false does not work on Xerces parsers because it disables infoset augmentation, and things like default attribute values no longer work.

My suggestion at this point is to go back to the original problem.  Try to use the most recent Xerces version, and see if that fixes the memory problem.

Regards,

Lucian

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...