PDA

View Full Version : Null pointer exception ConnectionAgent.send(msg)


jackhung
10-18-2004, 07:19 PM
I try to send a message to an agent in my lzx application:

myDatasource.sendAgentXML(to, xml);

this causes an NullPointerException:

java.lang.NullPointerException
at com.laszlosystems.data.HTTPDataSource.getHTTPData( HTTPDataSource.java:157)
at com.laszlosystems.connection.ConnectionAgent.send( ConnectionAgent.java:81)
at com.laszlosystems.connection.Application.sendMessa ge(Application.java:231)
at com.laszlosystems.connection.ConnectionGroup.sendM essage(ConnectionGroup.java:98)
at com.laszlosystems.servlets.responders.ResponderMES SAGE.respondImpl(ResponderMESSAGE.java:58)
at com.laszlosystems.servlets.responders.ResponderCon nection.respondImpl(ResponderConnection.java:118)
at com.laszlosystems.servlets.responders.ResponderCom pile.respondImpl(ResponderCompile.java:193)
at com.laszlosystems.servlets.responders.Responder.re spond(Responder.java:220)


Looking at the code, in ConnectionAgent.send(msg) HTTPDataSource.getHTTPData(req, res, surl, since) is called with null for both req & res :
HTTPDataSource.getHTTPData(null, null, surl, -1);
This caused the exception in getHTTPData:
String timeoutParm = req.getParameter("timeout");

jackhung
10-18-2004, 07:59 PM
I applied the following patch in HTTPDataSource.getHTTPData() and it seems to work fine now:

int timeout = mTimeout;
if (req != null) {
String timeoutParm = req.getParameter("timeout");
if (timeoutParm != null) {
timeout = Integer.parseInt(timeoutParm);
}
}

bloch
10-21-2004, 02:18 PM
thanks! until we have the source tree open... we have no formal mechanism for patches... but we'll slide this fix into the next release.

Please let us know how the agent stuff goes for you. If you have any feedback on the agent apis, that would be great.


-Eric

jackhung
10-25-2004, 09:19 PM
I have put together a tutorial on using the Laszlo Persistent Connection. The tutorial demonstrates the use of Persistent Connection to implement a server push stock quote application.

You can get the tutorial at:
http://jackhung.tripod.com/lpsagent/quoteAgent/main.html you must download and install the files into your LPS installation.

You can also try it out at: http://jackhung.homelinux.net:8080/lps/examples/quoteAgent/main.html , but my system goes offline at night (HKT)!!

I hope the tutorial could help others to understand how to implement back-end application for LPS

jsundman
10-26-2004, 08:24 AM
Hello Jack,

As the Laszlo "doc guy" I just wanted to pass along my thanks and crongratulations on your excellent tutorial.


It's wonderful to have such a motivated and talented person as part of the virtual Laszlo documentation team.

Also, I would be interested in comments from forum readers about the pros and cons of using screen captures as opposed to live examples.

Live examples have obvious benefits -- but they also take a long time to compile and load. I've been a strong proponent of live
examples, but for the purposes of this tutorial I have to admit that the screen captures worked pretty well.

Kind regards,

jrs

arina
11-01-2004, 05:06 AM
I'm getting all the time this message in Debug window:


Connected with auth param: usr=guest
Sent: <getquote user='guest' symbol='IBM'/>
message not sent: no one specified connected (range: agent)
Error sending XML: message not sent: no one specified connected

What can cause it?

pablo
11-01-2004, 10:11 AM
Hi Arina,

The message indicates that no agents that you're trying to communicate with are connected. Did you make sure the agent you're trying to contact is registered with the LPS?

pablo

arina
11-01-2004, 09:58 PM
Hello, Pablo!

The connection was established:

<connection authenticator="anonymous" group="client">
<agent url="..."/>
<method event="onconnect">
Debug.write("Connected");
</method>
</connection>

<script>
...
canvas.connection.connect();
</script>

And now, when i'm trying to send some data - i'm getting this message that no agent is connected...

Log shows that problem was in Java - exactly this row:
<getrequest_response time="<%=new Date()%>">

With an empty getquote.jsp it works perfectly.

ankitrastogi
01-15-2006, 11:07 PM
Hi,

I am able to push data from the server to my laszlo client using agentmessage LPS request type and the XML message for dataSet associated with this agent in msg parameter e.g :

msg=<stocklist><stock name="IMP" price="100"></stocklist>
But my reqirement is to push data to server without showing it on the browser URL as seen in this case ,as well push bulk amount of data for my laszlo client. In that case I feel maximum limit of no of characters in the URL (GET request 2000 characters)will be a problem.
So it boils down to is there any way of pushing the data to server via POST kind of request.

If not this is there any other way to solve this problem through normal dataset and xml way in laszlo.

Thanks,
Ankit.