We've just launched a copy of JRS via the AWS offering (ami-0e0fff66), and the basic operations work fine, i.e. report execute from the UI with no problems. However, when we try to render them using visualize.js, we get nothing except a cryptic error from the browser debugger:
Uncaught TypeError: Cannot read property '2' of null
There's a little more error context, which I will include if anyone responds to this post.
The web page & script look like this:
<span style="font-size:12px;"><!DOCTYPE html> <html> <head> <script src="http://my.server.org/jasperserver-pro/client/visualize.js?logLevel=debug"> </script> <title>My Report</title> </head> <body> <script>visualize({ auth: { name: "reporting", password: "somepassword" } }, function (v) { var report = v.report({ resource: "/public/Samples/Reports/9.CustomerDetailReport", container: "#container" }); }); </script> <div id="container"></div> </body> </html></span>
Pretty straightforward. We get nothing in the catalina.out nor jasperserver.log logs. We really don't have a clue why there's no response from the server. We do get the visualize.js page returned if we call it in the browser directly, i.e. http://my.server.org/jasperserver-pro/client/visualize.js, so I know it's accessible. And, as I mentioned, the reports run fine from the web UI.
Would someone point us in the right direction, please - even if just to tell us how to gather more information about the problem?
Thanks, Ben
6 Answers:

The problem seems to be in the 2 basic iFrames that are used in visualize.js to deal with cross scripting issues.
How are you running the HTML page that has the visualize.js calls? Because of the iFrames, your page has to run in a web server and cannot be on your local file system.
Sherman
Sherman - astute observation: yes, this simple HTML page was just on my file system and I was opening it locally in my browser. Executing it in JSFiddle worked great. There must have been another issue integrating visualize.js into our Java web app, so we'll dig back into that - knowing that a proper test can't be done via the local file system.
Thanks very much for your suggestion!
-Ben
I would agree with the top two suggestions. I'm running your exact code against a 5.6.1 system and it works perfect. Here is a link to a fiddle that does work. You can change the visualize location to test against your system if you wish.
Attachment | Size |
---|---|
![]() | 140.42 KB |
ya, I also faced same issue & now tried it by running in a web server page. But instead of Uncaught TypeError: Cannot read property '2' of null
error. I am getting new error Uncaught TypeError: Cannot read property 'Fn' of undefined in xdm.remote.js
Can some one help me out???
I too faced same issue. When I used localhost, if I place the files in the server, then only it worked.
But its working well when using JSFiddle. Why its not working in a different machine fi we create a nromal html file?
Any info please?
Thanks
Gowtham
You may use the blank.htm file that comes out of the box with JapserServer. It will run on Tomcat. You may find it here : jasperreports-server-6.0.1\apache-tomcat\webapps\jasperserver-pro (windows).
Here is my code :
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <meta http-equiv="content-type" content="text/html; charset=windows-1250"> <meta name="generator" content="PSPad editor, www.pspad.com"> <title></title> </head> <body> <script type="text/javascript" src="http://localhost:8080/jasperserver-pro/client/visualize.js?_opt=false&logLevel=debug"></script> <!-- Provide the URL to visualize.js --> Jade <div id="container"></div> <!-- Provide a container for the report --> <script > visualize({ auth: { name: "jasperadmin", password: "jasperadmin", organization: "organization_1" } }, function (v) { var report = v.report({ resource: "/public/Samples/Reports/9.CustomerDetailReport", container: "#container" }); }); </script> </body> </html>
Please ignore the span tags that this forum wrapped around my HTML page code...thanks.