Wednesday, December 19, 2012

Aspectj - trace method exection caller context details

http://mathewjhall.wordpress.com/2011/03/31/tracing-java-method-execution-with-aspectj/
:
Signature sig = thisJoinPointStaticPart.getSignature();
  String line =""+ thisJoinPointStaticPart.getSourceLocation().getLine();
  String sourceName = thisJoinPointStaticPart.getSourceLocation().getWithinType().getCanonicalName();
  Logger.getLogger("Tracing").log(
                Level.INFO, 
                "Call from "
                 +  sourceName
                    +" line " +
                    line
                    +" to " +sig.getDeclaringTypeName() + "." + sig.getName()
  );

jvisualvm remote tomcat

http://www.codefactorycr.com/java-visualvm-to-profile-a-remote-server.html
:
Start jstatd:
Given JAVA_HOME=/usr/lib/jvm/java-6-sun/bin
 Write following config to /usr/lib/jvm/java-6-sun/bin/jstatd.all.policy
grant codebase "file:<JAVA_HOME>/lib/tools.jar" {
permission java.security.AllPermission;};

 > /usr/lib/jvm/java-6-sun/bin/jstatd.all.policy

Then execute jstatd as
./jstatd -J-Djava.security.policy=jstatd.all.policy &


Identify jstatd ports as given in above link and make necessary firewall modifications.

Result: We can see the remote jstatd process in local jvisualvm as a remote process under the host.(plz add the host)

http://stackoverflow.com/questions/3892084/can-visualvm-connect-automatically-via-jmx-to-a-remote-process
:
Open tomcat's startup.sh and add following lines before the call
exec "$PRGDIR"/"$EXECUTABLE" start "$@"

JAVA_OPTS="$JAVA_OPTS -Dcom.sun.management.jmxremote.port=60000 -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false"

 Now you can even see your server along with jstatd under the remote host.

For JConsole:
http://docs.oracle.com/javase/1.5.0/docs/guide/management/jconsole.html:
Just connect to <host>:60000 (port no. set in the jmx settings specified in JAVA_OPTS above) and it works.

Thanks,
Tapomay.

Wednesday, September 12, 2012

Fedora 17: ant-optional - custom ant libs - ClassNotFoundException

http://fastcloud.wordpress.com/2009/05/14/how-to-install-apache-ant-on-fedora-8/ :
Basically you have to maually create the /usr/share/ant hierarchy and set ANT_HOME. Thats it.
You may want to include junit.jar also into the ANT_HOME/lib. Then you need not manuallly declare it in each of your project's classpath.

The default installation of ant from yum is bare-minimum and won't work for custom ant libs.

Tuesday, July 31, 2012

Fighting make error: not protecting function: no buffer at least 8 bytes long

Attempting to build monetdb from source. The mercurial checkout date is not today but somewhere around start of July.

Getting the following error saying something like:
cc1: warnings being treated as errors - this is due to -Werror flag to gcc


inet.c: In function ‘INET_comp_CW’:
inet.c:323: error: not protecting function: no buffer at least 8 bytes long
inet.c: In function ‘INETbroadcast’:
inet.c:423: error: not protecting function: no buffer at least 8 bytes long
inet.c: In function ‘INETnetmask’:
inet.c:523: error: not protecting function: no buffer at least 8 bytes long
inet.c: In function ‘INETnetwork’:
inet.c:593: error: not protecting function: no buffer at least 8 bytes long
inet.c: In function ‘INETabbrev’:
inet.c:660: error: not protecting function: no buffer at least 8 bytes long
make[7]: *** [libatoms_la-inet.lo] Error 1
 - due to -fstack-protector-all -Wstack-protector flags to gcc. For more info on stack protector feature refer http://stackoverflow.com/questions/1629685/when-and-how-to-use-gccs-stack-protection-feature


The explanation at http://ubuntuforums.org/showthread.php?t=1612849 was sufficient for fixing.

Went to those line numbers.  They were the entry point of the reported functions.
Found unsigned char[4] local variables. Changed them to char[8].

Owned it.

Regards,
Tapomay.

Design patterns in Ruby


http://rubylearning.com/blog/2010/11/02/how-does-one-use-design-patterns-in-ruby/ :


I believe that the essence of design patterns is to make a system resilient to changes in requirements which in itself could be attributed with the parameters associated with the problem definition. The above article helped me with a lucid set of ruby examples demonstrating following patterns:
(The comments are for my personal notes. Plz ignore them)
1. Inheritance  : Car < Vehicle
2. Composition over inheritance : Car<Vehicle, Car->Engine
3. Delegation ; Car<Vehicle, Car->Engine
4. Template Method pattern : HTMLReport<Report, TextReport<Report
5. Singleton pattern : require 'singleton', attr_accessor :data
6. Adapter pattern : Renderer, TextObject, DifferentTextObject, TextObjectAdapter, class << diff_text_obj

Thanks and Regards,
Tapomay




Tuesday, May 8, 2012

Java books


Concurrency in java -doug lee
gang of 4
Effective Java -Joshua
Java performance tuning 

Friday, April 20, 2012

Bash script - execute all sql files in a directory


#!/bin/bash

for i in $(ls *.sql)
do

echo "Executing" $i;
mysql  -u root < $i

done

Wednesday, March 21, 2012

Try hd(0,0): NTFS5: No wubildr

http://ubuntuforums.org/showthread.php?t=1585120&page=2

Just wait for sometime on the screen saying "Try hd(0,0): NTFS5: No wubildr". Grub comes up later without doing anything.

I was getting windows boot loader earlier. Selected Ubuntu and I was stuck with above message.

Monday, March 19, 2012

Hibernate HQL view join: java.lang.NullPointerException at org.hibernate.util.ReflectHelper.getConstructor(ReflectHelper.java:234)

https://hibernate.onjira.com/browse/HHH-5621

What worked for me:
"This is a minor issue since an easy workaround is available: you just have to use an alias to qualified the properties....
Query query3 = session.createQuery("select new Something(sthg.id, sthg.event, sthg.dummyField) " +
"from Something sthg" );"