0

i have problems with deploying my jsf-application on the upserver. starting tomcat results in the following exception:

14-Jul-2016 07:26:52.661 SEVERE [localhost-startStop-1] com.sun.faces.config.ConfigureListener.contextInitialized Critical error during deployment: 
 java.lang.ExceptionInInitializerError
    at org.omnifaces.util.Beans.getManager(Beans.java:88)
    at org.omnifaces.util.Beans.getReference(Beans.java:113)
    at org.omnifaces.application.OmniApplication.<init>(OmniApplication.java:70)
    at org.omnifaces.application.OmniApplicationFactory.createOmniApplication(OmniApplicationFactory.java:89)
    at org.omnifaces.application.OmniApplicationFactory.getApplication(OmniApplicationFactory.java:54)
    at com.sun.faces.application.InjectionApplicationFactory.getApplication(InjectionApplicationFactory.java:93)
    at com.sun.faces.config.InitFacesContext.getApplication(InitFacesContext.java:142)
    at com.sun.faces.lifecycle.ClientWindowFactoryImpl.<init>(ClientWindowFactoryImpl.java:62)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
    at java.lang.Class.newInstance(Class.java:442)
    at javax.faces.FactoryFinderInstance.getImplGivenPreviousImpl(FactoryFinderInstance.java:405)
    at javax.faces.FactoryFinderInstance.getImplementationInstance(FactoryFinderInstance.java:251)
    at javax.faces.FactoryFinderInstance.getFactory(FactoryFinderInstance.java:543)
    at javax.faces.FactoryFinder.getFactory(FactoryFinder.java:283)
    at com.sun.faces.config.processor.FactoryConfigProcessor.verifyFactoriesExist(FactoryConfigProcessor.java:328)
    at com.sun.faces.config.processor.FactoryConfigProcessor.process(FactoryConfigProcessor.java:236)
    at com.sun.faces.config.ConfigManager.initialize(ConfigManager.java:439)
    at com.sun.faces.config.ConfigureListener.contextInitialized(ConfigureListener.java:227)
    at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4842)
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5303)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:147)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1407)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1397)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.IllegalStateException: CDI BeanManager instance is not available in JNDI.
    at org.omnifaces.config.BeanManager.<init>(BeanManager.java:97)
    at org.omnifaces.config.BeanManager.<clinit>(BeanManager.java:47)
    ... 30 more
Caused by: java.lang.IllegalStateException: javax.naming.NamingException: Cannot create resource instance
    at org.omnifaces.util.JNDI.lookup(JNDI.java:95)
    at org.omnifaces.config.BeanManager.<init>(BeanManager.java:93)
    ... 31 more
Caused by: javax.naming.NamingException: Cannot create resource instance
    at org.apache.naming.factory.FactoryBase.getObjectInstance(FactoryBase.java:96)
    at javax.naming.spi.NamingManager.getObjectInstance(NamingManager.java:321)
    at org.apache.naming.NamingContext.lookup(NamingContext.java:841)
    at org.apache.naming.NamingContext.lookup(NamingContext.java:152)
    at org.apache.naming.NamingContext.lookup(NamingContext.java:829)
    at org.apache.naming.NamingContext.lookup(NamingContext.java:152)
    at org.apache.naming.NamingContext.lookup(NamingContext.java:829)
    at org.apache.naming.NamingContext.lookup(NamingContext.java:166)
    at org.apache.naming.SelectorContext.lookup(SelectorContext.java:157)
    at javax.naming.InitialContext.lookup(InitialContext.java:417)
    at org.omnifaces.util.JNDI.lookup(JNDI.java:90)
    ... 32 more

14-Jul-2016 07:26:52.665 SEVERE [localhost-startStop-1] org.omnifaces.ApplicationListener.checkCDIAvailable 
????????????????????????????????????????????????????????????????????????????????
?                         ??     ?                                             ?
?    ?                  ?????    ? OmniFaces failed to initialize!             ?
?   ????               ??????    ?                                             ?
?   ??????            ???????    ? This OmniFaces version requires CDI, but    ?
?   ???????          ???????     ? none was found on this environment.         ?
?    ???????????????????????     ?                                             ?
?    ???????????????????????     ? OmniFaces 2.x requires a minimum of JSF 2.2.?
?     ?????????????????????      ? Since this JSF version, the JSF managed bean?
?     ?????????????????????      ? facility @ManagedBean is semi-official      ?
?     ??????????????????????     ? deprecated in favour of CDI. JSF 2.2 users  ?
?     ??????????????????????     ? are strongly encouraged to move to CDI.     ?
?     ??????????????????????     ?                                             ?
?    ???????????????????????     ? OmniFaces goes a step further by making CDI ?
?    ????????????????????????    ? a REQUIRED dependency next to JSF 2.2. This ?
?    ????????????????????????    ? not only ensures that your web application  ?
?   ???????????????? ????????    ? represents the state of art, but this also  ?
?   ?????????????????????????    ? makes for us easier to develop OmniFaces,   ?
?   ??????????????????????????   ? without the need for all sorts of hacks in  ?
?   ??????????????????????????   ? in order to get OmniFaces to deploy on      ?
?  ????????????????????????????  ? environments without CDI.                   ?
?  ????????????????????????????  ?                                             ?
?  ????????????????????????????  ? You have 3 options:                         ?
?????????????????????????????????? 1. Downgrade to OmniFaces 1.x.              ?
?????????????????????????????????? 2. Install CDI in this environment.         ?
?????????????????????????????????? 3. Switch to a CDI capable environment.     ?
??????????????????????????????????                                             ?
?????????????????????????????????? For additional instructions, check          ?
?????????????????????????????????? http://omnifaces.org/cdi                    ?
??????????????????????????????????                                             ?
????????????????????????????????????????????????????????????????????????????????
14-Jul-2016 07:26:52.682 INFO [localhost-startStop-1] com.sun.faces.config.ConfigureListener.contextInitialized Initializing Mojarra 2.2.12 ( 20150720-0848 https://svn.java.net/svn/mojarra~svn/tags/2.2.12@14885) for context '/protano'
14-Jul-2016 07:26:52.840 INFO [localhost-startStop-1] com.sun.faces.spi.InjectionProviderFactory.createInstance JSF1048: PostConstruct/PreDestroy annotations present.  ManagedBeans methods marked with these annotations will have said annotations processed.
14-Jul-2016 07:26:52.872 SEVERE [localhost-startStop-1] com.sun.faces.config.ConfigureListener.contextInitialized Critical error during deployment: 
 java.lang.NoClassDefFoundError: Could not initialize class org.omnifaces.config.BeanManager
    at org.omnifaces.util.Beans.getManager(Beans.java:88)
    at org.omnifaces.util.Beans.getReference(Beans.java:113)
    at org.omnifaces.application.OmniApplication.<init>(OmniApplication.java:70)
    at org.omnifaces.application.OmniApplicationFactory.createOmniApplication(OmniApplicationFactory.java:89)
    at org.omnifaces.application.OmniApplicationFactory.getApplication(OmniApplicationFactory.java:54)
    at com.sun.faces.application.InjectionApplicationFactory.getApplication(InjectionApplicationFactory.java:93)
    at com.sun.faces.config.InitFacesContext.getApplication(InitFacesContext.java:142)
    at com.sun.faces.lifecycle.ClientWindowFactoryImpl.<init>(ClientWindowFactoryImpl.java:62)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
    at java.lang.Class.newInstance(Class.java:442)
    at javax.faces.FactoryFinderInstance.getImplGivenPreviousImpl(FactoryFinderInstance.java:405)
    at javax.faces.FactoryFinderInstance.getImplementationInstance(FactoryFinderInstance.java:251)
    at javax.faces.FactoryFinderInstance.getFactory(FactoryFinderInstance.java:543)
    at javax.faces.FactoryFinder.getFactory(FactoryFinder.java:283)
    at com.sun.faces.config.processor.FactoryConfigProcessor.verifyFactoriesExist(FactoryConfigProcessor.java:328)
    at com.sun.faces.config.processor.FactoryConfigProcessor.process(FactoryConfigProcessor.java:236)
    at com.sun.faces.config.ConfigManager.initialize(ConfigManager.java:439)
    at com.sun.faces.config.ConfigureListener.contextInitialized(ConfigureListener.java:227)
    at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4840)
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5303)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:147)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1407)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1397)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)

14-Jul-2016 07:26:52.889 SEVERE [localhost-startStop-1] org.apache.catalina.core.StandardContext.startInternal One or more listeners failed to start.

in my local enviroment it works fine. i already checked all affected files for presence and values:

WEB-INF
-(empty) beans.xml

WEB-INF/lib
-cdi-api-1.2.jar
-weld-servlet-2.2.9.Final.jar

META-INF
context.xml with following content:

 <Context>
   <Resource name="BeanManager" 
      auth="Container"
      type="javax.enterprise.inject.spi.BeanManager"
      factory="org.jboss.weld.resources.ManagerObjectFactory"/>
 </Context>

Enviroment:
java 8
mojarra 2.2.12
omnifaces 2.4
tomcat: 8.0.36 with cdi installed, carefully followed the steps given here:
http://balusc.omnifaces.org/2013/10/how-to-install-cdi-in-tomcat.html

there is a similar topic which is not helpful. for me the solution is unclear. Omnifaces exception on deployment on Tomcat 7

any other help/advice would be much appreciated.

Community
  • 1
  • 1
Steve
  • 384
  • 1
  • 7
  • 17
  • 1
    What's the difference of that "upserver" with your local server? – BalusC Jul 14 '16 at 09:03
  • pardon - the term "upserver" refers to the machine. that's a linux-server (ubuntu). locally i use a windows 7 machine. on both machines the same java- and tomcat (8.0.36) enviroments are running. – Steve Jul 14 '16 at 09:10
  • Exception doesn't indicate they are the same. Only oddness I can see in information provided so far is that the`cdi-api-1.2.jar` doesn't belong there (already bundled in that Weld JAR). The stack trace ordering is also unexpected and indicates duplicate JSF libraries in runtime classpath. – BalusC Jul 14 '16 at 09:12
  • after reviewing everything and discarding cdi-api-1.2.jar i am getting com.sun.faces.config.ConfigurationException: Factory 'javax.faces.lifecycle.ClientWindowFactory' was not configured properly. Caused by: java.lang.NullPointerException. at org.omnifaces.util.BeansLocal.resolve(BeansLocal.java:68) at org.omnifaces.util.BeansLocal.getReference(BeansLocal.java:84) maybe switching to TomEE is an alternative? – Steve Jul 14 '16 at 10:21
  • This confirms classpath pollution with duplicate JSF libraries once more. – BalusC Jul 14 '16 at 10:58
  • but how to identify/resolve a polluted classpath? tomcat itself has only its self-shipped jars under /opt/tomcat/bin (in 8.0.36 currently 24 jars). under project's WEB-INF/lib there aren't any duplicate jars: -omnifaces-2.4.jar, weld-servlet-2.2.9.final.jar, javax.faces-2.2.12.jar - all the basic jars are there once. – Steve Jul 14 '16 at 11:40
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/117321/discussion-between-steve-and-balusc). – Steve Jul 14 '16 at 12:10

1 Answers1

1

When you work with eclipse and its wtp-server-plugin and rely on "clean tomcat working directory" the most time, you may forget to cleanup tomcat's work folder also when a deploy fails on production enviroments.

after deletion of
tomcat/webapps/appName
tomcat/webapps/appName.war
tomcat/work

i redeployed and the errors went away.

Steve
  • 384
  • 1
  • 7
  • 17