Archive March 2013

x11 window server and users rights

March 27, 2013

if you get exception similar to the following: Can’t connect to X11 window server

check your DISPLAY env variable : > echo $DISPLAY
fix it if not correct : > export DISPLAY=:0

if it’s correctly set but you have the problem. May your linux user you have using don’t have rights to the xhost.
check this closure by typing: > xhost

if your user is not in the list, give it the right to connect to the X11 window server by typing: > xhost +SI:localuser:jboss

icefaces and SendUpdates optimization

if you encounter slow rendering (on icefaces tree for example) and generally when you code using icefaces framework, be sure that any html component you write has an id or has an icefaces component as parent.
In fact, icefaces client module send ajax request to the icefaces server module in aim to retrieve DOM changes. icefaces server module try to look for dom changes, and when each element has changed but have no id, it looks for its parent in the dom and insert all children of this parent as changed.

In my case i have a page with two elements: a <div>…</div> and just after an <ice:tree>…</ice:tree>
Unfortenatly, i don’t put an id to my <div>. So when i expand one node in the <ice:tree> i got all tree nodes sent as updates elements in the icefaces ajax response.
setting an id or converting your <div> to <ice:panelGroup> fix problem.

@see
– method computing and sending updates: com.icesoft.faces.context.PushModeSerializer -> serialize(final Document document)
– to debug dom updates, add following in your web.xml:

    
        com.icesoft.faces.debugDOMUpdate
        true
    

graphml de ton projet java

March 22, 2013

utils:
– degraph (https://github.com/schauder/degraph) / download: http://schauder.github.com/degraph//download/degraph-0.0.3.zip
– yEd (http://www.yworks.com/en/downloads.html#yEd) / download: http://www.yworks.com/en/products_download.php?file=yEd-3.10.2.zip

howto:
1. download degraph-0.0.3.zip and yEd-3.10.2.zip
2. unzip them in corresponding directories: degraph-0.0.3, yEd-3.10.2
3. > ./degraph-0.0.3/bin/degraph -c path/to/my_jar.jar -o /tmp/output.graphml -i witr.**
    this command line will scan only witr.** classes of your my_jar.jar and create output.graphml file
4. > cd yEd-3.10.2
    > java -jar yEd-3.10.2/yed.jar
    this wll run yEd. be sure that you can connect to X11 window server
5. use yEd gui to open output.graphml file
6. if the graph is not well presented then menu: layout>organic>
    preferred edge length = 117
    minimal node distance = 50
    avoid node/edge overlaps : check
    compacteness = 0.9
    ===> validate by pressing ok

enjoy

highlight results with javascript and escaping contents of tag

March 21, 2013

substitute regexp by this one var search_regexp = new RegExp(‘(?!

]*?>)>([^]*)?(?![^<]*?

)<','ig');

function highlightWordSearching(componentId, search){
    if(search && !search.blank()){
    search = search.replace(‘&’,’&’);
        var search_regexp = new RegExp(‘>([^]*)?<','ig');
        $(componentId).innerHTML = $(componentId).innerHTML.replace(search_regexp,’>$1$2$3<');
    }
}

connect with ssh from windows SSH Secure Shell to ubuntu sshd

March 20, 2013

first of all install sshd : “sudo apt-get install openssh-server”
then start sshd : “sudo /etc/init.d/ssh start” and try to connect from SSH Secure Shell with username/password

If it works, we have to know that username/password authentication is not secure!
So we will disable authentication with username/password and allow only keys authentication.
We have to edit sshd config file: sudo vi /etc/ssh/ssh_config
ensure that lines bellow are not commented and have such values:
– RSAAuthentication yes
– PubkeyAuthentication yes
– AuthorizedKeysFile      %h/.ssh/authorized_keys
and disable username/password auth:
– PasswordAuthentication no
save sshd_config and restart sshd : sudo /etc/init.d/ssh restart

now if you try to connect from SSH Secure Shell with username/password you will be refused. you must generate and put public and private keys.

> ssh-keygen -t dsa mykey.ossh
will create private and public keys

> cat mykey.ossh.pub >> ~/.ssh/authorized_keys
will authorize person having keys to login

if you will connect from open ssh client you just have to copy keys in your .ssh home directory
if you will connect from SSH Secure Shell you must before that convert open ssh keys to ssh2
> ssh-keygen -e -f mykey.ossh > mykey
> ssh-keygen -e -f mykey.ossh.pub > mykey.pub
then use mykey and mykey.pub from SSH SecureShell

connect with specified private key
> ssh -i path/to/your/private_key user@server.domain_or_ip
transfer myfile to server
> scp -i path/to/your/private_key myfile user@server.domain_or_ip:/path_in_server/

wireshark and npf under windows7


March 19, 2013

wireshark can not start capture because npf is not running under windows7.
solution : execute cmd.exe as administrator and type:
> sc qc npf
this will display th state of npf. if it’s not running then type
> sc start npf
if you want to set auto start type
> sc config npf start=auto