Archive June 2013

secure jboss7 with ssl (https)

1. create keystore certificate for jboss user
> keytool -genkey -alias jboss -keyalg RSA

2. edit jboss configuration file standalone.xml:
– in interfaces : add new interface “local”

    
       ......
        
            
        
        ......
    
– in socket binding : add new socket binding “httpLocal” listening on localhost with http
    
       ......
        
       ......
    

– remove http connector :
<connector name=”http” protocol=”HTTP/1.1″ scheme=”http” socket-binding=”http”/>

– add local http connector (for modules having to communicate in http with each others)

<connector name=”http” protocol=”HTTP/1.1″ scheme=”http” socket-binding=”httpLocal”/>

– add new https connector

            <connector name=”https” protocol=”HTTP/1.1″ scheme=”https” socket-binding=”https” secure=”true”>
              <ssl password=”password typed in step 1″ />
            </connector>

in subsystem web we must finally have :
        
            
            
              
            
            
                
                
            
        

exception : “java -jar” java.lang.NoClassDefFoundError

when you execute a jar file with java, you have to know that in the jar file we must declare the main class and th classpath in the manifest file.

extarct MANIFEST.MF
> jar xvf myjar.jar META-INF/MANIFEST.MF
see its content
> vi META-INF/MANIFEST.MF
it looks like :

Manifest-Version: 1.0
Ant-Version: Apache Ant 1.5.3
Created-By: 1.4.2_02-b03 (Sun Microsystems Inc.)
Main-Class: xxx.package.MainClassName
Class-Path: ./lib/a.jar  ./lib/b.jar

if you have NoClassDefFoundError when launching the jar, look for the missed jar library in the web, download it and put it in lib directory for example, and finally declare it in the manifest like others (./lib/a.jar ./lib/b.jar ./lib/c.jar). so :

> mkdir unzippedjar
> unzip myjar -d unzippedjar/
> cd unzippedjar
> vi META-INF/MANIFEST.MF
edit the manifest file : add missed lib to classpath, and save
> zip -r ../myjar.jar *

re-execute your myjar.jar and it must work

==========================
case of delineate which miss xalan-2.7.1.jar as library.

jpg to svg

to convert jpg to svg we can use autotrace or potrace.

autotrace:
> sudo apt-get install autotrace
use (convert /tmp/mba.jpg to svg):
> autotrace /tmp/mba.jpg -input-format jpg -output-format svg -output-file /tmp/mba.svg

see delineate gui application which use autotrace or potrace

merge several pdf files


================================================= 17/06/2013
merge several pdf files:
under ubuntu install pdftk, then to merge several pdf files type  following command:
> pdftk file1.pdf file2.pdf output file_merge.pdf

simple nodejs http server


================================================= 14/06/2013
simple nodejs http server:
– install nodejs
– create file server.js with following content:
var url = require(“url”);

function handleHttpRequest(request, response){
response.writeHead(200, {“Content-Type”: “text/html”});
response.write(“pathname:”+url.parse(request.url).pathname);
response.write(“
“);
response.write(“query:”+url.parse(request.url).query);
response.end();
}

var http = require(“http”);
http.createServer(handleHttpRequest).listen(8888);
– in command line: node /path/to/server.js
– go to http://localhost:8888
– go to http://localhost:8888/sevice?user=nour&age=42