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

Browser error on first visualize.js attempt


Recommended Posts

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:

<!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>


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

Link to comment
Share on other sites

  • Replies 14
  • Created
  • Last Reply

Top Posters In This Topic

Finally, when my test page renders in Firefox, I get this in the browser debugger:


"16:09:36.761" "[EasyXDM]" "[DEBUG] -" ": easyXDM present on 'file:/LOCAL_PATH_TO_MY_TEST_HTML_FILE/POC_visualize.html" visualize.js:63

"16:09:36.766" "[easyXDM.Rpc]" "[DEBUG] -" "constructor" visualize.js:63

"16:09:36.766" "[EasyXDM.{Private}]" "[DEBUG] -" "preparing transport stack" visualize.js:63

TypeError: t is null visualize.js:63

"16:09:36.766" "[EasyXDM.{Private}]" "[DEBUG] -" "resolved url 'http://MY.SERVER.org/jasperserver-pro/xdm.html?logEnabled=true&logLevel=debug'" visualize.js:63

Link to comment
Share on other sites

The code works for me on my localhost. I am wondering if your password and username are not correct. Also, if you has a few organizations on JRS, he needs to add the organization id. 
<span style="font-size:12px;"><!DOCTYPE html>
<title>My Report</title>
auth: {
name: "jasperadmin",
        password: "jasperadmin",
        organization: "organization_1"
}, function (v) {
var report = v.report({
resource: "/public/Samples/Reports/9.CustomerDetailReport",
container: "#container"
<div id="container"></div>


Link to comment
Share on other sites

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.



Link to comment
Share on other sites

Thanks for your suggestions; unfortunately, these did not work. I'm making the assumption that if any of these parameters were actually incorrect, or missing, the API would have returned an explicit error message (or, it *should* have done, anyway!). -Ben
Link to comment
Share on other sites

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!



Link to comment
Share on other sites

  • 2 weeks later...
Hi Gowtham. While I can't explain the reasons why, I can confirm that integrating the visualize.js Javascript with our web server did solve the problem. The explanation that Sherman provided above re: iFrams and cross scripting seems to be the fundamental issue. Good luck! -Ben
Link to comment
Share on other sites

  • 7 months later...

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.1apache-tomcatwebappsjasperserver-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><scripttype="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>[/code]


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...