Implementing Web AIM Client
Here are some notes when I was struggling to develop a web AIM client:
1. Download AIM SDK, both Windows and Linux
In Linux environment, you may already have NSS/NSPR libraries installed, if not following instructions to install it. You only need to run:
cd dist/release/
ln -s /usr/lib/libnspr4.so .
ln -s /usr/lib/libnss3.so .
ln -s /usr/lib/libnssckbi.so .
ln -s /usr/lib/libplc4.so .
ln -s /usr/lib/libplds4.so .
ln -s /usr/lib/libsmime3.so .
ln -s /usr/lib/libsoftokn3.so .
ln -s /usr/lib/libssl3.so .
ln -s /usr/lib/libfreebl3.so .
export LD_LIBRARY_PATH=/usr/local/tomcat/lib/
2. Get a developer key to use AIM SDK. The developer web site does not accept external email account, so create a new one. In fact, more new AIM screen names are needed, as testing AIM requires it.
3. Try to compile and run samples/accjsample:
cd samples/accjsample
javac -cp ../../dist/release/accjwrap.jar AccJSample.java Prefs.java
java -cp ../../dist/release/accjwrap.jar:./ AccJSample username password developerkey
But you may get error messasge like:
UNKNOWNVALUE
com.aol.acc.AccException: IAccSession_SignOn
at com.aol.acc.AccSession.SignOn(Native Method)
at com.aol.acc.AccSession.signOn(AccSession.java:113)
at AccJSample.(AccJSample.java:47)
at AccJSample.main(AccJSample.java:22)
But if you go into dist/release/ directory, where *.so are located, and run:
/usr/local/java/bin/java -cp ../../dist/release/accjwrap.jar:../../samples/accjsample/ AccJSample username password developerkey
You may get things running correctly:
[5/5/08 8:34 AM]: OnStateChange: Connecting, ACC_S_OK
[5/5/08 8:34 AM]: OnStateChange: Validating, ACC_S_OK
[5/5/08 8:34 AM]: OnStateChange: Transferring, ACC_S_OK
[5/5/08 8:34 AM]: OnStateChange: Negotiating, ACC_S_OK
[5/5/08 8:34 AM]: OnStateChange: Starting, ACC_S_OK
[5/5/08 8:34 AM]: OnStateChange: Online, ACC_S_OK
[5/5/08 8:34 AM]: OnUserChange: ACC_S_OK
…
That is because *.so may not be loaded correctly if they are not in the current working directory.
Someone says that inaccurate time may cause problems, so run:
/etc/init.d/ntpd start
to synchronize your server’s time.
4. following, it comes to the time that developing AIM desktop client, and then converting it into Java Servlet based AIM client. So, tutorial “Creating AIM-Enabled Application in Java” series are recommended.
5. And time to deploy your web AIM client to tomcat servlet container.
If your Tomcat 6 server is on Windows, you may need to copy all dist/release/*.dll into your %CATALINA_HOME%/bin/ folder, copy dist/release/accjwrap.jar into %CATALINA_HOME%/lib and restart Tomcat services to get things done. Deploy accjwrap.jar directly into webapps folder is not recommended, because you may want to restart your servlet application frequently while loading and unloading *.dll modules may cause “already loaded in another classloader UnsatisfiedLinkError” problems for Tomcat, which may result that you need to restart your Tomcat server.
If your Tomcat 6 server is on Linux, you also need to copy all dist/release/*.so into your $CATALINA_HOME/bin/ folder, copy dist/release/accjwrap.jar into $CATALINA_HOME/lib. And you need to modify your catalina.sh and add two lines:
LD_LIBRARY_PATH=$CATALINA_HOME/bin
cd $CATALINA_HOME/bin
And then restart Tomcat server.
Related links:
- Tomcat Native library on java.library.path
- Java Native Interface (JNI) - JNI Dll - java.library.path
- Java Linux issues with SDK
- AIM Custom Client Forum
Tags: AIM
June 19th, 2008 at 2:17 am
com.aol.acc.AccException: IAccSession_SetIdentity
My dev
Windows XP
Tomcat 6
JDK 6.0.06
Enviroment Variables
My Code
/**
* Logs in and calls pumpMsg to wait for server messages
* @param username
* @param password
*/
private void login(String username, String password){
AccClientInfo info;
try {
info = session.getClientInfo();
info.setDescription(key);
// set screen name
session.setIdentity(username);
session.signOn(password);
} catch (AccException e) {
System.out.println(”AccException: ” + e.errorCode);
e.printStackTrace();
}
pumpMsg();
}
/**
* runs loop
*/
private void pumpMsg() {
while(running)
{
try {
AccSession.pump(50);
} catch (Exception e) {
e.printStackTrace();
}
try {
Thread.sleep(50);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
the exception
com.aol.acc.AccException: IAccSession_SetIdentity
at com.aol.acc.AccSession.SetIdentity(Native Method)
at com.aol.acc.AccSession.setIdentity(AccSession.java:102)
at com.fluid.shopping.red5.invitation.messaging.impl.AIMInviterImpl.login(AIMInviterImpl.java:147)
at com.fluid.shopping.red5.invitation.messaging.impl.AIMInviterImpl.retrieveBuddyList(AIMInviterImpl.java:97)
at com.fluid.shopping.red5.service.impl.InvitationServiceImpl.retrieveAIMBuddyList(InvitationServiceImpl.java:23)
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 com.fluid.shopping.red5.Application.execute(Application.java:92)
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 org.red5.server.service.ServiceInvoker.invoke(ServiceInvoker.java:217)
at org.red5.server.service.ServiceInvoker.invoke(ServiceInvoker.java:123)
at org.red5.server.net.rtmp.RTMPHandler.invokeCall(RTMPHandler.java:161)
at org.red5.server.net.rtmp.RTMPHandler.onInvoke(RTMPHandler.java:437)
at org.red5.server.net.rtmp.BaseRTMPHandler.messageReceived(BaseRTMPHandler.java:143)
at org.red5.server.net.rtmpt.RTMPTHandler.messageReceived(RTMPTHandler.java:117)
at org.red5.server.net.rtmpt.RTMPTServlet.handleSend(RTMPTServlet.java:397)
at org.red5.server.net.rtmpt.RTMPTServlet.service(RTMPTServlet.java:478)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:433)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
at org.apache.coyote.ajp.AjpAprProcessor.process(AjpAprProcessor.java:419)
at org.apache.coyote.ajp.AjpAprProtocol$AjpConnectionHandler.process(AjpAprProtocol.java:378)
at org.apache.tomcat.util.net.AprEndpoint$Worker.run(AprEndpoint.java:1509)
at java.lang.Thread.run(Thread.java:619)
Error code
AccException: ACC_E_FAIL
How i’m starting tomcat
all libraries are in CATALINA_HOME/bin and enviroment variable PATH contains it
1. From eclipse with sisdeo plugin
2. With a custom .bat
SET JAVA_HOME=C:\Java\jdk1.6.0_06
SET CATALINA_HOME=C:\Java\apache\apache-tomcat-6.0.16
SET JPDA_OPTS = -Xdebug -Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=n
SET JAVA_OPTS = “-Djava.library.path=%CATALINA_HOME%\bin”
SET XMFILE=c:\servers\tomcat\server.xml
%CATALINA_HOME%\bin\startup.bat -config %XMFILE% %JAVA_OPTS% %JPDA_OPTS%
I hope somebody could help me with this issue.
Thanks
June 19th, 2008 at 2:19 am
I have accjwrap.jar in $CATALINA_HOME/lib too
June 19th, 2008 at 8:44 pm
Hi gclavell, what about putting *.dll into %CATALINA_HOME%\bin
I use the same Tomcat 6 and JDK 6, but I installed Tomcat 6 instead unzipped Tomcat 6, so no customized startup.bat is needed for me.
Hope this article helps.
June 25th, 2008 at 1:49 am
Thank you very much, it’s working
But not in linux
???
logs tell me that -Djava.library.path has no accjwrap
i have ntp running
i have LD_LIBRARY_PATH=tomcat/bin
and all in tomcat/bin(*.so and accj…jar)
June 25th, 2008 at 4:59 am
Run your tomcat in root. You may modify /etc/init.d/tomcat to do so.
June 25th, 2008 at 9:01 am
export JAVA_HOME=/usr/lib/jvm/java-6-sun
case $1 in
start)
sudo /usr/local/tomcat6/bin/startup.sh
;;
stop)
sudo /usr/local/tomcat6/bin/shutdown.sh
;;
restart)
sudo /usr/local/tomcat6/bin/shutdown.sh
sudo /usr/local/tomcat6/bin/startup.sh
;;
esac
exit 0
August 22nd, 2008 at 4:15 am
Thanks so much for pointing out that you may still need to copy the .so files to the working directory of the app! I was butting my head against this problem under Linux for several hours. It seems like either there should be a more “linux-friendly” solution, or that perhaps the AIM libraries are just mis-implemented, but either way I’ll take the workaround! Thanks!