FacesContext.getCurrentInstance() returns null in Runnable class

The FacesContext is stored as a ThreadLocal variable in the thread responsible for the HTTP request which invoked the FacesServlet, the one responsible for creating the FacesContext. This thread usually goes through the JSF managed bean methods only. The FacesContext is not available in other threads spawned by that thread. You should actually also not … Read more

createEntityManager throws java.lang.NullPointerException at org.hibernate.engine.transaction.internal.jta.JtaStatusHelper.getStatus

If you’re using Hibernate 4 and trying to create a EntityManagerFactory manually (or SessionFactory) declared as <jta-datasource>, there is a property you must set on your persistence.xml called hibernate.transaction.jta.platform. For using on JBoss 7 <property name=”hibernate.transaction.jta.platform” value=”org.hibernate.service.jta.platform.internal.JBossAppServerJtaPlatform” /> I found about this property at Hibernate Docs

Why ternary operation gives nullpointer while its ifelse counterpart doesn’t? [duplicate]

Here’s the relevant quote from the spec (§15.25.2): Boolean conditional expressions are standalone expressions (§15.2). The type of a boolean conditional expression is determined as follows: If the second and third operands are both of type Boolean, the conditional expression has type Boolean. Otherwise, the conditional expression has type boolean. Therefore, the overall expression’s type … Read more