Browser error on first visualize.js attempt

0

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

benu's picture
79
Joined: Dec 20 2006 - 6:20am
Last seen: 8 months 2 weeks ago

Please ignore the span tags that this forum wrapped around my HTML page code...thanks.

benu - 4 years 10 months ago
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=...'" visualize.js:63
benu - 4 years 10 months ago

6 Answers:

0
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>
<html>
<head>
</script>
<title>My Report</title>
</head>
<body>
<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>
<div id="container"></div>
</body>
</html></span>

 

bwang's picture
306
Joined: Jun 19 2012 - 12:28pm
Last seen: 2 months 3 weeks ago

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

benu - 4 years 9 months ago
3

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

swood_1's picture
197
Joined: Nov 15 2012 - 10:47am
Last seen: 1 day 19 hours ago

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

benu - 4 years 9 months ago
0

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.

http://jsfiddle.net/guzuro6h/

Attachments: 
AttachmentSize
Image icon 2014-09-25_08-54-31.png140.42 KB
garnold's picture
201
Joined: May 2 2013 - 10:58am
Last seen: 1 day 16 hours ago

Hi Gene,

Thanks very much for the corroboration and JSFiddle - working great, now. On to implementing in our Liferay app.

Thanks, and regards,

Ben

benu - 4 years 9 months ago
0

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

akthar.itzme's picture
Joined: Sep 23 2014 - 10:38pm
Last seen: 2 years 9 months ago

Can you provide a little more context, i.e. the script that you're using to call up your report? -Ben

benu - 4 years 9 months ago

script i am using is correct.
I was using localhost in the visualize.js & server urls.
i.e. http://localhost:8181/jasperserver-pro/client/visualize.js , http://localhost:8181/jasperserver-pro
Instead, now i changed the localhost with my IP. Now i am able to render the report.

akthar.itzme - 4 years 9 months ago
0

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

gowthamsenmca's picture
Joined: Oct 15 2013 - 4:52am
Last seen: 2 years 10 months ago

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

benu - 4 years 9 months ago
0

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>

jajab's picture
20
Joined: May 20 2015 - 1:45am
Last seen: 3 years 9 months ago
Feedback
randomness