1

I am using TomEE Plus 1.7.2 Server and try to start a webapp with OmniFaces included, but I get a Nullpointer exception:

WARNUNG: Could not instantiate eager request scoped beans for request /index.xhtml. Possibly the CDI request scope is not active. If this is indeed the case, see JavaDoc on org.omnifaces.cdi.Eager on how to remedy this.

java.lang.NullPointerException at org.omnifaces.cdi.eager.EagerBeansWebListener.requestInitialized(EagerBeansWebListener.java:78)

When I use the EagerBeansFilter as shown at OmniFaces docs, I get a slight variation:

WARNUNG: Could not instantiate eager application scoped beans. Possibly the CDI application scope is not active. This is known to be the case in certain Tomcat and Jetty based configurations.

java.lang.NullPointerException at org.omnifaces.cdi.eager.EagerBeansRepository.instantiateApplicationScopedAndRegisterListener(EagerBeansRepository.java:69)

Is this server not combinable with omnifaces?

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
Lemao1981
  • 2,225
  • 5
  • 18
  • 30
  • Which OmniFaces version exactly? You can find compatibility matrix here: https://github.com/omnifaces/omnifaces/wiki/Compatibility-Matrix TomEE is one of most tested servers. Is the webapp designed for Tomcat or Java EE? TomEE is definitely not comparable to Tomcat. Any Tomcat (or Jetty or any other custom stack) targeted webapp will fail in some way when deployed to a standard Java EE server. – BalusC Apr 11 '16 at 07:46
  • Problem at least suggests a misconfigured CDI environment. Perhaps webapp is indeed Tomcat targeted and bundles some CDI libraries along while that's completely unnecessary when deployed on a standard Java EE server which already provides several Java EE API implementations such as CDI (and JSF!) out the box. – BalusC Apr 11 '16 at 07:54
  • ok, problem seemed to be omnifaces-version related: I was using 2.2-RC2, now updated to 2.3 and no exception anymore! – Lemao1981 Apr 11 '16 at 08:13
  • I'd rather suspect a dirty build. Or does it also fail with 2.2 and 2.1 (non-RC)? – BalusC Apr 11 '16 at 08:24
  • Technically, 2.2 or newer shouldn't deploy on a stock TomEE 1.x because it uses JSF 2.1 instead of JSF 2.2. So likely your TomEE instance has been modified to use JSF 2.2. – BalusC Apr 11 '16 at 08:38
  • so I tried with 2.1 and 2.2 non-RC and it´s working fine, but as soon as I use the 2.2-RC2 I get the error. the webapp was set up by IDE (IntelliJ, I think Java EE setup) don´t remember the server setup at the beginning, maybe I switched the server from Tomcat to TomEE. it´s just a tiny training webapp, nothing fancy – Lemao1981 Apr 12 '16 at 04:36

1 Answers1

2

TomEE is after WildFly one of most tested servers for OmniFaces, particularly because it uses almost everywhere in Java EE a different implementation as compared to WildFly (Apache vs Oracle). In the OmniFaces compatibility matrix you can find TomEE versions which successfully ran through all pages in OmniFaces showcase.

Those exceptions mentioned in your question will be thrown when CDI BeanManager couldn't find the OmniFaces EagerBeansRepository, which is an @ApplicationScoped bean. This in turn indicates a misconfigured CDI environment (e.g. wrong beans.xml or missing JNDI/listener configuration) or a dirty build (e.g. duplicate libraries). Verifying the CDI configuration and performing a full clean/rebuild should solve the problem.

At least, OmniFaces 2.2 or newer is technically incompatible with TomEE 1.x, because TomEE 1.x ships with JSF 2.1 and OmniFaces 2.2 or newer has a hard dependency on JSF 2.2 due to new <o:viewAction> tag. So, unless you modify TomEE to provide JSF 2.2, OmniFaces 2.2 or newer won't deploy and should fail deployment with below exception:

java.lang.NoClassDefFoundError: javax/faces/component/UIViewAction

The latest OmniFaces version which successfully deploys on a stock TomEE 1.7.x server is OmniFaces 2.1. If you want to use OmniFaces 2.2 or newer on a stock TomEE, then you need to upgrade to TomEE 7.x.

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555