Thursday, April 18, 2013

reverse proxy for jetty 9 with nginx


========jetty 9  docs =========
http://wiki.eclipse.org/Jetty_Expanded_Webapp_Deploy
http://wiki.eclipse.org/Jetty/Howto/Configure_JNDI_Datasource
http://www.eclipse.org/jetty/documentation/current/

====== set up proxy for jetty 9 ==========
from jetty side, if you want to run at a maven webapp dir, do as follows:

1) cd ~/projects-try/ccaApp
2) mvn war:inplace (run this only if java compile is needed, jsp's gets refreshed directly)
3) add jetty-web.xml with following details under WEB-INF
you can also do setup extra things like datasource, jndi etc.,
look at url jetty 9 http://www.eclipse.org/jetty/documentation/current/
4) note the context name given here should match with the one we will put in nginx proxy-pass as follows
before close of last "}", paste folowing contents
#inside server add
sudo vi /etc/nginx/sites-available/default
sudo /etc/init.d/nginx reload

location ^~ /j9090 {
     proxy_set_header X-Forwarded-Host $host;
        proxy_set_header X-Forwarded-Server $host;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_pass http://localhost:9090;
    }
5) then you can start jetty by jetty.jar or using jetty-maven-plugin too
java -jar ~/programs/jetty-9.jar --port 9090  ~/projects-try/ccaApp/src/main/webapp

6) test these both url's it should work
a) using nginx http://localhost/j9090/
b) using jetty http://localhost:9090/j9090/

nginx setup and php


sudo apt-get install nginx
sudo /etc/init.d/nginx start

#install php-fpm
sudo apt-get install php5-fpm
sudo vi /etc/nginx/nginx.conf

#adjust values
worker_processes  4;
keepalive_timeout   2;

mkdir ~/www-nginx
cp /etc/nginx/sites-available/default ~/www-nginx/default.orig

#Virtual hosts are defined in server {} containers. The default #virtualhost is defined in the file /etc/nginx/sites-available/default:

sudo vi /etc/nginx/sites-available/default

========
server {
        listen   80; ## listen for ipv4; this line is default and implied
        listen   [::]:80 default ipv6only=on; ## listen for ipv6

        #root /usr/share/nginx/www;
root /home/rajesh/www-nginx;
        index index.php index.html index.htm;

        # Make site accessible from http://localhost/
        server_name _;

        location / {
                # First attempt to serve request as file, then
                # as directory, then fall back to index.html
                try_files $uri $uri/ /index.html;
                # Uncomment to enable naxsi on this location
                # include /etc/nginx/naxsi.rules
        }

        location /doc/ {
                alias /usr/share/doc/;
                autoindex on;
                allow 127.0.0.1;
                deny all;
        }

        # Only for nginx-naxsi : process denied requests
        #location /RequestDenied {
                # For example, return an error code
                #return 418;
        #}

        #error_page 404 /404.html;

        # redirect server error pages to the static page /50x.html
        #
        error_page 500 502 503 504 /50x.html;
        location = /50x.html {
                root /usr/share/nginx/www;
        }

        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
        #
        location ~ \.php$ {
                try_files $uri =404;
                fastcgi_split_path_info ^(.+\.php)(/.+)$;
                fastcgi_pass 127.0.0.1:9000;
                fastcgi_index index.php;
                include fastcgi_params;
        }

        # deny access to .htaccess files, if Apache's document root
        # concurs with nginx's one
        #
        location ~ /\.ht {
                deny all;
        }
}
==========

sudo /etc/init.d/nginx reload
sudo apt-get install php5-fpm

echo "" > ~/www-nginx/info.php

#test using http://rpradeshik/info.php

Friday, March 29, 2013

Downloading and configuring jetty9

More info is available here http://www.eclipse.org/jetty/documentation/current/jetty-runner.html
http://linuxdatum.info/web-server/howto-install-php-fpm-with-nginx-on-ubuntu-12-04-lts
NgInx server install with FastCGI check  /etc/resolv.conf , /etc/hostname, /etc/hosts check for hostname in (127.0.1.1)

===Downloading and configuring jetty9==

search.maven.org for "jetty-runner"

wget -O ~/programs/lib/jetty-runner-9.0.0.v20130308.jar http://search.maven.org/remotecontent?filepath=org/eclipse/jetty/jetty-runner/9.0.0.v20130308/jetty-runner-9.0.0.v20130308.jar

rm ~/programs/jetty-9.jar
ln -s -T ~/programs/lib/jetty-runner-9.0.0.v20130308.jar ~/programs/jetty-9.jar


==in another Window RUN war from cmdLine
cd ~/projects-try
mvn archetype:create -DarchetypeGroupId=org.apache.maven.archetypes -DarchetypeArtifactId=maven-archetype-webapp -DarchetypeVersion=1.0 -DgroupId=com.example -DartifactId=ccaApp -Dversion=1.0-SNAPSHOT

cd ccaApp
mvn war:inplace

java -jar ~/programs/jetty-9.jar --port 9090  ~/projects-try/ccaApp/src/main/webapp or add this to pom.xml and run as mvn -Djetty.port=9090 jetty:run ===============



    ccaApp

  
   
   
   
  org.eclipse.jetty
  jetty-maven-plugin
  9.0.0.v20130308
  
  
    10
    
      /j9090
    
  


  




test using http://http://rpradeshik:9090/
===========

Working with Sencha for ExtJs


=== download Sencha tool here http://www.sencha.com/products/sencha-cmd
stored in
Linux //samba-share/downloads/sencha/SenchaCmd-3.1.0.256-linux.run.zip
Window //samba-share/downloads/sencha/SenchaCmd-3.1.0.256-windows.exe.zip

== download ExtJs SDK from http://www.sencha.com/products/extjs/
http://www.sencha.com/products/extjs/download/ext-js-4.2.0/2142
Zip Sorted in //samba-share/downloads/sencha/extjs_420_build_2142/SenchaCmd-3.1.0.256-windows.exe.zip

==help install URL == http://stackoverflow.com/questions/14730977/build-failed-in-sencha-cmd
install ruby from http://rubyinstaller.org/
or sudo apt-get install ruby

==put in bashrc
export EXTJS_SDK=~/programs/sencha-cmd/ext-4.2.0.663
export SENCHA_HOME=$SENCHA_CMD_3.1.0.256
PATH=...$SENCHA_HOME/bin:$PATH

ll $SENCHA_HOME/sencha.cfg
echo "skip.sass=1" == $SENCHA_HOME/sencha.cfg
echo "skip.slice=1" == $SENCHA_HOME/sencha.cfg

test Sencha cmd as
==sencha

create new app as follows
cd ~/projects-try

sencha -sdk $EXTJS_SDK generate app CCAProject ~/projects-try/ccaApp

== to build app first cd to it and then build
cd ~/projects-try/ccaApp

echo "skip.sass=1" ext/cmd/sencha.cfg
echo "skip.slice=1" ext/cmd/sencha.cfg

sencha app build

Tuesday, January 1, 2013

alternate to oracle dbms output



CREATE TABLE mylog_t
  (
    "TIMESTAMP" DATE NOT NULL ENABLE,
    "LOG_TEXT" VARCHAR2(500 BYTE)
  );

  CREATE or replace PROCEDURE mylog(a_log_text       mylog_t.log_text%TYPE)
   IS
      PRAGMA AUTONOMOUS_TRANSACTION;
   BEGIN
      INSERT INTO mylog_t (timestamp,log_text)VALUES (SYSTIMESTAMP,a_log_text);
      COMMIT;
   END mylog;



shamelessly copied from http://berxblog.blogspot.com/2009/01/pipelined-function-vs-dbmsoutput.html

create or replace
function dummy
return DBMS_DEBUG_VC2COLL
PIPELINED -- NOTE the pipelined keyword
is
begin
pipe row (to_char(sysdate, 'DD-MON-YYYY HH24:MI:SS' ));
dbms_lock.sleep(15);
pipe row (to_char(sysdate, 'DD-MON-YYYY HH24:MI:SS' ));
return;
end;
/
Make sure you set the arraysize of SQL*PLUS (or whatever) small enough, otherwise you will get a bunch of results at once, not when they occure.
set arraysize 1
select * from table(dummy());
gives
COLUMN_VALUE
--------------------
20-JAN-2009 14:24:17
and after 15 sec.
20-JAN-2009 14:24:32

Wednesday, November 28, 2012

git and eclipse

Git ref 
to import a project into git from say CVS
cd ~/projects/camscapa-project/
mkdir CAMS2
cp -R ../cams2-project/CAMS2/* CAMS2
cd CAMS2

mvn clean

for d in `find -type d -name 'CVS'`; do rm -rf $d; done
for d in `find -type d -name '.settings'`; do rm -rf $d; done
for d in `find -type f -name '.project'`; do rm -rf $d; done

git init
git add .
git commit -a -m 'all commit first time'
cd ..
git clone --bare ./CAMS2 ~/z-git-repos/CAMS2.git
mv CAMS2 CAMS2_after_init
git clone git://rpradeshik/CAMS2.git
cd CAMS2
pwd

# add gitigone with target classes etc.,

git add .
git commit -m 'ingone file' .
git push

To import in eclipse

  1. Open "Git Perspective", do "Add existing local repo"  and choose "~/projects/camscapa-project/CAMS2" 
  2. RClick on CAMS2 node and select "Import Projects"
  3. in 3 radio options choose "Import as general Project", then "CAMS2", finish
  4. This should bring CAMS2 as project into workspace, goto java perspective
  5. to import single modules inside CAMS2 say "cams-dri" RClick and do maven import
  6. Make sure maven 304 is in eclipse installation


Wednesday, October 24, 2012

Maven and Linux Tips

java and C++ interface easily http://code.google.com/p/javacpp/
benchmark ref http://benchmarksgame.alioth.debian.org/
Standard Deviation http://www.mathsisfun.com/data/standard-deviation.html

Oracle trace settings ====

SQL> ALTER system SET EVENTS ’1652 TRACE NAME ERRORSTACK LEVEL 3′;
It will write to the alert.log
Tue Jul 21 11:04:45 2009
Errors in file /u01/admin/TESTDB/udump/testdb_ora_17682588.trc:
ORA-1652: unable to extend temp segment by 128 in tablespace TEMP

jar classifier and Profile usage, nice one

http://www.linuxtutorialblog.com/post/tutorial-conditions-in-bash-scripting-if-statements


To update version of maven for portal project
Manually update express/portal/pom.xml

mvn versions:update-child-modules -DgenerateBackupPoms=false
OR
mvn versions:set -DnewVersion=1.3-SNAPSHOT
mvn versions:commit