Setting the default/welcome page for a JSF app

Since <welcome-file-list> only works with physical files, you cannot use a *.jsf filename here since this resolves to a different physical file (like *.xhtml).

To define a welcome file, use one of the following approaches:

    • add an index.html file, and include a refresh meta tag in the head:

      <head>
      <meta http-equiv="Refresh" content="0; URL=your_welcome_page.jsf">
      </head>

 

  • add an index.jsp file, and redirect to your welcome page:

    <% response.sendRedirect("dropdowns.jsf"); %>

Initializing a JSF ManagedBean

Sometimes things really are easy – the fact that I Googled how to do this now seems pretty silly. The more I use JSF the more I like it 🙂

To initialize the state of the ManagedBean that a JSF page is using (like to preload data, or initialize other displayed values), just call the code from the bean’s constructor. Simple as that.

For example

@ManagedBean
public class ExampleController
{
    private String exampleProperty1;
    private String exampleProperty2;

    public ExampleController()
    {
    //example init code here, e.g. to init property values
    }

    ...

}

Java 8 will ship without Project Jigsaw, modular dependencies for the Java platform

Around this time two years ago, Oracle gave the Java community two options for the upcoming Java 7 release, Plan A and Plan B, which looked something like this:

Plan A: JDK 7 (as currently defined) Mid 2012
Plan B: JDK 7 (minus Lambda, Jigsaw, and part of Coin) Mid 2011
        JDK 8 (Lambda, Jigsaw, the rest of Coin, ++) Late 2012

Oracle went with Plan B based on community feedback, and we got Java 7 earlier, just with a reduced list of changes.

Now we’re on the verge of seeing the release of Java 8, Oracle has some rather upsetting news that the major changes, namely Project Jigsaw (to introduce modular dependencies into the Java platform), will not be included in Java 8 after all.

I don’t want to see any product released before it’s ready, there’s no point shipping something if its half-baked. But with the Plan A/Plan B approach it seems somehow that we’ve been short-changed. We agreed to delay significant changes to a future release just to keep the new releases coming, and now we’re at the point where we should have received the most significant platform changes that were originally planned for Java 7, to be included in Java 8, and Oracle is telling us ‘sorry, they’re not ready’.  At this point one has to wonder where Oracle’s priorities are with Java, because it’s certainly not looking very promising right now.

Configuring an @MessageDriven bean on JBoss AS7

If you forget to add the destination property to the activationConfig for an MDB, when deploying to JBoss AS7 you’ll get this NullPointerException. Would be better if it told you what required property was missing:

16:30:29,007 WARN  [org.hornetq.ra.inflow.HornetQActivation] (default-short-running-threads-threads - 1) Failure in HornetQ activation org.hornetq.ra.inflow.HornetQActivationSpec(ra=org.hornetq.ra.HornetQResourceAdapter@6ba59338 destination=null destinationType=javax.jms.Queue ack=Auto-acknowledge durable=false clientID=null user=null maxSession=15): java.lang.NullPointerException
    at javax.naming.NameImpl.<init>(NameImpl.java:281) [rt.jar:1.7.0_04]
    at javax.naming.CompositeName.<init>(CompositeName.java:231) [rt.jar:1.7.0_04]
    at org.jboss.as.naming.util.NameParser.parse(NameParser.java:49)
    at org.jboss.as.naming.NamingContext.parseName(NamingContext.java:440)
    at org.jboss.as.naming.NamingContext.lookup(NamingContext.java:213)
    at javax.naming.InitialContext.lookup(InitialContext.java:411) [rt.jar:1.7.0_04]
    at org.hornetq.ra.Util.lookup(Util.java:174) [hornetq-ra-2.2.11.Final.jar:]
    at org.hornetq.ra.inflow.HornetQActivation.setupDestination(HornetQActivation.java:454) [hornetq-ra-2.2.11.Final.jar:]
    at org.hornetq.ra.inflow.HornetQActivation.setup(HornetQActivation.java:287) [hornetq-ra-2.2.11.Final.jar:]
    at org.hornetq.ra.inflow.HornetQActivation$SetupActivation.run(HornetQActivation.java:605) [hornetq-ra-2.2.11.Final.jar:]
    at org.jboss.jca.core.workmanager.WorkWrapper.run(WorkWrapper.java:212)
    at org.jboss.threads.SimpleDirectExecutor.execute(SimpleDirectExecutor.java:33)
    at org.jboss.threads.QueueExecutor.runTask(QueueExecutor.java:801)
    at org.jboss.threads.QueueExecutor.access$100(QueueExecutor.java:45)
    at org.jboss.threads.QueueExecutor$Worker.run(QueueExecutor.java:821)
    at java.lang.Thread.run(Thread.java:722) [rt.jar:1.7.0_04]
    at org.jboss.threads.JBossThread.run(JBossThread.java:122)

Here’s a correctly configured MDB:

@MessageDriven(mappedName = "queue/QueueName", activationConfig = {
        @ActivationConfigProperty(propertyName = "acknowledgeMode", propertyValue = "Auto-acknowledge"),
        @ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue"),
        @ActivationConfigProperty(propertyName = "destination", propertyValue = "queue/queueName") })
public class QueueListener implements MessageListener {
...
}