Nullpointer exception in com.sun.faces.config.InitFacesContext.cleanupInitMaps

I cannot deploy my war file to tomcat server. I get an exception.

SEVERE: ContainerBase.addChild: start: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/BatchApp-1.0.0.M1]] at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:154) at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901) at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877) at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:633) at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:977) at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1655) at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source) at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source) at java.util.concurrent.FutureTask.run(Unknown Source) at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) at java.lang.Thread.run(Unknown Source) Caused by: java.lang.NullPointerException at com.sun.faces.config.InitFacesContext.cleanupInitMaps(InitFacesContext.java:281) at com.sun.faces.config.InitFacesContext.<init>(InitFacesContext.java:107) at com.sun.faces.config.FacesInitializer.onStartup(FacesInitializer.java:115) at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5280) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) ... 11 more May 11, 2013 5:28:05 PM org.apache.catalina.startup.HostConfig deployWAR SEVERE: Error deploying web application archive C:\AppDev\Tomcat7.0\webapps\BatchApp-1.0.0.M1.war java.lang.IllegalStateException: ContainerBase.addChild: start: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/BatchApp-1.0.0.M1]] at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:904) at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877) at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:633) at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:977) at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1655) at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source) at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source) at java.util.concurrent.FutureTask.run(Unknown Source) at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) at java.lang.Thread.run(Unknown Source) 

I still debugged it and looked like this: @getInitContextServletContextMap () method in com.sun.faces.config.InitFacesContext. I get a return null pointer.

  static Map getInitContextServletContextMap() { ConcurrentHashMap initContextServletContext = null; try { Field initContextMap = FacesContext.class.getDeclaredField("initContextServletContext"); initContextMap.setAccessible(true); initContextServletContext = (ConcurrentHashMap)initContextMap.get(null); } catch (Exception e) { if (LOGGER.isLoggable(Level.FINEST)) { LOGGER.log(Level.FINEST, "Unable to get (init context, servlet context) map", e); } } return initContextServletContext; } 

It is filmed that the server is looking for "initContextServletContext", but where to install it?

Please let me know how I can solve this problem.

+6
source share
1 answer

There was the same error. This was a dependency problem: I used the Oracle JSF implementation (2.2.1), but one of my Maven dependencies was to use Apache MyFaces.

What happened is that the piece of code that you are showing, which is from impelementation Oracle, is trying to access the static private field FacesContext. But the class loader loaded the implementation of MyFaces from FacesContext, which does not have this field. Therefore barf.

Check your dependencies. I bet you will find that you have two different versions or two different versions of JSF.

+8
source

Source: https://habr.com/ru/post/944796/


All Articles