The best place to *find* answers to programming/development questions, imo, however it's 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 again, a great reference for *finding* answers.

My Music (Nickleus)

20120530

how to get rid of "Multiple annotations found at this line: Syntax error in EL, Expression must be a value expression but is a method" in jsf/xhtml files in eclipse indigo


with my minimal eclipse java ee configuration:

which eclipse plugin(s) to install in order to get F3 "go to backing bean source" functionality in jsf/xhtmlhow to configure eclipse to run jboss in debug mode using jsf 1.2, richfaces 3.3, seam 2 and ejb3


in jsf/xhtml files i get lots of errors like this:
Multiple annotations found at this line:
- Syntax error in EL
- Expression must be a value expression but is a method

to get rid of these annoying errors, that really aren't errors, do this in eclipse:
window > preferences > web > javaserver faces tools > validation > uncheck Validate EL on Build/Run Validation

then right click on your project and choose Validate. now the errors should be gone.

thanks to BalusC: http://stackoverflow.com/questions/1790749/jsp-el-expression-language-causing-problems-in-eclipse

Exception sending context initialized event to listener instance of class org.jboss.seam.servlet.SeamListener


before correctly configuring my jboss server in eclipse, i would get errors like:
"Cannot load package Dinfo for org.jboss.seam.web"
and
>30 May 2012 09:06:59,752  INFO     javax.servlet.ServletContextListener                                                       Welcome to Seam 2.1.0.SP1
ERROR    org.apache.catalina.core.ContainerBase.[jboss.web].[localhost].[/]                         Exception sending context initialized event to listener instance of class org.jboss.seam.servlet.SeamListener
java.lang.OutOfMemoryError: PermGen space
at org.jboss.seam.servlet.SeamListener.contextInitialized(SeamListener.java:34)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3856)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4361)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:790)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:770)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:553)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:296)
at org.jboss.mx.server.RawDynamicInvoker.invoke(RawDynamicInvoker.java:164)
at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
at org.apache.catalina.core.StandardContext.init(StandardContext.java:5312)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:296)
at org.jboss.mx.server.RawDynamicInvoker.invoke(RawDynamicInvoker.java:164)
at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
at org.jboss.web.tomcat.service.TomcatDeployer.performDeployInternal(TomcatDeployer.java:301)
at org.jboss.web.tomcat.service.TomcatDeployer.performDeploy(TomcatDeployer.java:104)
at org.jboss.web.AbstractWebDeployer.start(AbstractWebDeployer.java:375)
at org.jboss.web.WebModule.startModule(WebModule.java:83)
at org.jboss.web.WebModule.startService(WebModule.java:61)
at org.jboss.system.ServiceMBeanSupport.jbossInternalStart(ServiceMBeanSupport.java:289)
at org.jboss.system.ServiceMBeanSupport.jbossInternalLifecycle(ServiceMBeanSupport.java:245)
at sun.reflect.GeneratedMethodAccessor7.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
>30 May 2012 09:07:01,672  ERROR    org.apache.catalina.core.StandardContext                                                   Error listenerStart
>30 May 2012 09:07:01,672  ERROR    org.apache.catalina.core.StandardContext                                                   Context [] startup failed due to previous errors
>30 May 2012 09:07:03,197  ERROR    org.apache.catalina.core.ContainerBase.[jboss.web].[localhost].[/]                         Exception sending context destroyed event to listener instance of class org.jboss.seam.servlet.SeamListener
>30 May 2012 09:07:04,687  ERROR    org.apache.catalina.core.StandardContext                                                   Exception during cleanup after start failed
>30 May 2012 09:07:06,200  ERROR    org.apache.tomcat.util.modeler.BaseModelMBean                                               Exception invoking method addChild
>30 May 2012 09:07:06,909  ERROR    org.apache.tomcat.util.modeler.BaseModelMBean                                               Exception invoking method init


how to configure eclipse to run jboss in debug mode using jsf 1.2, richfaces 3.3, seam 2 and ejb3

i'm developing a java ee project in eclipse indigo using the following technologies:
jsf 1.2
richfaces 3.3
seam 2
a mix of ejb2 and ejb3
jboss trinity 4.2.2.GA
sun java 1.6.0_26 (64-bit)
ubuntu linux 12.04

NOTE: you do not have to install jboss tools or any additional plugins after a clean install of eclipse in order to debug your project on jboss in eclipse, however you might want to install additional useful plugins like JRebel and JBoss JSF support

all you have to do in order to start your server in debug mode in eclipse is to configure your jboss server in eclipse:
find the Servers tab
new > server > jboss v4.2 > finish

(
UPDATE for Eclipse Juno

new > server > jboss v4.2 > next

set the Application Server Directory value:
/your_server_root/appservers/jboss
e.g.
/usr/jboss

Finish

)

now double click your new server JBoss v4.2 at localhost.
i increased the Timeouts > Start (in seconds) from 50 to 120 (just in case) and the Stop (in seconds) from 15 to 30.

i set Server Properties > Address to 0.0.0.0 so other people on the network can connect to my server.

set the correct port, e.g. for my project i use8080

if you've installed the JRebel plugin, then check the box that says "Enable JRebel agent"

click the Runtime Environment link and set the Application Server Directory to your jboss home, e.g. mine is /usr/jboss

click the Open launch configuration link and choose the Arguments tab. i got the values for Program arguments and VM arguments by first running jboss the normal way, from the console in the /usr/jboss/bin folder (outside of eclipse):
cd /usr/jboss/bin
./runMyJbossDomain.sh

runMyJbossDomain.sh is just a personalized version of run.sh, in the same folder, and looks like this:

echo "deleting log files..."
rm -rf /usr/jboss/server/mydomain/conf/my-config/logs/*
echo "deleting temp files in mydomain..."
rm -rf /usr/jboss/server/mydomain/log/*
rm -rf /usr/jboss/server/mydomain/tmp/*
rm -rf /usr/jboss/server/mydomain/work/*
rm -rf /usr/jboss/server/mydomain/data/*
/usr/jboss/bin/run.sh -b 0.0.0.0 -c mydomain


then i grep java processes in another terminal to get the correct/working java options:
ps aux|grep java

which gives an output like this:
/usr/lib/jvm/java-6-sun/bin/java -Dprogram.name=run.sh -server -Xms128m -Xmx512m -XX:MaxPermSize=128m -XX:PermSize=128m -Dsun.rmi.dgc.client.gcInterval=3600000 -Dsun.rmi.dgc.server.gcInterval=3600000 -Dorg.jboss.logging.Log4jService.catchSystemOut=false -Djava.net.preferIPv4Stack=true -Djava.endorsed.dirs=/usr/jboss/lib/endorsed -classpath /usr/jboss/bin/run.jar:/usr/lib/jvm/java-6-sun/lib/tools.jar org.jboss.Main -b 0.0.0.0 -c mydomain

so the value for Program arguments in Open launch configuration > Arguments:
-c mydomain -b 0.0.0.0

and VM arguments:
-Dprogram.name=run.sh -server -Xms128m -Xmx512m -XX:MaxPermSize=128m -XX:PermSize=128m -Dsun.rmi.dgc.client.gcInterval=3600000 -Dsun.rmi.dgc.server.gcInterval=3600000 -Dorg.jboss.logging.Log4jService.catchSystemOut=false -Djava.net.preferIPv4Stack=true -Djava.endorsed.dirs=/usr/jboss/lib/endorsed -classpath /usr/jboss/bin/run.jar:/usr/lib/jvm/java-6-sun/lib/tools.jar org.jboss.Main

in the Source tab, add your project:
Add > Java Project > select your project, OK


in the JRE tab, make sure the JRE is correct, e.g. java-6-sun-1.6.0.26

click OK then ctrl-s in the server configuration window (if it has a star by the name in the tab), i.e. if the tab looks like this: *JBoss v4.2 at localhost


(NOTE: build your project if you haven't already)

now in the Servers tab choose Debug.
now you're up and running (debugging) =)

20120529

which eclipse plugin(s) to install in order to get F3 "go to backing bean source" functionality in jsf/xhtml

when you're looking at a jsf file and you want to go directly to the java backing bean source by hitting F3 on the bean name in eclipse, you can install "jboss tools jsf".

to do this:

Help > Eclipse Marketplace > search for "jboss jsf" > click "install" on "jboss tools (indigo)" > unselect everything, then select only "jboss tools jsf" (as of 20120831 it is approx. 75 MB large).

it will additionally install the following requirements:
* jboss tools common
* jboss tools java standard tools
* jboss tools visual page editor

then you have to enable JSF capabilities:
right click on your project > Configure > Enable JSF Capabilities
in Juno, it will open Project Facets properties. at least the following facets should be checked:
Dynamic Web Module
Java
JavaServer Faces

on my machine there was a red X at the bottom of the window with a link to "additional configuration required". a different time it was just a warning saying "further configuration available".

click on the error/warning link.

in my jee app i set the following values:
context root: myProject
content directory: WebContent

(myProject is the name of your project)

click Next

from the dropdown menu for JSF Implementation library at the top, choose "Disable Library Configuration", then uncheck Configure JSF servlet in deployment descriptor and then click OK.

UPDATE 20120831

you can alternatively set up the Project Facet > JavaServer Faces manually, and download/install the api from eclipse, but one thing you don't get, that you do get from the jboss jsf tools is the handy JBoss Tools HTML Editor and its Visual/Source tab.

here's how you configure it manually, e.g. JSF 1.2:
right click on your project > Properties > Project Facets > click JavaServer Faces and choose version 1.2
make sure Java and Dynamic Web Module are also chosen.

you'll see either an error icon or warning icon with a link at the bottom of the properties window telling you that further configuration is required. click on the link.

a new window opens. when you get past setting up your sources, output folder and context root and content dialogues, you'll get to a dialogue allowing you to choose your user library. click the download link to the right and choose e.g. oracle's moharra JSF 1.2 implementation (i think it's only like 8.5 MB large), then select it when it is installed.

20120525

jsf 1.2 and richfaces 3 - get screen dimensions and browser info



here's how to get common browsing details like screen height and width, which browser the user is using and what language the browser has, using jsf 1.2 and richfaces 3:

<a4j:commandButton value="#{myBean.getPropertyValue('label.login')}"
action="#{myBean.login}">
<a4j:actionparam name="w" value="screen.width"
assignTo="#{myBean.screenWidth}" noEscape="true" />
<a4j:actionparam name="h" value="screen.height"
assignTo="#{myBean.screenHeight}" noEscape="true" />
<a4j:actionparam name="c" value="navigator.cookieEnabled"
assignTo="#{myBean.cookieEnabled}" noEscape="true" />
<a4j:actionparam name="a" value="navigator.userAgent"
assignTo="#{myBean.userAgent}" noEscape="true" />
<a4j:actionparam name="l" value="navigator.language"
assignTo="#{myBean.browserLanguage}" noEscape="true" />
<a4j:actionparam name="p" value="navigator.platform"
assignTo="#{myBean.platform}" noEscape="true" />
</a4j:commandButton>

20120515

jsf 1.2 h:panelGrid f:facet header and footer style background color not filling width 100%

i have the following xhtml for my jsf login box:


<h:panelGrid columns="2" styleClass="login">
<f:facet name="header">
<h:outputText value=" " />
</f:facet>
<h:outputLabel for="username" value="Username" />
<h:inputText required="true" id="username" value="#{loginBean.username}" />
<h:outputLabel for="password" value="Password" />
<h:inputSecret required="true" id="password" value="#{loginBean.password}" />
<f:facet name="footer">
<h:panelGroup>
<a4j:commandLink ajaxSingle="true"
value="Forgot password" oncomplete="#{rich:component('forgotPw')}.show()" />
</h:panelGroup>
</f:facet>
</h:panelGrid>

(the Login button and Terms of use link are irrelevant here so i left out the code)

as you can see, the footer and header background color doesn't horizontally fill the entire width of the h:panelGrid:

by using chrome's debugger i found the problem:


chrome's (user agent) stylesheet has a default border-collapse: separate for table elements, so to fix this i added the following to my application's stylesheet:
#checkPassword table {
border-collapse:collapse;
}

where #checkPassword is the id of the form that encloses the h:panelGrid, i.e. collapse all table borders inside my form.

20120510

openldap ldapadd how to add an organizational unit (ou) or Group item

here's what my LDAP hierarchy looks like:


here's how to add a new organizationalunit (ou=):
ldapadd -xWvD cn=adminUsername,dc=companyName,dc=com -f disabledUsersAsOU.ldif

disabledUsersAsOU.ldif contents:

cn: ou=DisabledUsers,dc=companyName,dc=com
ou: DisabledUsers
objectClass: top
objectclass: organizationalunit



or if you want to add a new group in the organizationalunit Groups (ou=Groups) instead:
ldapadd -xWvD cn=adminUsername,dc=companyName,dc=com -f disabledUsersAsGroup.ldif

disabledUsersAsGroup.ldif contents:

dn: cn=DisabledUsers,ou=Groups,dc=companyName,dc=com
cn: DisabledUsers
objectClass: top
objectClass: groupOfUniqueNames
uniqueMember:

20120503

how to set linux folder permissions to drwxr-s---

i deleted /var/spool/mqueue because it was sending out massive amounts of emails, but i wanted to recreate it with it's original file permissions so i did this:
cd /var/spool
sudo mkdir mqueue
sudo chown smmta:smmsp mqueue
sudo chmod u+rwx,g+rs,o-rwx mqueue
http://en.wikipedia.org/wiki/Chmod

how to stop ubuntu linux mailutils mail queue

we had some network problems here at the office so a bunch of error mails got queued to be sent to me and my colleague. it was annoying getting hundreds of irrelevant (because i had fixed the real problem already) error emails so i found out how to stop these queued messages from getting sent out every minute:
$ > /var/spool/mail/myuser
$ > /var/mail/myuser

this cleared the whole mail file so no more mails got sent out.

UPDATE. i was wrong, you need to delete the /var/spool/mqueue directory:
sudo rm -fdr /var/spool/mqueue


here's how to recreate it again with the correct permissions.

20120502

how to disable loading of firewire on boot using a kernel/grub/boot option

i read somewhere that "nofw" works, but it doesn't. you have to add the following to the boot options:
blacklist=firewire_ohci

https://bugs.launchpad.net/ubuntu/+bug/991889/