Author Topic: Trouble getting Javascript example to work  (Read 6697 times)

Scott B

  • Newbie
  • *
  • Posts: 17
  • Karma: 0
    • View Profile
Trouble getting Javascript example to work
« on: March 22, 2011, 12:01:52 »
Hey, I created a test.html with the following code and dropped the rpc.js into the same diretory as frontPage.jsp in my brand-spanking newly updated 1.7.0 Queuemetrics:

<html>
<head>
<title>test.html</title>
<script src="rpc.js"></script>
</head>
<body>
<h1>QueueMetrics JavaScript XML-RPC example </h1>
<script>
var server = "/DAILY/xmlrpc.do";
function run() {
try {
var service = new rpc.ServiceProxy( server, {
asynchronous:false,
protocol: "XML-RPC",
methods: ["QM.stats", "QM.realtime", "QM.auth"]
} );
res = service.QM.stats( "q1", "robot", "robot","", "",
"2005-10-10.10:23:12", "2009-10-10.10:23:10","",
[ "KoDO.DiscCauses", "CallDistrDO.AnsDistrPerDay" ]
);
document.getElementById("RESULT").innerHTML = plotBlocks(res);
} catch(e) {
alert("Error raised: " + e);
}
}
function plotBlocks( hmBlocks ) {
s = "";
for (var i in hmBlocks) {
s += "<h2>Block: " + i + "</h2>";
s += plotBlock( hmBlocks );
}
return s;
}
function plotBlock( arBlock ) {
s = "";
for ( r =0; r < arBlock.length; r++ ) {
s += "<tr>";
for ( c = 0; c < arBlock[r].length; c++ ) {
s += "<td>" + arBlock[r][c] + "</td>";
}
s += "</tr>";
}
return "<table border=1>" + s + "</table>";
}
</script>
<input type="button" value="Click me!" onclick="run();" >
<div id="RESULT"></div>
</body>

</html>



and I get the following error once I click "Click me!"

Block: result

Status   ERR
Description   -- Inner Exception -- Exception: it.loway.tpf.common.exceptions.UserException Stack trace: The user cannot login: 'robot' at it.loway.app.queuemetrics.autenticazione.effettuaLogOn.doRun(effettuaLogOn.java:92) at it.loway.app.queuemetrics.xmlrpc.tpfServer.runClass(tpfServer.java:910) at it.loway.app.queuemetrics.xmlrpc.tpfServer.stats(tpfServer.java:168) 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:597) at redstone.xmlrpc.handlers.ReflectiveInvocationHandler.execute(Unknown Source) at redstone.xmlrpc.handlers.ReflectiveInvocationHandler.invoke(Unknown Source) at redstone.xmlrpc.XmlRpcDispatcher.dispatch(Unknown Source) at redstone.xmlrpc.XmlRpcServer.execute(Unknown Source) at it.loway.app.queuemetrics.xmlrpc.tpfServer.doRun(tpfServer.java:91) at it.loway.tpf.transaction.servlets.LowayTransactionController.runVerb(LowayTransactionController.java:262) at it.loway.tpf.transaction.servlets.LowayTransactionController.serveRequest(LowayTransactionController.java:552) at it.loway.tpf.transaction.servlets.LowayTransactionController.serveRequestWrapper(LowayTransactionController.java:373) at it.loway.tpf.transaction.servlets.LowayTransactionController.doPost(LowayTransactionController.java:224) at javax.servlet.http.HttpServlet.service(HttpServlet.java:647) at javax.servlet.http.HttpServlet.service(HttpServlet.java:729) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:269) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:172) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:108) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:174) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:873) at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:665) at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:528) at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:81) at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:689) at java.lang.Thread.run(Thread.java:619) -- End Inner Exception --
Time elapsed (ms)   19
QM Version   1.7.0.0

Scott B

  • Newbie
  • *
  • Posts: 17
  • Karma: 0
    • View Profile
Re: Trouble getting Javascript example to work
« Reply #1 on: March 22, 2011, 12:03:34 »
Any ideas? The only part of it I really don't understand is the 

var server = "/DAILY/xmlrpc.do"

and searching xmlrpc.do in the pdf manual for the xmlrpc interface is just references to it in other examples in the other languages, with differing syntax. Any ideas?

QueueMetrics

  • Loway
  • Hero Member
  • *
  • Posts: 2999
  • Karma: 39
    • View Profile
    • QueueMetrics
Re: Trouble getting Javascript example to work
« Reply #2 on: March 22, 2011, 14:54:13 »
You need to serve the example from the same container, e.g. Tomcat, that is serving QM.

You could invoke the file as:

Code: [Select]
http://myserver:8080/jstest/mypage.html
and you could have QM available as

Code: [Select]
http://myserver:8080/queuemetrics/
In this case you would set the

Code: [Select]
var server = "/queuemetrics/xmlrpc.do";

Scott B

  • Newbie
  • *
  • Posts: 17
  • Karma: 0
    • View Profile
Re: Trouble getting Javascript example to work
« Reply #3 on: March 28, 2011, 10:42:56 »
You need to serve the example from the same container, e.g. Tomcat, that is serving QM.

You could invoke the file as:

Code: [Select]
http://myserver:8080/jstest/mypage.html
and you could have QM available as

Code: [Select]
http://myserver:8080/queuemetrics/
In this case you would set the

Code: [Select]
var server = "/queuemetrics/xmlrpc.do";

Great. I made the appropriate changes to my test file and re-uploaded but I still receive the same message.

(edit: genuine use of the word great here. I really appreciate all the help you guys provide on here.)

QueueMetrics

  • Loway
  • Hero Member
  • *
  • Posts: 2999
  • Karma: 39
    • View Profile
    • QueueMetrics
Re: Trouble getting Javascript example to work
« Reply #4 on: March 28, 2011, 11:23:21 »
Question: do you have the RPC library from Google installed?
In such cases, I suggest using TCPDUMP to see what is going on....

Scott B

  • Newbie
  • *
  • Posts: 17
  • Karma: 0
    • View Profile
Re: Trouble getting Javascript example to work
« Reply #5 on: March 29, 2011, 09:04:05 »
Question: do you have the RPC library from Google installed?
In such cases, I suggest using TCPDUMP to see what is going on....


Yes, I have the RPC library installed. I wouldn't even know how to apply tcpdump to this issue; I am doing some reading and understand the premis but do not know how it would help me troubleshoot the error I'm getting.

Scott B

  • Newbie
  • *
  • Posts: 17
  • Karma: 0
    • View Profile
Re: Trouble getting Javascript example to work
« Reply #6 on: March 29, 2011, 09:21:07 »
Ahh I see I had to manually enable to robot account. Now we're getting somewhere!

Scott B

  • Newbie
  • *
  • Posts: 17
  • Karma: 0
    • View Profile
Re: Trouble getting Javascript example to work
« Reply #7 on: March 29, 2011, 09:25:27 »
Not I get this error in Firefox when trying to launch it after it hangs for 15 seconds or so:

Error raised: Error: Unable to call "QM.stats". Server responsed with error (code -1): java.lang.OutOfMemoryError: Java heap space

QueueMetrics

  • Loway
  • Hero Member
  • *
  • Posts: 2999
  • Karma: 39
    • View Profile
    • QueueMetrics
Re: Trouble getting Javascript example to work
« Reply #8 on: March 30, 2011, 16:54:11 »
Yes, this is likely because you should give QM more RAM. The XML-RPC service is a bit expensive.