Wednesday, December 09, 2009

Unable to access jarfile on Cygwin

Today I ran into a strange problem on Cygwin: I give the full path to the jar file for the java command, but strangely, the java runtime shows me the error message: Unable to access jarfile /cygdrive/c/pathtojar/.yuicompressor.jar. What is going on? did I have a typo? No. Then Why? After scratch my head enough, I figure out that the java in Cygwin does not like Unix format path to specify the jar file. You can use cygpath to do the trick to convert the Unix format path to mixed(-m) or windows format(-w) path, the java command will happily take it and use the jar file. Here are the two commands that works for me:
  • java -jar `cygpath -m /cygdrive/c/pathtojar/.yuicompressor.jar`
  • java -jar `cygpath -w /cygdrive/c/pathtojar/.yuicompressor.jar`

pip install python packages makes it easy

pip is easy_install replacement, and it is easy to use. Here are some features I recently used:
  1. To install something from Python Package Index, for example, Django 1.1, you just issue: pip install django, it will download it and install it.
  2. To see what Python Packages were installed by pip, you can use command: pip freeze, of course, you can redirect the output to a file and pass around.
  3. To uninstall a Python Package, for example, Django 1.1 installed in step 1, the command is: pip uninstall django.
  4. To install some Python Package you may run into error: No distributions at all found for xxxxx, you can supply the package file url to the pip install command, for example, if you want to install Django 0.96.5, here is the command: pip install http://www.djangoproject.com/download/0.96.5/tarball/, this one is pretty cool, if you can find the package gz file, then you can install it by using pip.

Friday, June 05, 2009

Install MySQL-python on Cygwin

After pulling my hairs and scavenging the Google, finally I succeeded installed the MySQL-python on Cygwin.
  • Build MySQL on Cygwin
  • Download MySQL source package from here. I was using mysql-5.0.76.tar.gz
  • configure && make && make install
  • Install MySQL-python on Cygwin
  • Download MySQL-python . I was using 1.2.2. Unzip it.
  • ./setup.py install, if you run into any problem, please have look on the readme file of the MySQL-python package. You may need to update threadSafe=False in the site.cfg file.

Wednesday, June 03, 2009

PIL error: IOError: decoder jpeg not available

After installing PIL on Cygwin, I ran into the following error while I am trying to load data from a JPEG file.
IOError: decoder jpeg not available
To solve this problem I did the following steps:
Remove the installed PIL from Cygwin:
rm -rf /usr/lib/python2.5/site-packages/PIL
rm /usr/lib/python2.5/site-packages/PIL.pth

Install libjpeg by using Cygwin setup.exe

Rerun PIL setup.py install.

unable to remap C:\cygwin\bin\tk84.dll

While installing PIL(Python Imaging Libary) on Cygwin, I ran into the following error:
5 [main] python 4388 C:\cygwin\bin\python.exe: *** fatal error - unable to remap C:\cygwin\bin\tk84.dll to same address as parent(0x410000) != 0
x700000
22 [main] python 4636 fork: child 4388 - died waiting for dll loading, errno 11
error: Resource temporarily unavailable

Fortunately, with the help of Google, it is easy to find an existing solution from Datahammer's blog:
c:\cygwin\bin\ash
cd /bin
./rebase -b 0x100000000 tk84.dll

Rerun the PIL setup.py install in Cygwin shell.

Update: If you run into remap error on Cygwin, you could try rebaseall
c:\cygwin\bin\ash
cd /bin
./rebaseall

Thursday, April 16, 2009

Unix commands help on diagnosing Weblogic problems

While working on diagnosing the Weblogic problems, I found the unix commands help me a lot, here they are:
  • Apache error_log files BackEnd errors: grep -r -h --include=error_log Backend . | awk '{print $2 " " $3}'| sort | uniq -c

  • Oracle connections: while true; do netstat -an|grep 1521; netstat -an|grep 1521|wc -l; echo "+++++++++++++++++++"; sleep 4; done;

Thursday, April 09, 2009

Google App Engine for Java Rocks!!!

I signed up GAE yesterday, and the account was activated today. It is time to play with it:
* Create Application ID
* Download and install Eclipse plugin
* Create new Web application
* Deploy application to GAE

Done!!!
It is just so easy.
More will come on this topic.

Friday, March 13, 2009

How to remote debug JMeter?

Want to remote Debug JMeter? Here I show you how I did it?
  1. Download JMeter binary package and source package, unzip them into the same directory.
  2. Rename the eclipse.classpath file to .classpath and open the project with IDEA.
  3. Open a shell, set JVM_ARGS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5005
  4. Start JMeter in the previous shell.
  5. Setup remote debug in IDEA and start debug.

Setup JMeter JMS Publisher Sampler

Even though there are documentations on how to setup and use JMeter JMS publisher sampler, it seems all of them are either inaccurate or out of date. After pulling my hair for almost two hours, I finally made it work. To avoid headache for anybody who want to set up JMeter JMS publisher sampler, I recorded the procedure as following.

We choose ActiveMQ as our JMS provider.
  1. Copy activemq-core-5.2.0.jar, jms-1.1.jar, and geronimo-j2ee-management_1.0_spec-1.0.jar into JMeter's lib directory.
  2. Create a jndi.properties file and jar it into a jar file, put the jar file into JMeter's lib directory.
  3. Confiture the JMS publisher sampler with the following settings in the JMeter GUI.
  • Check use jndi.properties
  • Connection Factory: ConnectionFactory
  • Topic: MyTopic
  • Number of messages to aggregate: 1
Here is the content of the jndi.properties file:
java.naming.factory.initial=org.apache.activemq.jndi.ActiveMQInitialContextFactory
java.naming.provider.url=tcp://hostname:61616
topic.MyTopic=topic

There are a few catches during the setting up process:
* The ActiveMQInitialContextFactory package name must have the apache.
* ConnectionFactory can not contain any trailing space.
* The Topic JNDI name must be prefixed with topic in the jndi file.
* You must put in the Number Of messages to aggregate, otherwise there will be no messages published.