Sunday, November 23, 2008

Where is the log file of Eclipse TPTP Agent Controller?

I have a problem to use the integrated agent controller, which RAServer.sh reported that it has actually been running. Still finding and just learned that the logs are available at:

$TPTP_AC_HOME/config/servicelog.log

yc

Wednesday, November 12, 2008

Firefox works offline due to NetworkManager interfaces being inactive

There's one improvement in Ubuntu 8.10 which is causing me some problems - NetworkManager can now detect my HSDPA. But it doesn't work and here's the log:

Nov 12 22:32:40 kimmy pppd[9724]: Plugin /usr/lib/pppd/2.4.4/nm-pppd-plugin.so loaded.
Nov 12 22:32:40 kimmy pppd[9724]: pppd 2.4.4 started by root, uid 0
Nov 12 22:32:40 kimmy pppd[9724]: Using interface ppp0
Nov 12 22:32:40 kimmy pppd[9724]: Connect: ppp0 <--> /dev/ttyUSB0
Nov 12 22:32:40 kimmy NetworkManager: (ttyUSB0): device state change: 5 -> 6
Nov 12 22:32:40 kimmy pppd[9724]: CHAP authentication succeeded
Nov 12 22:32:40 kimmy pppd[9724]: CHAP authentication succeeded
Nov 12 22:32:40 kimmy NetworkManager: (ttyUSB0): device state change: 6 -> 7
Nov 12 22:32:40 kimmy kernel: [ 2143.619828] PPP BSD Compression module registered
Nov 12 22:32:40 kimmy kernel: [ 2143.681813] PPP Deflate Compression module registered
Nov 12 22:32:42 kimmy pppd[9724]: Modem hangup
Nov 12 22:32:42 kimmy NetworkManager: (ttyUSB0): device state change: 7 -> 9
Nov 12 22:32:42 kimmy NetworkManager: [1226500362.016832] nm_serial_device_close(): Closing device 'ttyUSB0'
Nov 12 22:32:42 kimmy pppd[9724]: Connection terminated.


Then, the supposingly working gnome-ppp will start hanging up too and in order to bring it back to live, I have to run the vodafone-mobile-connect-card-driver-for-linux:

Nov 12 22:34:03 kimmy pppd[9843]: pppd 2.4.4 started by yclian, uid 1000
Nov 12 22:34:03 kimmy pppd[9843]: using channel 7
Nov 12 22:34:03 kimmy pppd[9843]: Using interface ppp0
Nov 12 22:34:03 kimmy pppd[9843]: Connect: ppp0 <--> /dev/ttyUSB0
Nov 12 22:34:03 kimmy pppd[9843]: Warning - secret file /etc/ppp/pap-secrets has world and/or group access
Nov 12 22:34:03 kimmy pppd[9843]: sent [LCP ConfReq id=0x1 ]
Nov 12 22:34:03 kimmy pppd[9843]: rcvd [LCP ConfReq id=0x12 ]
Nov 12 22:34:03 kimmy pppd[9843]: sent [LCP ConfRej id=0x12 ]
Nov 12 22:34:03 kimmy pppd[9843]: rcvd [LCP ConfAck id=0x1 ]
Nov 12 22:34:03 kimmy pppd[9843]: rcvd [LCP ConfReq id=0x13 ]
Nov 12 22:34:03 kimmy pppd[9843]: sent [LCP ConfAck id=0x13 ]
Nov 12 22:34:03 kimmy pppd[9843]: sent [LCP EchoReq id=0x0 magic=0x0]
Nov 12 22:34:03 kimmy pppd[9843]: rcvd [LCP DiscReq id=0x14 magic=0xe0777e]
Nov 12 22:34:03 kimmy pppd[9843]: rcvd [CHAP Challenge id=0x1 <5053860912aec751b049750c32c838e8>, name = "UMTS_CHAP_SRVR"]
Nov 12 22:34:03 kimmy pppd[9843]: Warning - secret file /etc/ppp/chap-secrets has world and/or group access
Nov 12 22:34:03 kimmy pppd[9843]: sent [CHAP Response id=0x1 <2fb0aedcf34cb0db311ad1a157c5be04>, name = "admin"]
Nov 12 22:34:03 kimmy pppd[9843]: rcvd [LCP EchoRep id=0x0 magic=0xe0777e 00 00 00 00]
Nov 12 22:34:03 kimmy pppd[9843]: rcvd [CHAP Success id=0x1 ""]
Nov 12 22:34:03 kimmy pppd[9843]: CHAP authentication succeeded
Nov 12 22:34:03 kimmy pppd[9843]: CHAP authentication succeeded
...
Nov 12 22:34:08 kimmy pppd[9843]: local IP address 121.120.201.243
Nov 12 22:34:08 kimmy pppd[9843]: remote IP address 10.64.64.64
Nov 12 22:34:08 kimmy pppd[9843]: primary DNS address 58.71.136.10
Nov 12 22:34:08 kimmy pppd[9843]: secondary DNS address 58.71.132.10
Nov 12 22:34:08 kimmy pppd[9843]: Script /etc/ppp/ip-up started (pid 9845)

Now, disconnecting it again, connecting with gnome-ppp will start working:

Nov 12 22:34:24 kimmy pppd[9936]: pppd 2.4.4 started by yclian, uid 1000
Nov 12 22:34:24 kimmy pppd[9936]: using channel 8
Nov 12 22:34:24 kimmy pppd[9936]: Using interface ppp0
Nov 12 22:34:24 kimmy pppd[9936]: Connect: ppp0 <--> /dev/ttyUSB0
Nov 12 22:34:24 kimmy pppd[9936]: Warning - secret file /etc/ppp/pap-secrets has world and/or group access
Nov 12 22:34:24 kimmy pppd[9936]: sent [LCP ConfReq id=0x1 ]
Nov 12 22:34:24 kimmy pppd[9936]: rcvd [LCP ConfReq id=0x15 ]
Nov 12 22:34:24 kimmy pppd[9936]: sent [LCP ConfRej id=0x15 ]
Nov 12 22:34:24 kimmy pppd[9936]: rcvd [LCP ConfAck id=0x1 ]
Nov 12 22:34:24 kimmy pppd[9936]: rcvd [LCP ConfReq id=0x16 ]
Nov 12 22:34:24 kimmy pppd[9936]: sent [LCP ConfAck id=0x16 ]
Nov 12 22:34:24 kimmy pppd[9936]: sent [LCP EchoReq id=0x0 magic=0x0]
Nov 12 22:34:24 kimmy pppd[9936]: rcvd [LCP DiscReq id=0x17 magic=0xe0cb68]
Nov 12 22:34:24 kimmy pppd[9936]: rcvd [CHAP Challenge id=0x1 <7c2c8c8e00cabc94481272f65eb30ebb>, name = "UMTS_CHAP_SRVR"]
Nov 12 22:34:24 kimmy pppd[9936]: Warning - secret file /etc/ppp/chap-secrets has world and/or group access
Nov 12 22:34:24 kimmy pppd[9936]: sent [CHAP Response id=0x1 , name = "maxis"]
Nov 12 22:34:24 kimmy pppd[9936]: rcvd [LCP EchoRep id=0x0 magic=0xe0cb68 00 00 00 00]
Nov 12 22:34:24 kimmy pppd[9936]: rcvd [CHAP Success id=0x1 ""]
Nov 12 22:34:24 kimmy pppd[9936]: CHAP authentication succeeded
Nov 12 22:34:24 kimmy pppd[9936]: CHAP authentication succeeded
...
Nov 12 22:34:27 kimmy pppd[9936]: local IP address 121.120.187.27
Nov 12 22:34:27 kimmy pppd[9936]: remote IP address 10.64.64.64
Nov 12 22:34:27 kimmy pppd[9936]: primary DNS address 58.71.136.10
Nov 12 22:34:27 kimmy pppd[9936]: secondary DNS address 58.71.132.10
Nov 12 22:34:27 kimmy pppd[9936]: Script /etc/ppp/ip-up started (pid 9938)

That's not annoying enough. NetworkManager now marks my network as inactive unless I'm connected either to eth0 or wifi0, which I did not have to do in the past. The consequence? Every time when I start Firefox, it works offline.

I found out that there're other users that are facing similar issue, like in question #28829. I did not use the NetworkManager.conf workaround as suggested in the page since I'm not familiar with the dbus stuff, but looking at the file gave me a clue that running Firefox as root would fix the problem. That was right but who would want to do that? ;-)

A better solution would definitely be altering Firefox settings. Question #96 suggests to set network.online to true but it already is! Then I saw toolkit.networkmanager.disable and toggled it to true, restarted Firefox and.. Yes, this is the solution, it disables Firefox from consulting the NetworkManager.

Read the knowledge base if you want to know more about it.

- yc

Saturday, November 8, 2008

Steve Ballmer is.. funny but great

Went to the FOSS.my 2008 and one of the sessions that I attended was Microsoft on Open Source and Silverlight. When the speaker, Chris Levanes, talked about the open source involvement of Microsoft and their peguins and lab, I remembered Steve Ballmer's "Linux is a cancer" comment. I found it irony, but.. then again, business is business and Ballmer said that like 7 years ago. The world has changed.

Ballmer (the monkey boy that most guys would call) is a passionate guy and that's the quality he has. These videos are amusing and they will really make you to remember him.
Now.. before we laugh at him, here're some facts:
  • Ballmer is the CEO of Microsoft.
  • Ballmer is fucking passionate, or, he can really express himself in a crazy manner.
  • Ballmer is one of the richest men in the world.
Can you do better than him?

- yc

Thursday, November 6, 2008

Profiling a Remote Application in Eclipse

I came across this guide which mentioned about attaching the Eclipse profiler to a remote Java application. I was stuck for some hours, asked my question in #java and #eclipse but got no response.. then, realized that, the instructions are old!

Instead, I visited the TPTP site, downloaded the Agent Controller and followed the instructions in this page to get things up and running. Basically,
  • Add $TPTP_AC_HOME/lib:$TPTP_AC_HOME/bin:$TPTP_AC_HOME/plugins/org.eclipse.tptp.javaprofiler to $LD_LIBRARY_PATH
  • Add $TPTP_AC_HOME/bin to $PATH
  • Run SetConfig.sh to configure the AC
  • Run ACStart.sh to start AC
  • Add '-agentlib:JPIBootLoader=JPIAgent:server=enabled;CGProf' to your JAVA_OPTS (ldd and nm are good commands)
  • Start your Java application
  • Profile and hook into the application by selecting "Attach to Agent" in the Eclipse's dialog
- yc

Friday, October 31, 2008

XML-RPC vs. SOAP vs. REST thoughts and Spring Beans

Recently I am working on the remote API side of my project, and the protocol that we chose is XML-RPC. Somewhere in two blogs returned by Google search suggested that REST > XML-RPC > SOAP. SOAP can only be considered for its wide enterprise adoption and protocol stack (with security management, transaction control, etc.) and therefore it is complicated. Yes, the person created XML-RPC wasn't an expert in XML but it's neat.

Why not REST then? I used to work on design and technical issues of Mule ESB and I was exposed to REST of its sweetness (the simplicity, the CRUD stuff) before more people started to talk about it (now they talk about Cloud). I learned that SOAP is for SOA (Service Oriented Architecture) and REST is for ROA (Resource Oriented Architecture). They are two different paradigms, and the purpose and design of these layers are therefore different, e.g. you don't carry a service/RPC mindset when you create a REST API.

So, no REST for now as IMO it requires more effort to design a proper API. Never I'll create SOAP due to its complexity.

What about JSON-RPC? I had a short discussion regarding this with @ditesh at #myoss@irc.freenode.net. I love JSON for its interoperability and speed (vs. XML parsing). But the available implementations turned me off pretty quickly, most of them stuck in year 2005~2007. For a publicly available remote API, a well-adopted and "mature" protocol is a much better choice.

What about the Spring beans stuff mentioned in the topic? I found the Apache XML-RPC server can't be integrated with Spring naturally (it has but not enough of bean property methods) and the API is quite ugly, e.g. XmlRpcSystemImpl.addSystemHandler() takes a PropertyHandlerMapping, why not XmlRpcListableHandlerMapping?

I took a similar approach suggested by Tomas Salfischberger in his blog and here they are:
  • An implementation of Spring's AbstractController.
  • An extension of PropertyHandlerMapping, this bean is used by the previous.

public class MyXmlRpcController extends AbstractController {
private XmlRpcServletServer server = new XmlRpcServletServer();
private boolean introspectionEnabled = false;

@Override
protected void initServletContext(ServletContext servletContext) {
super.initServletContext(servletContext);
if (this.introspectionEnabled) {
try {
XmlRpcSystemImpl.addSystemHandler((PropertyHandlerMapping) this.server.getHandlerMapping());
} catch (Exception e) {
}
}
}
@Override
protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception {
this.server.execute(request, response);
return null;
}
@Required
public void setHandlerMapping(XmlRpcHandlerMapping serverHandlerMapping) {
this.server.setHandlerMapping(serverHandlerMapping);
}
public void setIntrospectionEnabled(boolean introspectionEnabled) {
this.introspectionEnabled = introspectionEnabled;
}
}

public class MyXmlRpcHandlerMapping extends PropertyHandlerMapping {
private Map serviceMap;

public void init() throws XmlRpcException {
this.load(Thread.currentThread().getContextClassLoader(), serviceMap);
}
@Required
public void setServicesMapping(Map serviceMap) {
this.serviceMap = serviceMap;
}
}


<bean id="xmlRpcHandlerMapping" class="my.MyXmlRpcHandlerMapping" init-method="init">
<property name="servicesMapping">
<map>
<entry key="membershipService" value="my.service.XmlRpcMembershipService"></entry>
</map>
</property>
</bean>
<bean id="urlHandlerMapping" class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
<property name="mappings">
<value>/xmlrpc=xmlRpcController</value>
</property>
</bean>
<bean id="xmlRpcController" class="my.MyXmlRpcController">
<property name="handlerMapping" ref="xmlRpcHandlerMapping"></property>
<property name="introspectionEnabled" value="true"></property>
</bean>


- yc

Friday, October 17, 2008

The guys behind the new Maybank2U, please read

Epic fail! For the past few days, I had been hearing people ranting about the new site in Twitter, Facebook and my IM.

I haven't been using my Maybank account (basically abandoning it unless there's a need to M2U to some friends for convenience sake, oh.. and, it has more ATM machines than HSBC that is true) for the past 2 months ever since I changed my job.

As I am NOW doing some book keeping, as well as to experience the pain others are suffering, I convinced myself to log into the site. Clicking on "Transaction History", the cool Ajaxy waiting icon appeared and.. woohoo, a few 10 seconds later:

Ah, ArrayIndexOutOfBoundsException, caused by a JSP tag. I don't want to know what else they're doing with Struts and in the JSP, but surely, these guys wrote some shit to make almost every customer suffers.

- yc

Monday, October 13, 2008

I love Java

Love? Love comes with struggles, frustrations, hate; it's unconditional. There's this "I Love *" meme initiated by the folks at foss.my and in supporting of it and to show my love to the programming language and its community:



I love Java for how advanced it is, for the standards (see JCP and JSRs) that have been defined, for the other languages that you can run on top of it, for its rich frameworks and libraries, ...

I hate Java, for the same reasons too. :)

Note: The Sun's Java Virtual Machine (runtime) is called HotSpot. It is released under GPL, it wasn't.. before November 2006. Here is a list of JVM implementations.

- yc