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)

20131223

[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 :)


20131211

[SOLVED] starting sahi dashboard gives "java.net.BindException: Address already in use"

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

but got the following error message:
java.net.BindException: Address already in use
    at java.net.PlainSocketImpl.socketBind(Native Method)
    at java.net.AbstractPlainSocketImpl.bind(Unknown Source)
    at java.net.ServerSocket.bind(Unknown Source)
    at net.sf.sahi.Proxy.startProxy(Proxy.java:162)
    at net.sf.sahi.Proxy.access$000(Proxy.java:57)
    at net.sf.sahi.Proxy$1.run(Proxy.java:126)
    at java.lang.Thread.run(Unknown Source)


SOLUTION

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

THE REASON

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:

[org.jboss.as.remoting] (MSC service thread 1-7) JBAS017100: Listening on 127.0.0.1:9999
...
[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="${jboss.management.native.port:8888}"/>
    ...
</socket-binding-group>



Here, i've changed 9999 to 8888.


20131210

[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:toolbar>
                <p:toolbarGroup>
                    <p:commandLink update=":search:searchPanelHolder" id="searchFilter" onclick="PF('CDD_filterPanelWV').show();"
                        value="search/filter" />
                </p:toolbarGroup>
            </p:toolbar>
            <ui:include
                src="/webcomponents/costDevTable.xhtml" />
        </h:form>
    </ui:define>


    <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" />
                ...
            </h:panelGrid>
        </h:form>
    </p:dialog>

</ui:composition>

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:toolbar>
                <p:toolbarGroup>
                    <p:commandLink update=":search:searchPanelHolder" id="searchFilter" onclick="PF('CDD_filterPanelWV').show();"
                        value="search/filter" />
                </p:toolbarGroup>
            </p:toolbar>
            <ui:include
                src="/webcomponents/costDevTable.xhtml" />
        </h:form>
 

        <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" />
                    ...
                </h:panelGrid>
            </h:form>
        </p:dialog>
    </ui:define>
</ui:composition>



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

20131209

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-/0.0.0.0:8080-1) setErrorMessage: Feil oppstod...
12:13:02,217 ERROR [stderr] (http-/0.0.0.0:8080-1) org.hibernate.LazyInitializat...
12:13:02,218 ERROR [stderr] (http-/0.0.0.0:8080-1)     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):
search/match:
^[^ ]+ ?(.*$)
replace:
\1


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



at first i thought it would be good enough with just this:
search/match:
^[^ ]+ ?
replace:
(nothing)


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:
 [com.takecargo.tiv.persistentservices.transportagreement.daoimpl....
 [stdout] (http-/0.0.0.0:8080-1) setErrorMessage: Feil oppstod...




EXPLANATION

^[^ ]+ ?(.*$)

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


20131203

[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="http://www.w3.org/1999/xhtml"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:p="http://primefaces.org/ui">



* 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: EscapeSequencesTest.java

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