• maven and ear packaging

    okay, i just needed to place some files in the ear file.

    solution:
    -create src/main/application
    -anything you place in that folder will be included in the ear file
    -DO NOT USE ’src/main/resources’, it will not get into your ear file

    -thanks to cata

  • Java, the IP address and reverse proxy

    Okay so there is the getRemoteAddr() method of HttpServletRequest, but when you’re using a reverse proxy that won’t work and it will just return 127.0.0.1

    If so, look for the header ‘X-Forwarded-For‘ of your request object. (request.getHeader("X-Forwarded-For")).
    But this will return null if using non-reverse proxy. ;)

    thanks to POLONKAI Gergely

  • Linux: finding files given text within…

    after setting up the data source for my jbossportal,
    i kinda need to play around with its layout and theme.
    so i read the documentation,
    but it was lacking on the files and its directories where those configurations can be found.

    thanks to Nap:), he gave me a way of finding those with

    find . -name ‘*.xml’ | xargs grep “phalanx”

    first part, find . -name '*.xml' does find all xml files
    second part, xargs which tells to operate on each of those files
    finally , grep "phalanx" which text contained within the files i’m looking for.

    after it returned the files i needed,
    did the configuration and played with the layout of jbossportal.

    oh, by the way, the output is kinda like this…

    ./server/default/deploy/jboss-portal.sar/portal-core.war/WEB-INF/portal-layouts.xml: phalanx
    ./server/default/deploy/jboss-portal.sar/portal-core.war/WEB-INF/portal-layouts.xml: /phalanx/index.jsp
    ./server/default/deploy/jboss-portal.sar/portal-core.war/WEB-INF/portal-layouts.xml: /phalanx/index.jsp
    ./server/default/deploy/jboss-portal.sar/portal-core.war/WEB-INF/portal-layouts.xml: /layouts/phalanx/maximized.jsp
    ./server/default/deploy/jboss-portal.sar/portal-core.war/WEB-INF/portal-layouts.xml: /layouts/phalanx/maximized.jsp
    ./server/default/deploy/jboss-portal.sar/portal-core.war/WEB-INF/portal-themes.xml: nphalanx
    ./server/default/deploy/jboss-portal.sar/portal-core.war/WEB-INF/portal-themes.xml:
    ./server/default/deploy/jboss-portal.sar/portal-core.war/WEB-INF/portal-themes.xml:
    ./server/default/deploy/jboss-portal.sar/conf/data/default-object.xml: phalanx
    ./server/default/deploy/jboss-portal.sar/conf/data/default-object.xml: phalanx
    ./server/default/deploy/jboss-portal.sar/META-INF/jboss-service.xml: phalanx

  • Oracle: Could not create another database? Create another data source.

    I needed to set-up another data source using the same database server

    —–

    So using the SQL Plus, i created a user and granted privileges for it.

    Creating User
    SQL> create user username identified by password default tablespace user_tablespace temporary tablespace temp_tablespace;
    e.g.
    SQL> create user wpsdbusr identified by password default tablespace users temporary tablespace temp;

    Granting Privileges
    SQL> grant connect, resource to username;
    e.g.
    SQL> grant connect, resource to wpsdbusr;

    now i have another data source for my project using the same database.

  • Transposing Records into One Field

    As they say in Exist, There’s always a better way.

    What I Did…
    performed a loop for each record in my collection to retrieve another collection using a particular Id in the record
    and placing the retrieved collection to be part of the record.

    The Effect…
    my screen populates very slow

    The Solution…
    from backend, transpose those collection being retrieved to be just one field so you need not to loop in your code

    Click Here…

    - thanks to ken and cata

  • Eclipse: build-error but seems everything is set properly

    Been using Eclipse for two years now.

    So I have this project with a modular setup where all model class is in one folder while the webapp is in another folder.

    Okay, so i did check everything. It seems everything is set properly.

    My project do get build in maven, all build path and variables are set properly.

    So how did I solve my error? ALL I needed to do was to PROJECT >> CLEAN.

    –thanks VENZ :)

  • Debugging in Eclipse, calling shell scripts

    Background:
    i’m using Ubuntu, my Eclipse was installed via apt-get
    i have Oracle installed under ‘oracle’ profile
    i run and debug my program through Eclipse

    Issue:
    attempt to run sqlldr which is called from the webapp results to an error/sqlldr exit code 3.

    Solution:
    run the webapp externally, don’t use Eclipse when running the webapp(since it was installed via apt-get and uses different permissions/ownership)
    or have a manual installation of Eclipse and place it in your profile’s home folder if you want to use Eclipse for running your webapp.

  • Installing Oracle 10g in Ubuntu 7.10 (Gutsy Gibbon)

    This doc isn’t yet perfect, but it would help.

    1. Requirements
    Your linux swap is set to 2GB
    You have the Oracle 10g RC2 installer for Linux

    2. Setting Ubuntu

    2.1 Install required libraries

    Open the Synaptic Package Manager (click System –> Administration)
    Click on Settings –> Repositories
    Click all the checkbox(main, universe, restricted, multiverse) found in the “Ubuntu Software” Tab
    Click the Close button
    Click the Reload button
    Close the Synaptic Package Manager

    Open a terminal
    sudo apt-get install gcc make binutils libmotif3 lesstif2 rpm libaio1 zip build-essential rpm lesstif2-dev alien -y

    2.2 Users/groups Oracle’s creation

    sudo userdel nobody
    sudo groupadd oinstall
    sudo groupadd dba
    sudo groupadd nobody
    sudo useradd -g oinstall -G dba -p passwd -d /home/oracle -m oracle -s /bin/bash
    sudo useradd -g nobody nobody
    sudo passwd oracle

    2.3 Deceive Installer that you are using RedHat

    sudo ln -s /usr/bin/awk /bin/awk
    sudo ln -s /usr/bin/rpm /bin/rpm
    sudo ln -s /usr/bin/basename /bin/basename
    sudo ln -s /etc /etc/rc.d
    sudo touch /etc/redhat-release
    sudo chmod 666 /etc/redhat-release
    sudo echo “Red Hat Linux release 3.0 (drupal)” > /etc/redhat-release

    sudo mkdir -p /u01/app/oracle
    sudo mkdir -p /u02/oradata

    sudo mkdir /data/oracle -p
    sudo mkdir /data/oracle/10g

    2.3.1 mode & ownership modification

    sudo chown -R oracle:oinstall /u01 /u02
    sudo chmod -R 775 /u01 /u02

    sudo chown -R oracle:oinstall /data/oracle
    sudo chmod -R 775 /data/oracle

    2.4 Configurations

    2.4.1 Configuring Kernel Parameters

    Oracle instances consume memory and CPU resources on servers, and Ubuntu doesn’t come configured to allow the quantity of resources to be consumed that we’ll end up needing. To fix that, we therefore have to specify a set of new Kernerl Parameters which the operating system should use. That’s easily done by editing one file, like so:

    sudo gedit /etc/sysctl.conf

    You can substitute in the name of your preferred text editor instead of gedit if you like, but whatever editor you use, you now need to add these lines to the end of that file:

    kernel.shmall = 2097152
    kernel.shmmax = 2147483648
    kernel.shmmni = 4096
    kernel.sem = 250 32000 100 128
    fs.file-max = 65536
    net.ipv4.ip_local_port_range = 1024 65000

    Don’t make any typing mistakes (it’s best to cut-and-paste from the above, really) and make sure you leave a blank line after the last line of the file (otherwise, the last setting tends not to get read and implemented at all). Normally, the sysctl.conf file is only read at each machine startup, so you’d have to reboot the server to implement the changes, but you can force the server to re-read the file without need for a reboot by now issuing the command:

    sudo /sbin/sysctl -p

    2.4.2 Security Limits

    Finally, we need to set some new security limits for the system, too. Do that by issuing this command:

    sudo gedit /etc/security/limits.conf

    ..and then appending to the end of that file these new values:

    * soft nproc 2047
    * hard nproc 16384
    * soft nofile 1024
    * hard nofile 65536

    2.4.3 Setting Up Environment

    sudo mkdir /home/oracle
    sudo chown oracle:oinstall /home/oracle -R
    sudo gedit /home/oracle/.bashrc

    ORACLE_HOME=/data/oracle/10g/
    ORACLE_SID=orcl
    ORATAB=/etc/oratab
    ORACLE_HOME_LISTNER=$ORACLE_BASE
    ORACLE_BASE=$ORACLE_HOME

    export ORACLE_BASE ORACLE_SID ORATAB ORACLE_HOME ORACLE_HOME_LISTNER

    PATH=${PATH}:$ORACLE_HOME/bin

    Make sure to leave a blank line after the last of those lines.

    3. Installing Oracle

    3.1 preparing the installer

    copy the oracle installer to /home/oracle
    sudo chown oracle:oinstall /home/oracle/*.zip
    sudo chmod 775 /home/oracle/*.zip

    3.2 running the installer
    logout of ubuntu
    login back as oracle

    open a console
    unzip the file
    cd /home/oracle/database

    ./runInstaller -ignoreprereq

    3.3 Editing Oratab

    You should log out as the oracle user, and log yourself back on as yourself (that is, the user you created during the Ubuntu install). That’s a full logout and logon, not merely the use of the su command to become another account, by the way.

    Once you’ve done that, you should edit the contents of the /etc/oratab file in the text editor of your choice. You’ll have to have root privileges to edit a file in the /etc directory, of course, and that means it will be necessary to issue a command such as:

    sudo gedit /etc/oratab

    You’ll find at the moment that the file contains this one line (apart from all the commented-out ones, that is):

    orcl:/oracle/10g:N

    4. Starting the listener and the database

    su - oracle
    Password: enter your sudo password
    [oracle] $ lsnrctl start

    LSNRCTL for Linux: Version 10.2.0.1.0 - Production on 19-JAN-2006 13:55:02

    Copyright (c) 1991, 2005, Oracle. All rights reserved.

    Starting /u01/app/oracle/oracle/product/10.2.0/db_1//bin/tnslsnr: please wait…

    TNSLSNR for Linux: Version 10.2.0.1.0 - Production
    System parameter file is /u01/app/oracle/oracle/product/10.2.0/db_1/network/admi n/listener.ora
    Log messages written to /u01/app/oracle/oracle/product/10.2.0/db_1/network/log/l istener.log
    Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1)))
    Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=localhost.localdomain)(P ORT=1521)))

    Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1)))
    STATUS of the LISTENER
    ————————
    Alias LISTENER
    Version TNSLSNR for Linux: Version 10.2.0.1.0 - Production
    Start Date 19-JAN-2006 13:55:04
    Uptime 0 days 0 hr. 0 min. 0 sec
    Trace Level off
    Security ON: Local OS Authentication
    SNMP OFF
    Listener Parameter File /u01/app/oracle/oracle/product/10.2.0/db_1/network/adm in/listener.ora
    Listener Log File /u01/app/oracle/oracle/product/10.2.0/db_1/network/log /listener.log
    Listening Endpoints Summary…
    (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1)))
    (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=localhost.localdomain)(PORT=1521)))
    Services Summary…
    Service “PLSExtProc” has 1 instance(s).
    Instance “PLSExtProc”, status UNKNOWN, has 1 handler(s) for this service…
    The command completed successfully

    [oracle] $ sqlplus connect as sysdba

    SQL*Plus: Release 10.2.0.1.0 - Production on Thu Jan 19 13:55:21 2006

    Copyright (c) 1982, 2005, Oracle. All rights reserved.

    Enter password: enter the DB password
    Connected to an idle instance.

    SQL> startup
    ORACLE instance started.

    Total System Global Area 285212672 bytes
    Fixed Size 1218992 bytes
    Variable Size 92276304 bytes
    Database Buffers 188743680 bytes
    Redo Buffers 2973696 bytes
    Database mounted.
    Database opened.
    SQL> exit

    —-

    Credits:

    Much of the content of this document came from dizwell’s site and few of the steps were updated for the Ubuntu 7.10 compatibility. And thanks to those other sites that makes our life easier. (http://www.zjant.com/index.php/date/2007/04/ , http://www.supinfo-projects.com/en/2006/oracle%5Fon%5Fubuntu/3/)

  • Set Encoding in Eclipse

    Problem was, when i check out our project, all ‘»’ characters were being replaced with ‘�’.
    I didn’t knew this was happening until Ken told me.

    Ken figured out that it was an encoding issue.
    I was using Eclipse 3.2 and Ken was using 3.3.
    So when i went to my Eclipse Edit menu –> Set Encoding.
    My eclipse default was UTF-8.

    So I went to see what was Ken’s and it was ‘ISO-8859-1′ encoding

    Oh well, need to restore those characters…

  • Dual Boot Issues: Reinstalled Windows

    My windows did get a virus. Did try to remove it, a system restore, but none worked. Last resort… REINSTALL

    After re-installation I needed my GRUB(the that lets you choose your operating system when booting) back.

    1. Boot Ubuntu Live CD
    2. open a terminal, if your in GUI mode
    3. run #sudo grub
    4. find your grub in preparation for the root command execute find /boot/grub/stage1
    5. execute root (<device,partition>), if step 4 returns (hd0, 5) you do root (hd0, 5)
    6. execute setup (<device>), following step 5 it would be setup (hd0)
    7. execute quit, then reboot.

    I did find some help through google. But Venz Hua has better document and I’m placing it here. :D