升级到 Struts 2.3.32。使用 getBaseTilesDefinitionURLs 获取空指针异常
Upgrading to Struts 2.3.32. Getting null pointer exception with getBaseTilesDefinitionURLs
我正在将现有应用程序升级到 Struts 2.3.32
,当我将应用程序添加到 WebSphere 7.0
服务器时,出现以下错误。
[3/14/17 10:43:28:135 CDT] 00000032 WASSessionCor I SessionContextRegistry getSessionContext SESN0176I: Will create a new session context for application key default_hostllr
[3/14/17 10:43:28:198 CDT] 00000032 StrutsTilesLi I com.opensymphony.xwork2.util.logging.commons.CommonsLogger info Starting Struts Tiles 2 integration ...
[3/14/17 10:43:28:276 CDT] 00000032 webapp E com.ibm.ws.webcontainer.webapp.WebApp notifyServletContextCreated SRVE0283E: Exception caught while initializing context: {0}
java.lang.NullPointerException
at org.apache.tiles.util.URLUtil.getBaseTilesDefinitionURLs(URLUtil.java:54)
at org.apache.struts2.tiles.StrutsTilesContainerFactory.getSourceURLs(StrutsTilesContainerFactory.java:229)
at org.apache.tiles.factory.BasicTilesContainerFactory.createLocaleDefinitionDao(BasicTilesContainerFactory.java:298)
at org.apache.tiles.factory.BasicTilesContainerFactory.createDefinitionsFactory(BasicTilesContainerFactory.java:242)
at org.apache.tiles.factory.BasicTilesContainerFactory.createContainer(BasicTilesContainerFactory.java:104)
at org.apache.tiles.startup.AbstractTilesInitializer.createContainer(AbstractTilesInitializer.java:124)
at org.apache.tiles.startup.AbstractTilesInitializer.initialize(AbstractTilesInitializer.java:70)
at org.apache.tiles.web.startup.AbstractTilesListener.contextInitialized(AbstractTilesListener.java:62)
我添加(或更新)到应用程序的 jar 文件是:
WEB-INF文件夹下所有的jar文件是:
根据我对 Aleksandr M 评论的理解,我从 web.xml
文件中删除了以下行。
<context-param>
<param-name> org.apache.tiles.impl.BasicTilesContainer.DEFINITIONS_CONFIG</param-name>
<param-value>/WEB-INF/tiles/tiles.xml,/WEB-INF/tiles/gis-tiles.xml </param-value>
</context-param>
我不再得到空指针异常。我还有其他问题正在解决,但这似乎已经解决了我最初询问的问题。
编辑:根据 Aleksandr 在此答案的评论中提供的 link,我发现问题是文件 WEB-INF/tiles/gis-tiles.xml
不存在,所以我将其从 <param-value>
元素.
我正在将现有应用程序升级到 Struts 2.3.32
,当我将应用程序添加到 WebSphere 7.0
服务器时,出现以下错误。
[3/14/17 10:43:28:135 CDT] 00000032 WASSessionCor I SessionContextRegistry getSessionContext SESN0176I: Will create a new session context for application key default_hostllr
[3/14/17 10:43:28:198 CDT] 00000032 StrutsTilesLi I com.opensymphony.xwork2.util.logging.commons.CommonsLogger info Starting Struts Tiles 2 integration ...
[3/14/17 10:43:28:276 CDT] 00000032 webapp E com.ibm.ws.webcontainer.webapp.WebApp notifyServletContextCreated SRVE0283E: Exception caught while initializing context: {0}
java.lang.NullPointerException
at org.apache.tiles.util.URLUtil.getBaseTilesDefinitionURLs(URLUtil.java:54)
at org.apache.struts2.tiles.StrutsTilesContainerFactory.getSourceURLs(StrutsTilesContainerFactory.java:229)
at org.apache.tiles.factory.BasicTilesContainerFactory.createLocaleDefinitionDao(BasicTilesContainerFactory.java:298)
at org.apache.tiles.factory.BasicTilesContainerFactory.createDefinitionsFactory(BasicTilesContainerFactory.java:242)
at org.apache.tiles.factory.BasicTilesContainerFactory.createContainer(BasicTilesContainerFactory.java:104)
at org.apache.tiles.startup.AbstractTilesInitializer.createContainer(AbstractTilesInitializer.java:124)
at org.apache.tiles.startup.AbstractTilesInitializer.initialize(AbstractTilesInitializer.java:70)
at org.apache.tiles.web.startup.AbstractTilesListener.contextInitialized(AbstractTilesListener.java:62)
我添加(或更新)到应用程序的 jar 文件是:
WEB-INF文件夹下所有的jar文件是:
根据我对 Aleksandr M 评论的理解,我从 web.xml
文件中删除了以下行。
<context-param>
<param-name> org.apache.tiles.impl.BasicTilesContainer.DEFINITIONS_CONFIG</param-name>
<param-value>/WEB-INF/tiles/tiles.xml,/WEB-INF/tiles/gis-tiles.xml </param-value>
</context-param>
我不再得到空指针异常。我还有其他问题正在解决,但这似乎已经解决了我最初询问的问题。
编辑:根据 Aleksandr 在此答案的评论中提供的 link,我发现问题是文件 WEB-INF/tiles/gis-tiles.xml
不存在,所以我将其从 <param-value>
元素.