The best place to ask programming/development questions, imo. UPDATE: stackoverflow is the *worst* place to *ask* questions (if your first question/comment doesn't get any up-rating/response, then u can't ask anymore questions--ridiculously unrealistic), but a great reference for finding answers.

My Music (Nickleus)

20120227

jboss jsf login example catalina container managed security j_security_check web.xml login-config auth-method form

some relevant code from web.xml:
<security-constraint>
<display-name>Web Security</display-name>
<web-resource-collection>
<web-resource-name>rich</web-resource-name>
<url-pattern>/pages/*</url-pattern>
</web-resource-collection>
<auth-constraint>
<role-name>Users</role-name>
<role-name>Administrators</role-name>
</auth-constraint>
</security-constraint>
<security-constraint>
<display-name>Admin Web Security</display-name>
<web-resource-collection>
<web-resource-name>rich_admin</web-resource-name>
<url-pattern>/adm/*</url-pattern>
</web-resource-collection>
<auth-constraint>
<role-name>Administrators</role-name>
</auth-constraint>
</security-constraint>
<login-config>
<auth-method>FORM</auth-method>
<realm-name>myrealmLdapAuthenticator</realm-name>
<form-login-config>
<form-login-page>/login.jsf</form-login-page>
<form-error-page>/login.jsf</form-error-page>
</form-login-config>
</login-config>
<security-role>
<role-name>Users</role-name>
</security-role>
<security-role>
<role-name>Administrators</role-name>
</security-role>

the security-role role-names are defined in our LDAP server.

the most relevant line from LoginBean.java:
FacesContext.getCurrentInstance().getExternalContext().redirect("/pages/j_security_check?j_username="+username+"&j_password="+password); 

WebAuthentication webA = new WebAuthentication();
webA.login(username, password);


 this is done when backend authentication, plus anything you need to check/set before you welcome the user into the application, is complete. note that LoginBean.java is declared with request scope in faces-config.xml and the class itself has the annotation @org.ajax4jsf.model.KeepAlive
this redirect should be run on a server using https because it is a GET request.

and some code from login.xhtml:

<h:messages showDetail="false" showSummary="true" layout="list" styleClass="rich-messages-label" /> 
<h:form id="checkPassword">
<h:panelGrid columns="2">
<h:outputLabel for="username" value="#{loginBean.getPropertyValue('label.username')}" />
<h:inputText required="true" id="username" value="#{loginBean.username}" />
<h:outputLabel for="password" value="#{loginBean.getPropertyValue('label.password')}" />
<h:inputSecret required="true" id="password" value="#{loginBean.password}" />
</h:panelGrid>
<h:commandButton value="#{loginBean.getPropertyValue('label.login')}" action="#{loginBean.login}" disabled="#{loginBean.mustChangePassword}" reRender="checkPassword,authenticate" />
</h:form> 
<h:form id="authenticate" rendered="#{loginBean.mustChangePassword}">
<h:panelGrid columns="2">
<h:outputLabel for="currentpassword" value="#{loginBean.getPropertyValue('label.passwordCurrent')}" />
<h:inputSecret required="true" id="currentpassword" value="#{loginBean.password}" />
<h:outputLabel for="newpassword" value="#{loginBean.getPropertyValue('label.passwordNew')}" />
<h:inputSecret required="true" id="newpassword" value="#{loginBean.newPassword}" />
<h:outputLabel for="confirmnewpassword" value="#{loginBean.getPropertyValue('label.passwordConfirmNew')}" />
<h:inputSecret required="true" id="confirmnewpassword" value="#{loginBean.confirmNewPassword}" />
</h:panelGrid>
<h:commandButton value="#{loginBean.getPropertyValue('label.save')}" action="#{loginBean.authenticate}" />
</h:form>

20120225

what's the difference between oracle's expdp full database backup (full=y) and not full (default)

e.g. if you are using scott, a non-full dump/export will only dump scott's tables. a full backup will dump scott's tables, but also system tables, etc.


-rw-r----- 1 oracle oinstall  318050304 2012-02-24 09:44 full_11g.dmp
-rw-r----- 1 oracle oinstall  260571136 2012-02-24 09:53 not_full_11g.dmp

20120222

how to change oracle table tablespace and rebuild unusable indexes

after installing oracle 11g on ubuntu 11.10, importing (using impdp) from an oracle 10g database, i noticed that some of the tables were in the SYSTEM tablespace instead of the USER tablespace so i wanted to move them all to the same tablespace. you do it in 2 parts, first move, then rebuild indexes. here's how i did it:


* log in as sys:

su - oracle 
cd /u01/app/oracle/product/11.1.0/db_1/bin 
./sqlplus sys as sysdba


* now, to find out which tables were in the SYSTEM tablespace:
select table_name from dba_tables where owner = 'SCOTT' and tablespace_name = 'SYSTEM';
let's say the query returns:
TABLEX 
TABLEY 
TABLEZ
* and to find their index names:
select index_name from dba_indexes where STATUS='UNUSABLE';
(this will technically give you all the unusable index names, or you can narrow your search to the 3 tables above if you like, by modifying the where clause, but why wouldn't you want to see if there were additional unusable indexes? =))


let's say the query returns:

PK_TABLEX 
PK_TABLEY 
PK_TABLEZ
(in my table i had all kinds of different looking index names, e.g.: SYS_C0014766, TABLEX_PK, IX_HTTPMSGFM_MEMBER_LDAP_ID, AGREEMENTNO_UNIQUE, etc -- who the hell named these so inconsistently?)



* move them to USER tablespace, then rebuild the unusable index:
alter table SCOTT.TABLEX move tablespace USERS;alter index SCOTT.TABLEX rebuild tablespace USERS;
alter table SCOTT.TABLEY move tablespace USERS;alter index SCOTT.TABLEY rebuild tablespace USERS;
alter table SCOTT.TABLEZ move tablespace USERS;alter index SCOTT.TABLEZ rebuild tablespace USERS;

sources:
http://www.dba-oracle.com/t_alter_table_move_index_constraint.htm
http://www.databasejournal.com/features/oracle/article.php/3735286/Oracle-Unusable-Indexes.htm

how to give oracle user home directory and bash history

after installing oracle 11g on ubuntu 11.10, i'm left with an oracle user that doesnt have a home and who forgets all his command line history. to fix this:
* as a normal user (not oracle) with sudo privileges:
sudo mkdir /home/oracle
sudo chown oracle:oinstall /home/oracle
su - oracle
touch .bash_history

20120221

workaround for oracle impdp ORA-39014 ORA-39029 ORA-31672 prematurely exited/terminated


i've been trying for the last 24 hours to import a dump/dmp file created with expdp in oracle 10g on ubuntu 8 into a new server on ubuntu 11.10 with oracle 11g enterprise, using this import statement:
oracle@mydbserver:/u01/app/oracle/product/11.1.0/db_1/bin$ ./impdp scott@MYDB PARFILE=/home/me/Downloads/params.txt


but it would run for a little while then throw this error:
ORA-39014: One or more workers have prematurely exited.
ORA-39029: worker 1 with process name "DW01" prematurely terminated
ORA-31672: Worker process DW01 died unexpectedly.


when i increased the PARALLEL number (e.g. to 4) it got past a place it was stuck at, and got somewhat further.


params.txt looks like this:
DIRECTORY=data_pump_dir
DUMPFILE=expdat_scott_20120216.dmp
PARALLEL=4
TABLE_EXISTS_ACTION=REPLACE




another workaround is to import tables one by one using the INCLUDE parameter, so e.g. add this line to the param file (i.e. params.txt):
INCLUDE=TABLE:"IN ('TABLE1')"


then simply rerun the impdp command (while in the bin directory):
./impdp scott@MYDB PARFILE=/home/me/Downloads/params.txt


if somehow you know there is a particular table that is causing trouble you can use the EXCLUDE parameter instead and simply exclude that one table:
EXCLUDE=TABLE:"IN ('MY_CORRUPT_TABLE1')"


our dmp file was made while the database was running and thus one of the tables got corrupted, or was exported in the middle of a process so that's why we had problems importing it into the new database. i found this out by doing this:
cat /u01/app/oracle/admin/mydb/dpdump/import.log


which showed me the name of the import job i was running:
SCOTT.SYS_IMPORT_FULL_01


so i ran this:
./impdp ATTACH=SCOTT.SYS_IMPORT_FULL_01


and it showed me which table was the last table to be attempted imported:
Worker 1 Status:
  Process Name: DW01
  State: UNDEFINED                    
  Object Schema: SCOTT
  Object Name: MY_CORRUPT_TABLE1
  Object Type: SCHEMA_EXPORT/TABLE/TABLE_DATA
  Completed Objects: 4


so i knew i should exclude that table in the import.


sources:
https://forums.oracle.com/forums/thread.jspa?threadID=907984 (thanks to user https://forums.oracle.com/forums/profile.jspa?userID=696918 )


p.s. in some previous desperate attempts to get things to work (prior to the instructions above), i also ran the following as sys:

alter system set open_cursors=1024 scope=spfile;
alter system set "_optimizer_cost_based_transformation"=off;
commit;


i cant say for sure whether this was necessary or not. i'm sorry, i know, that sucks, but if the above fails then consider running these alter statements, then trying again.

where is the default oracle impdp log file location?

in my oracle 11g installation on ubuntu 11.10 it is:
/u01/app/oracle/admin/mydatabase/dpdump/import.log

i found this folder by running this query:
SELECT directory_path FROM dba_directories WHERE directory_name = 'DATA_PUMP_DIR';

20120220

how to exclude multiple files when importing with impdp for oracle xe

su oracle
cd /usr/lib/oracle/xe/app/oracle/product/10.2.0/server/bin
nano -w params.txt

give it the following content, e.g.:

DIRECTORY=data_pump_dir
DUMPFILE=my_expdat.dmp
EXCLUDE=TABLE:"IN ('TABLE1,TABLE2')"
TABLE_EXISTS_ACTION=REPLACE

save it, then run impdp like this:
./impdp system@MYDATABASE PARFILE=params.txt


source: http://www.orafaq.com/forum/t/174436/0/

20120218

sox FAIL formats: no handler for file extension `mp3'

if you're trying to work with mp3 files and sox wont play, run this in a terminal:
sudo apt-get install libsox-fmt-mp3

how to quickly get the most updated (svn) version of hydrogen for ubuntu 11.10

i've noticed a couple of bugs in hydrogen 0.9.5:
* metronome indiscriminately turning on/off during playback and export
* incorrect error message when exporting, that it failed when it didnt fail

there might be more bugs, but the 2 bugs above have at least been fixed. to get the latest and most up-to-date version of hydrogen do this in a terminal:
sudo add-apt-repository ppa:kxstudio-team/hydrogen
sudo apt-get update
sudo apt-get install hydrogen-svn

ref:
http://www.hydrogen-music.org/hcms/node/1917
http://hydrogen.popez.org/hcms/node/1868
https://launchpad.net/~kxstudio-team/+archive/hydrogen/

20120217

how to install raid on ubuntu 11.10

*you need the server edition*--the normal desktop version doesnt have raid options in the manual partitioning interface.

then follow this:
https://help.ubuntu.com/community/Installation/SoftwareRAID

then after choose "configure software raid"

20120216

how to backup the oracle 10 database using expdp

to backup the database using expdp:
cd ~/path/to/oracle/product/10.2.0/db_1/bin
./sqlplus "sys/any as sysdba"
SQL> startup;
SQL> exit;
./lsnrctl start
./sqlplus "sys/any as sysdba"

if you already havent done so:
SQL> grant read, write on directory DATA_PUMP_DIR to scott;


now run:
SQL> host


$ ./expdp scott/mypassword DIRECTORY=DATA_PUMP_DIR DUMPFILE=expdat_scott.dmp

the backup dmp file will be here:
/path/to/oracle/product/10.2.0/db_1/rdbms/log/

which is the default value/location for DATA_PUMP_DIR

you can double check it in sqlplus like this:
SQL> 
SELECT directory_path FROM dba_directories WHERE directory_name = 'DATA_PUMP_DIR';

source: http://www.orafaq.com/wiki/Datapump (external link)

how to delete oracle 10 archive log redo files

when trying to connect to my database i got this error:
oracle: ORA-00257: archiver error. Connect internal only, until freed.

source: http://www.dba-oracle.com/sf_ora_00257_archiver_error_connect_internal_only_until_freed.htm

to double check the archivelog redo space:
cd ~/path/to/oracle/product/10.2.0/db_1/bin
./sqlplus "sys/any as sysdba"
SQL> archive log list;
SQL> show parameter db_recovery_file_dest;
SQL> SELECT * FROM V$RECOVERY_FILE_DEST;

source: https://forums.oracle.com/forums/thread.jspa?threadID=519282 (external link)

in another terminal:
cd ~/path/to/oracle/product/10.2.0/db_1/bin
./rman target / nocatalog

RMAN > delete archivelog all;

source: http://oracle-abc.wikidot.com/cold-backup-with-rman (external link)

it seemed as if things werent quite deleted so i ran this:
RMAN > run {
allocate channel t1 type disk;
backup archivelog all delete input format '/home/oracle/arch_NaVu_%s';
release channel t1;
}

source: http://www.shutdownabort.com/errors/ORA-19809.php

20120208

samsung galaxy gio GT-S5660 mobile cell phone android 2.3.3 how to transfer call / set someone over

when you get a call you want to set over to someone else's telephone (transfer) push the "keypad" button, then type:
**the_new_number#

e.g. to transfer the incoming call to 22 22 22 22, type:
**22222222#

20120206

ubuntu 11.10 configure multiple desktops, laptop to external monitor with hdmi cable

in ubuntu 11.10 unity, in order to connect my laptop to an LG flatron L246WH monitor that i've rotated to the left so it stands tall, on its side, you have to first enable ubuntu's fglrx driver using jockey-gtk. then open system settings > displays, then select the goldstar company ltd 24" monitor and choose rotation: clockwise. (note: these settings get saved in ~/.config/monitors.xml)

then every time you switch between single and dual desktop mode you have to (at least when switching back to dual mode) go into displays again and set it up.


to automate this process, i made a script i use in a terminal to quickly and easily switch between single and dual desktop mode, called xto:
http://ideone.com/AhmWC

put the script here:
~/

make sure you set it to executable:
chmod +x ~/xto

to set system to dual mode:
cd./xto -m


to set system to single desktop mode:
cd./xto -s


below are the configuration files for single and desktop modes that the script copies to set things up, depending on the command line arg you send to xto.

xorg.single.confhttp://ideone.com/CkIB2
xorg.dual.confhttp://ideone.com/sU5XO
monitors.single.confhttp://ideone.com/XFv5l
monitors.dual.confhttp://ideone.com/2tzhF

place these files in ~/Documents