powered by Jive Software

JSP failure, more information

Code that does not fail in a standalone application behaves differently when embedded in a JSP page. In particular, the server does not respond. The XML stream from the client looks like:

<stream:stream to=“philipcarey.net” xmlns=“jabber:client” xmlns:stream=“http://etherx.jabber.org/streams”>

The exception generated yields:

org.jivesoftware.smack.XMPPException: Connection failed. No response from server.

I am interested in using the library from with J2SE J2EE servlets and/or beans. If anyone has a working example in that context, please post it along with changes required to make it so. Thanks…

Can you paste in the JSP page you’'re trying to use to do this?

Regards,

Matt

I’'m also having a failure:

Code:


<%@ page import=“org.jivesoftware.smack.*”%>

<%

XMPPConnection connection

= new XMPPConnection(“208.211.205.62”);

connection.login(“ColdFusion”, “maxbrite”);

GroupChat groupConnection = new GroupChat(connection, “Technology@conference.208.211.205.62”);

groupConnection.join(“ColdFusion”);

groupConnection.sendMessage(“I am Here”);

groupConnection.leave();

out.print( “Message Sent” );

%>


Error: Top two lines of my stack trace


org.jivesoftware.smack.XMPPException: No response from server.

at org.jivesoftware.smack.GroupChat.join(GroupChat.java:122)


I can also connect to my Jabber server with a regular client and join the Technology@conference.208.211.205.62 room just fine…

So, the major problem with this approach is that you’‘re creating a new connection on every single page view. You won’‘t have any way of seeing new messages this way, because the messages will likely arrive between page views. What you really need to do is create a seperate class that keeps a connection object in memory. You could use the user’'s session as a key in the map to lookup the connection for each page view. Does this make sense?

Regards,

Matt

That was my plan, but that still doesn’‘t take care of the error that I’'m getting now.

Here is my code with storing the connection in session:


<%@ page import=“org.jivesoftware.smack.*”%>

<%

if ( session == null ) {

XMPPConnection connection

= new XMPPConnection(“208.211.205.62”);

connection.login(“ColdFusion”, “maxbrite”);

session.setAttribute(“sesConnection”, connection);

}

XMPPConnection storedConnection = ( XMPPConnection ) session.getAttribute( “sesConnection” );

GroupChat groupConnection = new GroupChat(storedConnection, “Technology@conference.208.211.205.62”);

groupConnection.join(“ColdFusion”);

groupConnection.sendMessage(“I am Here”);

groupConnection.leave();

out.print( “Message Sent” );

%>


However I still can’'t get past the no responce eroor when I try to join a room…

I’'ve been working my app some more, and have found that the .join() method physically joins me to the room but throws the no responce error. I have implemented a Try Catch scenario to keep the error from coming up, but have found because .join() fails I can not use .leave()

I’'d recommend doing all of your Smack testing in a standalone application, as that will be much easier for testing. You can also turn on the Smack debugging mode, which will let you see the XML going back and forth. If you find an error in that case, let me know.

Regards,

Matt

Please see the last few messages in:

You may be running into the same issue in your JSP.

Regards,

Matt

Hoping that Beta 2 would now have a fix for my .join() problem; I installed it; now I can’'t even connect.

Error:


org.jivesoftware.smack.XMPPException: Connection failed. No response from server.

at org.jivesoftware.smack.PacketReader.startup(PacketReader.java:182)

at org.jivesoftware.smack.XMPPConnection.init(XMPPConnection.java:414)

at org.jivesoftware.smack.XMPPConnection.(XMPPConnection.java:152)

at org.jivesoftware.smack.XMPPConnection.(XMPPConnection.java:130)

I just downloaded and tested the latest and it now works as expected when embedded in jsp. Thanks!

I’'m glad the update helped.

FYI, Matt is traveling on business right now so he may have trouble responding. He should be back at the end of the week.

FYI, Matt is traveling on business right now so he

may have trouble responding. He should be back at the

end of the week.

Luckily my hotel room has high speed internet, so I’'ll be around.

-Matt

Restarted my CF Services and tested again, works great now, thanks for your hard work…