Showing posts with label Tomcat. Show all posts
Showing posts with label Tomcat. Show all posts

Monday, June 4, 2007

Why need Tomcat to run js2gtalk?

Here's a reply from one of the author of J2S, in their google groups:
Zhou Renjian
From: "Zhou Renjian"
Date: Sat, 2 Jun 2007 11:16:21 +0800
Local: Sat, Jun 2 2007 11:16 am

Subject: Re: J2S Gtalk demo : Why do we need to deploy it on Servlet Container (ie. Tomcat)

Here is how the current Java2Script GTalk works: Java2Script GTalk
(browser side) packs some message into HTTP request, send to Apache
server. And Apache server redirects requests to Tomcat server (Java
Servlet container). Then Java Servlet setups and keeps a XMPP
connection to Google Talk Jabber server using Smack library, and then
sends out request, and responses Jabber server's response, which will
redirected to Apache server. And Apache server then returns responses
through HTTP connection to browser. Java2Script GTalk finally updates
its messages or status.

The reason why there is a Tomcat server is that Apache server is not
designed to execute Java codes while Tomcat is. And in fact, you can
build up Java2Script GTalk without Apache server. Tomcat is already
an HTTP server. And the connection will be simplified to:
Java2Script GTalk <--HTTP--> Tomcat <--XMPP (Jabber) [Smack] --> GTalk Server

BTW: you can run Java2Script GTalk standalone as SWT desktop
application with a Java VM environment.


See the communication path :D

Friday, June 1, 2007

More info on XIFF and j2sgtalk

Xiff+Flash to Gtalk
- Still none existed (none found even in their developers forum)
- they always persistence in their own MUC client - http://xiffian.sourceforge.net/test/
- There are some cross-domain issues that didn't allow flash clients to connect to other jabber server
- Flash-based apps has advantage both in easy-deployment, as well as rich graphical, vector-based content, proven when the Gtalkr guys are being hired by google. But I didn't found any statement that google will have them use XIFF (Correct me if I'm wrong). There's a possibility that they'll use internal google own library (will continue researching on this)


Why need Tomcat to run js2gtalk?
- It uses Java Backends (Smack) to connect to GTalk server. Only Tomcat can execute those Java codes.
- Tomcat uses the Jasper converter to turn JSPs into servlets for execution.
- "It's wise to keep Java code out of your JSPs as much as possible, and put it in either Java taglibs, or in Java beans of EJBs. Your servlet should act primarily as a "traffic copy", receiving requests from the user and directing those requests to the appropriate methods defined in Java beans or EJBs, and then forwarding the response to the appropriate JSP to render the proper view. This design pattern is called "Model-View-Controller" and was made famous in the book "Design Patterns". I strongly recommend this book to anyone serious about moving beyond "hacking code" and doing serious program architecture and design." - http://forum.java.sun.com/thread.jspa?threadID=531586&messageID=2561649

- Possibility: Chat app need open socket connection for message transfer to work. For non-web-based app (JAVA+Smack), the OS handles this. but for web-based app (AJAX), the server is the one responsible for this. In our case, Tomcat uses servlets that has been "deployed" as part of it engine, to open connection to gtalk server. This relates to how Punjab works, by "deploying" itself using the python engine.


Next, I'll be focusing my reseach on xmpp4moz and creating Firefox add-ons.

Comments are appreciated :D

Java2Script Google Talk: Deploying-Customizing

Here are my findings for today:

get J2S from eclipse update manager
===================================
- used http://j2s.sourceforge.net/update
- tried using mirror from Ishikawa Japan, gave out wrong version
- retry, got latest version from The default site [j2s 1.0.0v5.2.0]. Easiest & u'll get the latest version.


connecting to gtalk using j2s
=============================
- need a servlet container
- apache tomcat engine (http://tomcat.apache.org/index.html)

- Tomcat Engine ver x.x?
- Apache Tomcat caters jsp spec from various version (http://tomcat.apache.org/whichversion.html)


- Tomcat connector?
- it's mod_jk!


- mod_jk?
- mod_jk is a replacement to the elderly mod_jserv. It is a completely new Tomcat-Apache plug-in that handles the communication between Tomcat and Apache. (http://tomcat.apache.org/tomcat-3.2-doc/mod_jk-howto.html)


- installing apache tomcat
- in C:\Program Files\Apache Software Foundation\Tomcat 6.0











- no need to run wamp and tomcat at the same time?
- successfully ran tomcat without wamp (put offline + stop all service)

- configuring apache, tomcat @ http://tomcat.apache.org/tomcat-3.2-doc/mod_jk-howto.html
1) remove mod_jserv if exist, including tomcat-apache.conf or tomcat.conf in httpd.conf
2) ..halt!

- Running J2S gtalk client on localhost succeeded!









- known bug:
- u'll stay online on you buddy's roster's after you logout
- but after 2 minutes, u'll be offline in the chat window, still online on their roster















- recompiling j2sgtalk demo:
- It uses SMACK!
- possible comm. path : Java+Smack+J2S -> Javascript -> Tomcat -> Gtalk -> Conf. Bot
- recompile success, but nothing appear after deploy and launch, the original web.xml are much more complex than what i did.

- running j2sgtalk on plain server
- unsuccessful

- simply copy/paste j2sgtalk folder into Tomcat root dir
- eventhough it shows as a tomcat app in the tomcat manager page, it still wont work.
- possible cause: the web.xml points to classes & libs that need to be loaded inside tomcat, as part of its module


- ajaxrpc?
- is part of junit.framework.TestCase - http://jsourcery.com/api/apache/webservices/axis/1.4/test/jaxrpc/AJAXRPC.html
- IMO: is a testing/debugging library for ajax


- xiff+gtalk?
- as of today...no one has ever done it.
- limitations and possible workarounds - http://www.igniterealtime.org/forum/message.jspa?messageID=103593



- What's up next?
- xmpp4moz - XMPP for Mozilla - http://dev.hyperstruct.net/xmpp4moz
- XMPP Library for firefox - http://www.bolinfest.com/changeblog/2007/03/31/request-for-help-xmpp-library-for-firefox/
- Websites about Firefox Programming - http://www.libsuccess.org/index.php?title=Web_Browser_Extensions#Websites_about_Firefox_Programming
- XMPP library for JAVA - http://www.igniterealtime.org/projects/smack/