<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/atom10full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><feed xmlns="http://www.w3.org/2005/Atom" xmlns:openSearch="http://a9.com/-/spec/opensearch/1.1/" xmlns:georss="http://www.georss.org/georss" xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr="http://purl.org/syndication/thread/1.0" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" gd:etag="W/&quot;CkMHQ3syeip7ImA9WhRaFE8.&quot;"><id>tag:blogger.com,1999:blog-33865970</id><updated>2012-02-16T19:27:12.592Z</updated><category term="Tomcat" /><category term="JSF" /><category term="Converter" /><category term="Java EE" /><category term="Validation" /><category term="JEE Security Authentication JAAS Java" /><title>Java Web Development</title><subtitle type="html">Problems and solutions I have found working with Hibernate, Spring, Struts, Seam and JEE.</subtitle><link rel="http://schemas.google.com/g/2005#feed" type="application/atom+xml" href="http://java-web-development.blogspot.com/feeds/posts/default" /><link rel="alternate" type="text/html" href="http://java-web-development.blogspot.com/" /><author><name>Simon</name><uri>http://www.blogger.com/profile/04059229290827090172</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><generator version="7.00" uri="http://www.blogger.com">Blogger</generator><openSearch:totalResults>13</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/atom+xml" href="http://feeds.feedburner.com/JavaWebDevelopment" /><feedburner:info uri="javawebdevelopment" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><entry gd:etag="W/&quot;CkQMRHw_fCp7ImA9WhdVFE4.&quot;"><id>tag:blogger.com,1999:blog-33865970.post-1472463660262037714</id><published>2011-09-16T14:39:00.001+01:00</published><updated>2011-09-19T12:06:25.244+01:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-09-19T12:06:25.244+01:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="JSF" /><category scheme="http://www.blogger.com/atom/ns#" term="Validation" /><category scheme="http://www.blogger.com/atom/ns#" term="Java EE" /><title>Why does f:validateDoubleRange only work for @SessionScoped?</title><content type="html">Can someone explain to me why Foo in my example is always null when it gets to the validateDoubleRange class? The end result is the min value for the validator is always 0.  The number 3 displays just fine on the page when in the outputText element.&lt;br /&gt;
It validates fine if I make the bean `@SessionScoped` instead of `@ViewScoped`&lt;br /&gt;
&lt;br /&gt;
Controller:&lt;br /&gt;
&lt;pre class="xml" name="code"&gt;import java.io.Serializable;
    import java.math.BigDecimal;
    import javax.faces.bean.ManagedBean;
    import javax.faces.bean.ViewScoped;
    
    @ViewScoped
    @ManagedBean(name = "fooController")
    public class FooController implements Serializable {
    
        private static final org.slf4j.Logger log = org.slf4j.LoggerFactory.getLogger(FooController.class);
        private static final long serialVersionUID = 1L;
        private Foo foo;
        private BigDecimal amount;
        private Long fooId;
    
        public Long getFooId() {
            return fooId;
        }
    
        public void setFooId(Long fooId) {
            this.fooId = fooId;
            this.foo = new Foo();
            foo.setFooId(fooId);
            foo.setMinAmount(Double.valueOf(3));
            foo.setMaxAmount(Double.valueOf(10));
        }
    
        public Foo getFoo() {
            return foo;
        }
    
        public void sendAmount() {
            log.debug("sendAmount: " + amount);
        }
    
        public BigDecimal getAmount() {
            return amount;
        }
    
        public void setAmount(BigDecimal amount) {
            this.amount = amount;
        }
    
        public static class Foo {
    
            private Long fooId;
            private Double minAmount;
            private Double maxAmount;
    
            public Foo() {
            }
    
            public void setFooId(Long fooId) {
                this.fooId = fooId;
            }
    
            public void setMinAmount(Double minAmount) {
                this.minAmount = minAmount;
            }
    
            public void setMaxAmount(Double maxAmount) {
                this.maxAmount = maxAmount;
            }
    
            public Long getFooId() {
                return fooId;
            }
    
            public Double getMaxAmount() {
                return maxAmount;
            }
    
            public Double getMinAmount() {
                return minAmount;
            }
        }
    }
&lt;/pre&gt;
&lt;br /&gt;
JSP:   &lt;br /&gt;

&lt;pre class="xml" name="code"&gt;

&amp;lt;ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:h="http://java.sun.com/jsf/html"
                &amp;gt;
    &amp;lt;f:metadata&amp;gt;
        &amp;lt;f:viewParam name="fooId" value="#{fooController.fooId}" /&amp;gt;        
    &amp;lt;/f:metadata&amp;gt;
    &amp;lt;h:form id="myForm"&amp;gt;
        &amp;lt;h:outputText value="This is correctly displayed: '#{fooController.foo.minAmount}'"/&amp;gt;&amp;lt;br/&amp;gt;
        &amp;lt;h:outputText value="My Input:" /&amp;gt;
        &amp;lt;h:inputText id="myInput"
                     value="#{fooController.amount}" 
                     required="true"
                     &amp;gt;
            &amp;lt;f:validateDoubleRange minimum="#{fooController.foo.minAmount}" maximum="80"/&amp;gt;
        &amp;lt;/h:inputText&amp;gt;
        &amp;lt;h:message for="myInput"/&amp;gt;
        &amp;lt;br/&amp;gt;
        &amp;lt;h:commandButton id="bidButton"
                         value="Place Bid"
                         action="#{fooController.sendAmount}"
                         &amp;gt;
        &amp;lt;/h:commandButton&amp;gt;
    &amp;lt;/h:form&amp;gt;
&amp;lt;/ui:composition&amp;gt;

&lt;/pre&gt;

&lt;br /&gt;
I am using JSF 2 on JBoss 6.1&lt;br /&gt;
&lt;br /&gt;
------------------------------------------- UPDATE------------------------------------------- &lt;br /&gt;
&amp;nbsp;Thanks to &lt;a href="http://stackoverflow.com/users/157882/balusc"&gt;BalusC&lt;/a&gt; on StackOverflow I have the answer. "This problem is related to JSF &lt;a href="http://java.net/jira/browse/JAVASERVERFACES-1492" rel="nofollow"&gt;issue 1492&lt;/a&gt;." See &lt;a href="http://stackoverflow.com/questions/7445417/why-does-fvalidatedoublerange-only-work-for-sessionscoped/7447265#7447265"&gt;http://stackoverflow.com/questions/7445417/why-does-fvalidatedoublerange-only-work-for-sessionscoped/7447265#7447265&lt;/a&gt; for the full answer and work arounds.&lt;br /&gt;
&lt;br /&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/33865970-1472463660262037714?l=java-web-development.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/8DXJEgkzqK_8gn-b9UFgaalx8D8/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/8DXJEgkzqK_8gn-b9UFgaalx8D8/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/8DXJEgkzqK_8gn-b9UFgaalx8D8/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/8DXJEgkzqK_8gn-b9UFgaalx8D8/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/JavaWebDevelopment/~4/LqZSqNZrH2o" height="1" width="1"/&gt;</content><link rel="related" href="http://stackoverflow.com/questions/7445417/why-does-fvalidatedoublerange-only-work-for-sessionscoped" title="Why does f:validateDoubleRange only work for @SessionScoped?" /><link rel="replies" type="application/atom+xml" href="http://java-web-development.blogspot.com/feeds/1472463660262037714/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=33865970&amp;postID=1472463660262037714" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/33865970/posts/default/1472463660262037714?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/33865970/posts/default/1472463660262037714?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/JavaWebDevelopment/~3/LqZSqNZrH2o/why-does-fvalidatedoublerange-only-work.html" title="Why does f:validateDoubleRange only work for @SessionScoped?" /><author><name>Simon</name><uri>http://www.blogger.com/profile/04059229290827090172</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><thr:total>0</thr:total><feedburner:origLink>http://java-web-development.blogspot.com/2011/09/why-does-fvalidatedoublerange-only-work.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CEAFSXo6eip7ImA9WhdQEEw.&quot;"><id>tag:blogger.com,1999:blog-33865970.post-9082825580814756972</id><published>2011-08-10T22:43:00.001+01:00</published><updated>2011-08-10T22:45:18.412+01:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-08-10T22:45:18.412+01:00</app:edited><title>Search Strings and the Levenshtein Distance</title><content type="html">I would just like to thank my friend Mark for reminding about the &lt;br /&gt;
&lt;a href="http://www.stickfight.co.uk/d6plinks/ADMR-8FVE9B"&gt;Levenshtein Distance&lt;/a&gt;. What is the Levenshtein Distance? Well, it is simply a measure of how different two strings are. Very useful returning useful search results, dictionary suggestions, that kind of thing.&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/33865970-9082825580814756972?l=java-web-development.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/5Dx8uawjq0eJfAHdXySpaIZkn1E/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/5Dx8uawjq0eJfAHdXySpaIZkn1E/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/5Dx8uawjq0eJfAHdXySpaIZkn1E/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/5Dx8uawjq0eJfAHdXySpaIZkn1E/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/JavaWebDevelopment/~4/rxoliMijbzU" height="1" width="1"/&gt;</content><link rel="related" href="http://www.stickfight.co.uk/d6plinks/ADMR-8FVE9B" title="Search Strings and the Levenshtein Distance" /><link rel="replies" type="application/atom+xml" href="http://java-web-development.blogspot.com/feeds/9082825580814756972/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=33865970&amp;postID=9082825580814756972" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/33865970/posts/default/9082825580814756972?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/33865970/posts/default/9082825580814756972?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/JavaWebDevelopment/~3/rxoliMijbzU/sorting-stringslevenshtein-distance.html" title="Search Strings and the Levenshtein Distance" /><author><name>Simon</name><uri>http://www.blogger.com/profile/04059229290827090172</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><thr:total>0</thr:total><feedburner:origLink>http://java-web-development.blogspot.com/2011/08/sorting-stringslevenshtein-distance.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DkACSH09eip7ImA9WhdSFEQ.&quot;"><id>tag:blogger.com,1999:blog-33865970.post-5475551688090899366</id><published>2011-07-08T14:32:00.002+01:00</published><updated>2011-07-24T09:06:09.362+01:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-07-24T09:06:09.362+01:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="JSF" /><category scheme="http://www.blogger.com/atom/ns#" term="Converter" /><category scheme="http://www.blogger.com/atom/ns#" term="Tomcat" /><title>JSF Bug - Number Based Input Field Magically Changes From 'null' To Zero</title><content type="html">The problem:&lt;br /&gt;
Submitting a form and the number based fields (BigDecimal/Number/Integer etc) that had an empty string (null) on the form get populated with zero ("0") values.&lt;br /&gt;
&lt;br /&gt;
The problem domain:&lt;br /&gt;
Tomcat/JBoss servers. I am running JBoss 5.1.0.GA.&lt;br /&gt;
&lt;br /&gt;
The solution:&lt;br /&gt;
It appears the team at Tomcat didn't want us to be able to have nullable number fields in a JSF form! The solution is to set this java system variable: "org.apache.el.parser.COERCE_TO_ZERO=false", e.g.:&lt;br /&gt;
&lt;br /&gt;
run.bat -Dorg.apache.el.parser.COERCE_TO_ZERO=false&lt;br /&gt;
&lt;br /&gt;
This was a bit of a nightmare to track down, I tried writing and stepping through custom converters and thought I was going insane. Hopefully this helps someone out there.&lt;br /&gt;
&lt;br /&gt;
P.S. I know I said this is a bug, but technically (crazily?) the spec does say to convert null's to 0's. See: &lt;a href="http://tomcat.apache.org/tomcat-6.0-doc/config/systemprops.html"&gt;http://tomcat.apache.org/tomcat-6.0-doc/config/systemprops.html&lt;/a&gt;.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/33865970-5475551688090899366?l=java-web-development.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/1H4rtjmy5qt7lQCqoSov_y3ZOe8/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/1H4rtjmy5qt7lQCqoSov_y3ZOe8/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/1H4rtjmy5qt7lQCqoSov_y3ZOe8/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/1H4rtjmy5qt7lQCqoSov_y3ZOe8/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/JavaWebDevelopment/~4/0JNuAMZGa3o" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://java-web-development.blogspot.com/feeds/5475551688090899366/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=33865970&amp;postID=5475551688090899366" title="4 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/33865970/posts/default/5475551688090899366?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/33865970/posts/default/5475551688090899366?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/JavaWebDevelopment/~3/0JNuAMZGa3o/jsf-bug-number-based-input-field.html" title="JSF Bug - Number Based Input Field Magically Changes From 'null' To Zero" /><author><name>Simon</name><uri>http://www.blogger.com/profile/04059229290827090172</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><thr:total>4</thr:total><feedburner:origLink>http://java-web-development.blogspot.com/2011/07/jsf-bug-number-based-input-field.html</feedburner:origLink></entry><entry gd:etag="W/&quot;Dk8AQXc_eip7ImA9WhdSFEQ.&quot;"><id>tag:blogger.com,1999:blog-33865970.post-4089855325131580188</id><published>2011-07-01T21:36:00.002+01:00</published><updated>2011-07-24T09:07:20.942+01:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-07-24T09:07:20.942+01:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="JEE Security Authentication JAAS Java" /><title>JEE 6 Security - Part Two (the implementation)</title><content type="html">Alright, I have set up authentication up in JBoss AS 6 using JAAS database (jdbc) authentication. The steps:&lt;br /&gt;
&lt;br /&gt;
1) Setup the logging levels, this will save you some headaches, trust me. Don't forget to change it back once you are setup. Open up jboss-logging.xml under server/default/deploy, under the 'console-handler' tag, there is a 'level' tag, replace 'INFO' with 'TRACE'. Also, add by the other loggers the following:&lt;br /&gt;
&lt;pre class="xml" name="code"&gt;&lt;logger category="org.jboss.security"&gt;
      &lt;level name="TRACE" /&gt;
   &lt;/logger&gt;
&lt;/pre&gt;&lt;br /&gt;
2) Add your security domain. To do this create a new XML file, name it something like my-app-name-jaas-jboss-beans.xml and place it in the server/default/deploy folder. Add the following to the file:&lt;br /&gt;
&lt;pre class="xml" name="code"&gt;&lt;?xml version="1.0" encoding="UTF-8"?&gt;

&lt;deployment xmlns="urn:jboss:bean-deployer:2.0"&gt;
  &lt;application-policy xmlns="urn:jboss:security-beans:1.0" name="myapp-realm"&gt;
    &lt;authentication &gt;
      &lt;login-module code="org.jboss.security.auth.spi.DatabaseServerLoginModule" flag="required"&gt;
        &lt;module-option name="dsJndiName"&gt;java:/jdbc/myapp&lt;/module-option&gt;
        &lt;module-option name="principalsQuery"&gt;
          select PASSWORD from USER where USERNAME=?&lt;/module-option&gt;
        &lt;module-option name="rolesQuery"&gt;
          SELECT r.NAME, 'Roles' FROM ROLE r, USER_ROLE ur, USER u WHERE
          u.USERNAME=? AND u.USERNAME=ur.USERNAME AND ur.ROLE_NAME=r.NAME
        &lt;/module-option&gt;
      &lt;/login-module&gt;
    &lt;/authentication&gt;
  &lt;/application-policy&gt;
&lt;/deployment&gt;
&lt;/pre&gt;IMPORTANT: The role query has to have two coloums, the second of which is always 'Roles' exactly like stated. It's a JBoss quirk.&lt;br /&gt;
&lt;br /&gt;
3) You have a security domain, now you have to tell your application to use it. Create or edit jboss-web.xml in your applications WEB-INF folder, it needs the security doman specified like so:&lt;br /&gt;
&lt;pre class="xml" name="code"&gt;&lt;?xml version="1.0" encoding="UTF-8"?&gt;
&lt;jboss-web&gt;
    &lt;context-root&gt;/myapp&lt;/context-root&gt;
    &lt;security-domain&gt;java:/jaas/myapp-realm&lt;/security-domain&gt;
&lt;/jboss-web&gt;
&lt;/pre&gt;&lt;br /&gt;
4) Your application is set to use the domain now, but you haven't told it what needs securing and when to authenticate. For testing purposes I have used &lt;a href="http://download.oracle.com/javaee/5/tutorial/doc/bncbe.html#bncbn"&gt;BASIC authentication, in reality you should use FORM based&lt;/a&gt;. I will leave you to research the difference. To test your security add the following to your web.xml:&lt;br /&gt;
&lt;pre class="xml" name="code"&gt;&lt;security-constraint&gt;
        &lt;display-name&gt;Secure Pages&lt;/display-name&gt;
        &lt;web-resource-collection&gt;
            &lt;web-resource-name&gt;secure-pages&lt;/web-resource-name&gt;
            &lt;description/&gt;
            &lt;url-pattern&gt;/test/*&lt;/url-pattern&gt;
        &lt;/web-resource-collection&gt;
        &lt;auth-constraint&gt;
            &lt;description/&gt;
            &lt;role-name&gt;MANAGER&lt;/role-name&gt;
            &lt;role-name&gt;USER&lt;/role-name&gt;
        &lt;/auth-constraint&gt;
    &lt;/security-constraint&gt;
    &lt;login-config&gt;
        &lt;auth-method&gt;BASIC&lt;/auth-method&gt;
        &lt;realm-name&gt;myapp-realm&lt;/realm-name&gt;
    &lt;/login-config&gt;
    &lt;security-role&gt;
        &lt;description/&gt;
        &lt;role-name&gt;MANAGER&lt;/role-name&gt;
    &lt;/security-role&gt;
    &lt;security-role&gt;
        &lt;description/&gt;
        &lt;role-name&gt;USER&lt;/role-name&gt;
    &lt;/security-role&gt;
&lt;/pre&gt;&lt;br /&gt;
So I have covered authentication, and &lt;a href="http://java.sun.com/developer/technicalArticles/J2EE/security_annotation/"&gt;EJB 3.1 JEE authorization&lt;/a&gt; is covered tons everywhere. One thing lacking in the JEE world is full Identity management, i.e. something where you say identity.createUser("bob") and it will create a user in any abstracted back end user store, LDAP, Database or whatever. This tool does exist, and it is &lt;a href="http://www.jboss.org/picketlink"&gt;PicketLink&lt;/a&gt;. I haven't had a chance to play with it, but it looks promising. I would dare say it is overkill for most applications though, at least until it becomes more mainstream and simple to use.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/33865970-4089855325131580188?l=java-web-development.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/yKuSii_o-Ul7wC2-MfMRLDNDeag/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/yKuSii_o-Ul7wC2-MfMRLDNDeag/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/yKuSii_o-Ul7wC2-MfMRLDNDeag/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/yKuSii_o-Ul7wC2-MfMRLDNDeag/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/JavaWebDevelopment/~4/wAKcu7Ev4hM" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://java-web-development.blogspot.com/feeds/4089855325131580188/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=33865970&amp;postID=4089855325131580188" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/33865970/posts/default/4089855325131580188?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/33865970/posts/default/4089855325131580188?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/JavaWebDevelopment/~3/wAKcu7Ev4hM/jee-6-security-part-two-implementation.html" title="JEE 6 Security - Part Two (the implementation)" /><author><name>Simon</name><uri>http://www.blogger.com/profile/04059229290827090172</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><thr:total>0</thr:total><feedburner:origLink>http://java-web-development.blogspot.com/2011/07/jee-6-security-part-two-implementation.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CUUGR38yeCp7ImA9WhZaFU4.&quot;"><id>tag:blogger.com,1999:blog-33865970.post-8356111654229889745</id><published>2011-07-01T16:12:00.001+01:00</published><updated>2011-07-01T16:13:46.190+01:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-07-01T16:13:46.190+01:00</app:edited><title>JEE 6 Security - Part One (the research)</title><content type="html">I am starting to look at security for my JEE 6 /EJB 3.1 application. I have to say there is plenty of information on authorization for EJB 3.x (for instance what methods/urls a user has access to etc) but very few simple articles on authentication and identity management (creating new users etc). Authentication isn't really part of the JEE spec as such, although all JEE 6 servers support JAAS. &lt;br /&gt;
&lt;br /&gt;
Using a new library that handles identity management (&lt;a href="http://www.jboss.org/picketlink"&gt;PicketLink&lt;/a&gt;) sounds great, but I don't want to be stuck in a couple of years time replacing it because it is out of fashion. I also want to try not to use Spring Security, I want to stick with JEE standards (even though Spring Security is a pseudo standard).&lt;br /&gt;
&lt;br /&gt;
I hope to follow this up with how I managed to get authentication setup using JAAS and probably JDBC/Database credentials, and how I create new users.&lt;br /&gt;
&lt;br /&gt;
As a side note, I found a good article for &lt;a href="http://software-security.sans.org/blog/2010/08/11/security-misconfigurations-java-webxml-files/"&gt;Seven Security (Mis)Configurations in Java web.xml Files&lt;/a&gt;. Definitely worth a read.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/33865970-8356111654229889745?l=java-web-development.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/EoQpjoOD-l1RhTu1-Nkg1dEOb9E/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/EoQpjoOD-l1RhTu1-Nkg1dEOb9E/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/EoQpjoOD-l1RhTu1-Nkg1dEOb9E/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/EoQpjoOD-l1RhTu1-Nkg1dEOb9E/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/JavaWebDevelopment/~4/f0xbO12SB3g" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://java-web-development.blogspot.com/feeds/8356111654229889745/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=33865970&amp;postID=8356111654229889745" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/33865970/posts/default/8356111654229889745?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/33865970/posts/default/8356111654229889745?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/JavaWebDevelopment/~3/f0xbO12SB3g/jee-6-security-part-one-research.html" title="JEE 6 Security - Part One (the research)" /><author><name>Simon</name><uri>http://www.blogger.com/profile/04059229290827090172</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><thr:total>0</thr:total><feedburner:origLink>http://java-web-development.blogspot.com/2011/07/jee-6-security-part-one-research.html</feedburner:origLink></entry><entry gd:etag="W/&quot;AkUASX89cCp7ImA9WhZUFkw.&quot;"><id>tag:blogger.com,1999:blog-33865970.post-5716166927114733650</id><published>2011-06-09T12:17:00.000+01:00</published><updated>2011-06-09T12:17:28.168+01:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-06-09T12:17:28.168+01:00</app:edited><title>JRebel</title><content type="html">I normally just try and post up useful code snippets and howto's. I am breaking this rule to rave about how great &lt;a href="http://www.zeroturnaround.com/jrebel/"&gt;JRebel&lt;/a&gt; is! If you haven't heard of it, it INSTANTLY deploys code from your workspace onto your server, yes INSTANTLY. So, not just your JSP/XHTML changes but your CODE changes. So, say good-bye to your code and re-deployment cycles, and &lt;a href="http://www.zeroturnaround.com/jrebel/"&gt;give JRebel a try&lt;/a&gt;.&lt;br /&gt;
&lt;br /&gt;
P.S. I am no way affiliated with them, just love the idea of skipping the deployment cycle and wasting my precious time.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/33865970-5716166927114733650?l=java-web-development.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/jb6BLfDsm4p32BX0LLpneL2KNi4/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/jb6BLfDsm4p32BX0LLpneL2KNi4/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/jb6BLfDsm4p32BX0LLpneL2KNi4/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/jb6BLfDsm4p32BX0LLpneL2KNi4/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/JavaWebDevelopment/~4/H24OtAcvnRc" height="1" width="1"/&gt;</content><link rel="related" href="http://www.zeroturnaround.com/jrebel/" title="JRebel" /><link rel="replies" type="application/atom+xml" href="http://java-web-development.blogspot.com/feeds/5716166927114733650/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=33865970&amp;postID=5716166927114733650" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/33865970/posts/default/5716166927114733650?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/33865970/posts/default/5716166927114733650?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/JavaWebDevelopment/~3/H24OtAcvnRc/jrebel.html" title="JRebel" /><author><name>Simon</name><uri>http://www.blogger.com/profile/04059229290827090172</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><thr:total>0</thr:total><feedburner:origLink>http://java-web-development.blogspot.com/2011/06/jrebel.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DkYEQXg6fyp7ImA9WhZVF0s.&quot;"><id>tag:blogger.com,1999:blog-33865970.post-8145886813729266034</id><published>2011-05-30T15:00:00.001+01:00</published><updated>2011-05-30T15:01:40.617+01:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-05-30T15:01:40.617+01:00</app:edited><title>Internationalized h:selectOneMenu using a Enum</title><content type="html">Using JSF2.0 it is now very easy to add internalionsed enums to your drop down (h:selectOneMenu) options. All you need to do is this:&lt;br /&gt;
&lt;br /&gt;
&lt;pre class="xml" name="code"&gt;&amp;lt;h:selectOneMenu id="colourSelect" value="#{colourController.colour}"&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;f:selectItems value="#{colourController.colours}"
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var="colour"
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; itemValue="#{colour}"
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; itemLabel="#{enumBundle[colour.name()]}"&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/f:selectItems&amp;gt;
&amp;lt;/h:selectOneMenu&amp;gt;
&lt;/pre&gt;&lt;br /&gt;
Simples! That may be enough for you to get going. Read on if you need more config info.&lt;br /&gt;
&lt;br /&gt;
In faces config, add:&lt;br /&gt;
&lt;pre class="xml" name="code"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;application&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;resource-bundle&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;base-name&amp;gt;/enumBundle&amp;lt;/base-name&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;var&amp;gt;enumBundle&amp;lt;/var&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/resource-bundle&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/application&amp;gt;
&lt;/pre&gt;&lt;br /&gt;
Create a file '/src/main/resources/enumBundle.properties' (if using maven, otherwise place it in your default package) and add this to it:&lt;br /&gt;
&lt;br /&gt;
RED=Colour Red&lt;br /&gt;
BLUE=Colour Blue&lt;br /&gt;
GREEN=Colour Green &lt;br /&gt;
&lt;br /&gt;
Thats the resource bundle setup, now you just need the bean:&lt;br /&gt;
&lt;br /&gt;
&lt;pre class="java" name="code"&gt;import java.io.Serializable;
import javax.enterprise.context.ConversationScoped;
import javax.inject.Named;


@ConversationScoped
@Named("colourController")
public class ColourController implements Serializable {

&amp;nbsp;&amp;nbsp;&amp;nbsp; public enum Colour {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; RED, BLUE, GREEN
&amp;nbsp;&amp;nbsp;&amp;nbsp; }
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; public Colour[] getColours(){
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return Colour.values();
&amp;nbsp;&amp;nbsp;&amp;nbsp; }

&amp;nbsp;&amp;nbsp;&amp;nbsp; public void colour(Colour colour) {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; System.out.println("colour: '" + colour.name() + "' was selected.");
&amp;nbsp;&amp;nbsp;&amp;nbsp; }
}
&lt;/pre&gt;&lt;br /&gt;
You DO NOT need to write your own converter (I have seen this recommended elsewhere) as JSF has it's own built in converter. This is all you need to do. I wasted a couple of hours on this, hopefully saves someone out there some time, let me know!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/33865970-8145886813729266034?l=java-web-development.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/SRRmhajkS_njaYdo58E4nFtJqz4/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/SRRmhajkS_njaYdo58E4nFtJqz4/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/SRRmhajkS_njaYdo58E4nFtJqz4/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/SRRmhajkS_njaYdo58E4nFtJqz4/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/JavaWebDevelopment/~4/sKOd-hOR00Y" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://java-web-development.blogspot.com/feeds/8145886813729266034/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=33865970&amp;postID=8145886813729266034" title="1 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/33865970/posts/default/8145886813729266034?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/33865970/posts/default/8145886813729266034?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/JavaWebDevelopment/~3/sKOd-hOR00Y/internationalized-hselectonemenu-using.html" title="Internationalized h:selectOneMenu using a Enum" /><author><name>Simon</name><uri>http://www.blogger.com/profile/04059229290827090172</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><thr:total>1</thr:total><feedburner:origLink>http://java-web-development.blogspot.com/2011/05/internationalized-hselectonemenu-using.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CUIARno9fCp7ImA9WhZVEko.&quot;"><id>tag:blogger.com,1999:blog-33865970.post-4132024274900810760</id><published>2011-05-24T22:45:00.000+01:00</published><updated>2011-05-24T22:45:47.464+01:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-05-24T22:45:47.464+01:00</app:edited><title>Adding Code Syntax Highlighting To Your Blog</title><content type="html">Thanks to &lt;a href="http://heisencoder.net/"&gt;http://heisencoder.net&lt;/a&gt; I can now use &lt;a href="http://heisencoder.net/2009/01/adding-syntax-highlighting-to-blogger.html"&gt;code snippets and syntax highlighting in my blog&lt;/a&gt;. Click &lt;a href="http://heisencoder.net/2009/01/adding-syntax-highlighting-to-blogger.html"&gt;here&lt;/a&gt; to see how you can do it.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/33865970-4132024274900810760?l=java-web-development.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/mMS1yMYy5yPGIw1ljcR0mSQzO5Q/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/mMS1yMYy5yPGIw1ljcR0mSQzO5Q/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/mMS1yMYy5yPGIw1ljcR0mSQzO5Q/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/mMS1yMYy5yPGIw1ljcR0mSQzO5Q/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/JavaWebDevelopment/~4/ef9hQ0XMffY" height="1" width="1"/&gt;</content><link rel="related" href="http://heisencoder.net/2009/01/adding-syntax-highlighting-to-blogger.html" title="Adding Code Syntax Highlighting To Your Blog" /><link rel="replies" type="application/atom+xml" href="http://java-web-development.blogspot.com/feeds/4132024274900810760/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=33865970&amp;postID=4132024274900810760" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/33865970/posts/default/4132024274900810760?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/33865970/posts/default/4132024274900810760?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/JavaWebDevelopment/~3/ef9hQ0XMffY/adding-code-syntax-highlighting-to-your.html" title="Adding Code Syntax Highlighting To Your Blog" /><author><name>Simon</name><uri>http://www.blogger.com/profile/04059229290827090172</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><thr:total>0</thr:total><feedburner:origLink>http://java-web-development.blogspot.com/2011/05/adding-code-syntax-highlighting-to-your.html</feedburner:origLink></entry><entry gd:etag="W/&quot;D0ENR3Y5fyp7ImA9WhZVFEU.&quot;"><id>tag:blogger.com,1999:blog-33865970.post-524946802856387885</id><published>2011-05-24T22:30:00.003+01:00</published><updated>2011-05-27T09:41:36.827+01:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-05-27T09:41:36.827+01:00</app:edited><title>Using CDI Beans in your Faces Converter</title><content type="html">Unfortunately, you cannot use @Inject within your FacesConverter. This becomes a problem when you want to convert, say, countries loaded from your database and cached in a context such as @ApplicationScoped. There are two answers here:&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-size: large;"&gt;Option 1: If using JBoss&lt;/span&gt;&lt;br /&gt;
If you are using JBoss, just use &lt;a href="http://seamframework.org/Seam3/FacesModule"&gt;Seam Faces&lt;/a&gt;. Just by including the library you can use the @Inject annotation, as well as @PostConstruct. Very Handy. If you are using Maven, just add this to your pom.xml:&lt;br /&gt;
&lt;pre class="xml" name="code"&gt;&amp;lt;dependency&amp;gt;
&amp;lt;groupId&amp;gt;org.jboss.seam.faces&amp;lt;/groupId&amp;gt;
&amp;lt;artifactId&amp;gt;seam-faces&amp;lt;/artifactId&amp;gt;
&amp;lt;version&amp;gt;3.0.1.Final&amp;lt;/version&amp;gt;
&amp;lt;/dependency&amp;gt;&lt;/pre&gt;That is it! You can stop reading now :).&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-size: large;"&gt;Option 2: If using GlassFish&lt;/span&gt;&lt;br /&gt;
Unfortunately, Glass fish 3.1 has a bug with the class loader, see:&lt;br /&gt;
&lt;ul&gt;&lt;li&gt;&lt;span class="postbody"&gt; &lt;a class="postlink" href="http://java.net/jira/browse/GLASSFISH-16318" target="_blank"&gt;http://java.net/jira/browse/GLASSFISH-16318&lt;/a&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span class="postbody"&gt;&lt;/span&gt;&lt;span class="postbody"&gt;&lt;a class="postlink" href="http://seamframework.org/Seam3/CompatibilityHome#H-OverzealousClassScanner" target="_blank"&gt;http://seamframework.org/Seam3/CompatibilityHome#H-OverzealousClassScanner&lt;/a&gt;&lt;/span&gt;&amp;nbsp;&lt;/li&gt;
&lt;/ul&gt;Using Seam Faces exposes the bug. According to the bug report, 'you need to add dependencies to the classpath to satisfy any class that is referenced in a bean archive'. Not only annoying, but I couldn't get it to work even when dependencies where in the pom, it was one issue after another. Until &lt;a href="http://wikis.sun.com/display/GlassFish/3.1.1BuildSchedule"&gt;GlassFish 3.1.1&lt;/a&gt; I would recommend creating a simple Service Locator to lookup the CDI beans.&lt;br /&gt;
&lt;br /&gt;
&lt;pre class="java" name="code"&gt;public class CDIServiceLocator {
    private static BeanManager getBeanManager() {
        try {
            InitialContext initialContext = new InitialContext();
            return (BeanManager) initialContext.lookup("java:comp/BeanManager");
        }
        catch (NamingException e) {
            throw new RuntimeException("Couldn't find BeanManager in JNDI");
        }
    }

    public static Object getBeanByName(String beanName) {
        BeanManager bm = getBeanManager();
        Set beans = bm.getBeans(beanName);
        if (beans == null || beans.isEmpty()) {
            return null;
        }
        Bean bean = beans.iterator().next();
        CreationalContext ctx = bm.createCreationalContext(bean);
        Object o = bm.getReference(bean, bean.getClass(), ctx);
        return o;
    }
}
&lt;/pre&gt;&lt;br /&gt;
You can then use the ServiceLocator to lookup beans like so:&lt;br /&gt;
&lt;pre class="java" name="code"&gt;countries = (List&amp;lt;country&amp;gt;) CDIServiceLocator.getBeanByName("countries");
&lt;/pre&gt;&lt;br /&gt;
This is a hack, no doubt about it. But until GlassFish 3.1.1 comes out, I believe its the best option - unless you can switch to JBoss. Big thanks to &lt;a href="http://www.java.net/external?url=http://dominikdorn.com/2010/04/cdi-weld-manual-bean-lookup/"&gt;dominickdorn.com&lt;/a&gt; whose code and info this is largely based from.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/33865970-524946802856387885?l=java-web-development.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/c9SSANoY24NrSvlAecyiu9WLfxo/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/c9SSANoY24NrSvlAecyiu9WLfxo/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/c9SSANoY24NrSvlAecyiu9WLfxo/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/c9SSANoY24NrSvlAecyiu9WLfxo/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/JavaWebDevelopment/~4/x3HPcC3UZHY" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://java-web-development.blogspot.com/feeds/524946802856387885/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=33865970&amp;postID=524946802856387885" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/33865970/posts/default/524946802856387885?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/33865970/posts/default/524946802856387885?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/JavaWebDevelopment/~3/x3HPcC3UZHY/using-cdi-beans-in-your-faces-convertor.html" title="Using CDI Beans in your Faces Converter" /><author><name>Simon</name><uri>http://www.blogger.com/profile/04059229290827090172</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><thr:total>0</thr:total><feedburner:origLink>http://java-web-development.blogspot.com/2011/05/using-cdi-beans-in-your-faces-convertor.html</feedburner:origLink></entry><entry gd:etag="W/&quot;A04GRXc5eSp7ImA9WhZVEkk.&quot;"><id>tag:blogger.com,1999:blog-33865970.post-1200397172463272561</id><published>2011-05-24T14:49:00.003+01:00</published><updated>2011-05-24T16:12:04.921+01:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-05-24T16:12:04.921+01:00</app:edited><title>HyperSonic/HyperSQL Quickstart</title><content type="html">HyperSQL is a fantastic tool for local rapid development and testing. A lot of people don't seem to know about it, or just how useful it is. Some advantages:&lt;br /&gt;
&lt;ol&gt;&lt;li&gt;You do not need to install it, so you do not need local admin rights (a hurdle in corporate environments).&lt;/li&gt;
&lt;li&gt;It saves everything in a readable, and editable text file. In other words, the database IS the text file (see below for example).&lt;/li&gt;
&lt;li&gt;It starts up in no time (an empty DB for me starts up in 385 ms!).&lt;/li&gt;
&lt;li&gt;It is fully JDBC compatible.&lt;/li&gt;
&lt;/ol&gt;As a quick start (based on release 2.2.2, which is the latest as of this post):&lt;br /&gt;
&lt;ul&gt;&lt;li&gt;Download the latest &lt;a href="http://sourceforge.net/projects/hsqldb/files/hsqldb/hsqldb_2_2/hsqldb-2.2.2.zip/download"&gt;HyperSQL/HSQLDB zip file&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;extract it to your local drive, in this example C:\bin\hsql&lt;/li&gt;
&lt;li&gt;cd C:\bin\hsqldb-2.2.2\hsqldb\bin&lt;/li&gt;
&lt;li&gt;make a new batch file, call it say hsqlStart.bat&lt;/li&gt;
&lt;li&gt;edit the batch file, and put this in it:&lt;/li&gt;
&lt;li&gt;java -cp ../lib/hsqldb.jar org.hsqldb.server.Server --database.0 file:C:\bin\hsqldb-2.2.2\hsqldb\data\myDb --dbname.0 test&lt;/li&gt;
&lt;li&gt;Run the batch file from the comman prompt from the bin folder&lt;/li&gt;
&lt;li&gt;Connect to the database using the jdbc compatible SQL editor of your choice, using the connection string: jdbc:hsqldb:hsql://localhost/test", "SA", "", and the driver found at: C:\bin\hsqldb-2.2.2\hsqldb\lib\hsqldb.jar&lt;/li&gt;
&lt;li&gt;Refer to the &lt;a href="http://hsqldb.org/doc/2.0/guide/index.html"&gt;HyperSQL/HSQLDB User Guide&lt;/a&gt; for anything not covered by this quick start.&lt;/li&gt;
&lt;/ul&gt;&lt;br /&gt;
As mentioned it saves all updates in a plain text file. So if you run:&lt;br /&gt;
&lt;blockquote&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; create table my_tbl(&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; my_key INT primary key,&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; some_text VARCHAR(256)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; )&lt;/blockquote&gt;and then open the file: C:\bin\hsqldb-2.2.2\hsqldb\data\temp.log, you will see it has the create table directly in there. This is VERY useful for troubleshooting and sanity checks during rapid development.&lt;br /&gt;
&lt;br /&gt;
To shutdown the server cleanly type 'SHUTDOWN' in your SQL editor (such as Squiral SQL). You will notice it shutdown, and copies the data cleanly from the temp.log file into temp.script. This file is actually editable, so you can edit the SQL driectly in the script file, cool huh?&lt;br /&gt;
&lt;br /&gt;
Hope this is useful for someone, shout out if it is!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/33865970-1200397172463272561?l=java-web-development.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/Ks-oS-YVsQTf6Iv5z59mBODgYCY/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/Ks-oS-YVsQTf6Iv5z59mBODgYCY/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/Ks-oS-YVsQTf6Iv5z59mBODgYCY/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/Ks-oS-YVsQTf6Iv5z59mBODgYCY/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/JavaWebDevelopment/~4/TlqD-mkQNBg" height="1" width="1"/&gt;</content><link rel="related" href="http://hsqldb.org/" title="HyperSonic/HyperSQL Quickstart" /><link rel="replies" type="application/atom+xml" href="http://java-web-development.blogspot.com/feeds/1200397172463272561/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=33865970&amp;postID=1200397172463272561" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/33865970/posts/default/1200397172463272561?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/33865970/posts/default/1200397172463272561?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/JavaWebDevelopment/~3/TlqD-mkQNBg/hypersql-hypersonic-hsqldb-hypersql-is.html" title="HyperSonic/HyperSQL Quickstart" /><author><name>Simon</name><uri>http://www.blogger.com/profile/04059229290827090172</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><thr:total>0</thr:total><feedburner:origLink>http://java-web-development.blogspot.com/2011/05/hypersql-hypersonic-hsqldb-hypersql-is.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DEYMSX4_eyp7ImA9WhZVEk8.&quot;"><id>tag:blogger.com,1999:blog-33865970.post-5348964388521375051</id><published>2011-05-24T09:29:00.004+01:00</published><updated>2011-05-24T09:36:28.043+01:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-05-24T09:36:28.043+01:00</app:edited><title /><content type="html">Right, well it has been a few years since my first blog on here. I thought I should start this thing back up again. Stay tuned for (hopefully) useful insite based on my experiences with Java, EJB, JSF, Seam, Spring etc etc&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/33865970-5348964388521375051?l=java-web-development.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/z_PYvBjY61Z1o2q0_e09pkLtfS8/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/z_PYvBjY61Z1o2q0_e09pkLtfS8/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/z_PYvBjY61Z1o2q0_e09pkLtfS8/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/z_PYvBjY61Z1o2q0_e09pkLtfS8/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/JavaWebDevelopment/~4/0wvtJZwcdww" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://java-web-development.blogspot.com/feeds/5348964388521375051/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=33865970&amp;postID=5348964388521375051" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/33865970/posts/default/5348964388521375051?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/33865970/posts/default/5348964388521375051?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/JavaWebDevelopment/~3/0wvtJZwcdww/right-well-it-has-been-few-years-since.html" title="" /><author><name>Simon</name><uri>http://www.blogger.com/profile/04059229290827090172</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><thr:total>0</thr:total><feedburner:origLink>http://java-web-development.blogspot.com/2011/05/right-well-it-has-been-few-years-since.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DkUHRX4-fip7ImA9WBNUFEk.&quot;"><id>tag:blogger.com,1999:blog-33865970.post-115743076567943020</id><published>2006-09-05T05:20:00.000+01:00</published><updated>2006-09-05T09:17:14.056+01:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2006-09-05T09:17:14.056+01:00</app:edited><title /><content type="html">&lt;h1&gt;CSS and Images not loading&lt;/h1&gt;Alrighty, my first (hopefully) helpful blog :).&lt;br /&gt;&lt;br /&gt;I am using a hosting company for my webapp. They are using plain, good old Apache for hosting the static content such as images, css files and html pages. Requests are passed to Tomcat for processing any of the jsp files etc.&lt;br /&gt;&lt;br /&gt;I noticed that the first time I went to my website after clearing the browser cache, the images and the CSS files were not being displayed or even found. This kept me up a few nights pulling my hair out, but I eventually noticed that when I disabled cookies the images and CSS NEVER got displayed!&lt;br /&gt;&lt;br /&gt;The problem? After viewing the page source I noticed that without cookies enabled, the URLs included the session id in them, like so: "http://www.stroke-education.com/image/cart.gif;jsessionid=24A03F5B45814B192ABF9F7B1918B8AB.tomcat36". Of course Apache doesn't know how to deal with the jsessionid, it treats the whole thing as one URL, and it cannot find the file. The session id gets included the first time because tomcat isn't sure if cookies are enabled/disabled.&lt;br /&gt;&lt;br /&gt;The solution? Tomcat has to get passed the requests that have jsessionid in the URL. My host company ended up forwarding all requests to Tomcat, which is overkill but it works.&lt;br /&gt;&lt;br /&gt;A better solution is talked about here:&lt;br /&gt;&lt;a onclick="return top.js.OpenExtLink(window,event,this)" href="http://www.jguru.com/faq/view.jsp?EID=53878" target="_blank"&gt;http://www.jguru.com/faq/view&lt;wbr&gt;.jsp?EID=53878&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;They suggest adding the following to Apaches config:&lt;br /&gt;&amp;lt;IfModule mod_rewrite.c&amp;gt;&lt;br /&gt;RewriteEngine  on&lt;br /&gt;# Force URLs with a jsessionid to go to Tomcat. Necessary because&lt;br /&gt;# Apache doesn't recognise that the semi-colon is special.&lt;br /&gt;RewriteRule  ^(/.*;jsessionid=.*)$   $1 [T=jserv-servlet]&lt;br /&gt;&amp;lt;/IfModule&amp;gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/33865970-115743076567943020?l=java-web-development.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/E70aqoJGOrghwSGTfILs3Kw1sb4/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/E70aqoJGOrghwSGTfILs3Kw1sb4/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/E70aqoJGOrghwSGTfILs3Kw1sb4/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/E70aqoJGOrghwSGTfILs3Kw1sb4/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/JavaWebDevelopment/~4/NHLeAoRnsGk" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://java-web-development.blogspot.com/feeds/115743076567943020/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=33865970&amp;postID=115743076567943020" title="2 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/33865970/posts/default/115743076567943020?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/33865970/posts/default/115743076567943020?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/JavaWebDevelopment/~3/NHLeAoRnsGk/css-and-images-not-loadingalrighty-my.html" title="" /><author><name>Simon</name><uri>http://www.blogger.com/profile/04059229290827090172</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><thr:total>2</thr:total><feedburner:origLink>http://java-web-development.blogspot.com/2006/09/css-and-images-not-loadingalrighty-my.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CkUMQno6fyp7ImA9WhZXE0g.&quot;"><id>tag:blogger.com,1999:blog-33865970.post-115742041346474328</id><published>2006-09-05T00:35:00.002+01:00</published><updated>2011-05-02T16:31:23.417+01:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-05-02T16:31:23.417+01:00</app:edited><title /><content type="html">&lt;h1&gt;Welcome&lt;/h1&gt;&lt;br /&gt;After spending numerous hours searching blogs and the like for help with weird, wonderful, and just plain strange Java Web Development issues and bugs, I thought I should return the favor and post my findings.&lt;br /&gt;&lt;br /&gt;The latest site I have made is &lt;a href="http://www.stroke-education.com/"&gt;http://www.stroke-education.com&lt;/a&gt;. It was an interesting one for me, as I hadn't dealt with credit card processing, or a website with high accessibility needs before. It was also my first contract based website.&lt;br /&gt;&lt;br /&gt;The main technologies I used were:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Struts MVC&lt;/li&gt;&lt;li&gt;Hibernate&lt;/li&gt;&lt;li&gt;Spring&lt;/li&gt;&lt;li&gt;MySQL&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;I will post up some issues I had with it, and the solutions I came up with as I remember them, or come across new ones :).&lt;br /&gt;&lt;br /&gt;I hope my postings will help a few people out there, so stay tuned!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/33865970-115742041346474328?l=java-web-development.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/VOE6yMoNmyGu15syeG-3d_JRbb8/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/VOE6yMoNmyGu15syeG-3d_JRbb8/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/VOE6yMoNmyGu15syeG-3d_JRbb8/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/VOE6yMoNmyGu15syeG-3d_JRbb8/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/JavaWebDevelopment/~4/Tz8lFVc4P-g" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://java-web-development.blogspot.com/feeds/115742041346474328/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=33865970&amp;postID=115742041346474328" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/33865970/posts/default/115742041346474328?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/33865970/posts/default/115742041346474328?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/JavaWebDevelopment/~3/Tz8lFVc4P-g/welcome-after-spending-numerous-hours.html" title="" /><author><name>Simon</name><uri>http://www.blogger.com/profile/04059229290827090172</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><thr:total>0</thr:total><feedburner:origLink>http://java-web-development.blogspot.com/2006/09/welcome-after-spending-numerous-hours.html</feedburner:origLink></entry></feed>

