Error - Tag Insert : no value defined for bean - struts-1

i'm new to struts. i will use struts tile in my Java EE project.
i read following page that illustrate how to use tile.
struts tiles examples
i read the page and try do all thing that mentained in the page. in the below you can my files detail.
struts-config.xml:
<plug-in className="org.apache.struts.tiles.TilesPlugin">
<set-property property="definitions-config" value="/WEB-INF/tiles-defs.xml" />
<set-property property="moduleAware" value="true" />
</plug-in>
tiles-defs.xml:
<tiles-definitions>
<definition name="role.list" path="/WEB-INF/content/layout.jsp">
<put name="body" value="/WEB-INF/content/admin/restricted/role_list_body.jsp"
type="page" />
</definition>
role_list_body.jsp:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
List of Roles
</body>
</html>
and role_list.jsp is:
<body>
<sTile:insert beanName="role.list"/>
</body>
i think all of things is correct. but when i call role_list.jsp i get following error:
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
org.apache.jasper.JasperException: javax.servlet.ServletException: javax.servlet.jsp.JspException: Error - Tag Insert : No value defined for bean 'role.list' with property 'null' in scope 'null'.
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:534)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:442)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:391)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
root cause
javax.servlet.ServletException: javax.servlet.jsp.JspException: Error - Tag Insert : No value defined for bean 'role.list' with property 'null' in scope 'null'.
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:911)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:840)
org.apache.jsp.WEB_002dINF.content.admin.restericted.role.role_005flist_jsp._jspService(role_005flist_jsp.java:80)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:419)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:391)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
root cause
javax.servlet.jsp.JspException: Error - Tag Insert : No value defined for bean 'role.list' with property 'null' in scope 'null'.
org.apache.struts.tiles.taglib.InsertTag.processBean(InsertTag.java:667)
org.apache.struts.tiles.taglib.InsertTag.createTagHandler(InsertTag.java:483)
org.apache.struts.tiles.taglib.InsertTag.doStartTag(InsertTag.java:441)
org.apache.jsp.WEB_002dINF.content.admin.restericted.role.role_005flist_jsp._jspx_meth_sTile_005finsert_005f0(role_005flist_jsp.java:97)
org.apache.jsp.WEB_002dINF.content.admin.restericted.role.role_005flist_jsp._jspService(role_005flist_jsp.java:70)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:419)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:391)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
note The full stack trace of the root cause is available in the Apache Tomcat/7.0.12 logs.
do you know what this problem occourred.
thanks.

i find problem.
in the role_list.jsp i replace
<sTile:insert beanName="role.list" /> with <sTile:insert definition="role.list" />
now it works true.

Related

Getting this error while working on Spring MVC and Apache tiles

I am not sure where the error is.
message
Request processing failed; nested exception is org.apache.tiles.impl.CannotRenderException:
org.apache.tiles.util.TilesIOException:
JSPException including path '/WEB-INF/views/hotels/enterBookingInfo.jsp'.
description The server encountered an internal error that prevented it from fulfilling this request.
exception
org.springframework.web.util.NestedServletException:
Request processing failed; nested exception is org.apache.tiles.impl.CannotRenderException:
org.apache.tiles.util.TilesIOException: JSPException including path '/WEB-INF/views/hotels/enterBookingInfo.jsp'.
org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:656)
org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:549)
javax.servlet.http.HttpServlet.service(HttpServlet.java:624)
javax.servlet.http.HttpServlet.service(HttpServlet.java:731)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:77)
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
root cause
org.apache.tiles.impl.CannotRenderException: org.apache.tiles.util.TilesIOException:
JSPException including path '/WEB-INF/views/hotels/enterBookingInfo.jsp'.
org.apache.tiles.impl.BasicTilesContainer.render(BasicTilesContainer.java:692)
org.apache.tiles.impl.BasicTilesContainer.render(BasicTilesContainer.java:644)
org.apache.tiles.impl.BasicTilesContainer.render(BasicTilesContainer.java:627)
org.apache.tiles.impl.BasicTilesContainer.render(BasicTilesContainer.java:321)
org.springframework.web.servlet.view.tiles2.TilesView.renderMergedOutputModel(TilesView.java:124)
org.springframework.js.ajax.tiles2.AjaxTilesView.renderMergedOutputModel(AjaxTilesView.java:131)
org.springframework.web.servlet.view.AbstractView.render(AbstractView.java:250)
org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1047)
org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:817)
org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:719)
org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:644)
org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:549)
javax.servlet.http.HttpServlet.service(HttpServlet.java:624)
javax.servlet.http.HttpServlet.service(HttpServlet.java:731)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:77)
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
tiles.xml defintion is as follows
<tiles-definitions>
<definition name="enterBookingInfo" extends="standardLayout">
<put-attribute name="body" value="/WEB-INF/views/hotels/enterBookingInfo.jsp"> </put-attribute>
</definition>
</tiles-definitions>
Tiles configuration extract
<beans:bean id="tilesConfigurer" class="org.springframework.web.servlet.view.tiles2.TilesConfigurer">
<beans:property name="definitions">
<beans:value>
/WEB-INF/**/tiles.xml
</beans:value>
</beans:property>
</beans:bean>
I got this resolved by setting the commandName attribute of the form to the name of the modelAttribute object used in my controller.
I also had to modify the method syntax to have BindingResult parameter which had to follow the ModelAttribute object.
public String ultimateBooking(#RequestParam("hotelId") String hotelId,#ModelAttribute("booking") Booking bookingValidation,BindingResult result,ModelMap model)
No changes were made to tile.xml

JSF Composite Component: Unable to resolve composite component from using page using EL expression

I studied some similar questions here on stackoverflow, but none of them seem to nail my problem...
I wrote a (kind of simple) composite component:
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:composite="http://java.sun.com/jsf/composite">
<composite:interface>
<composite:attribute name="buttonValue" />
<composite:attribute name="ajaxExecute" />
<composite:attribute name="ajaxRender" />
<composite:attribute name="ajaxListener" />
</composite:interface>
<composite:implementation>
<h:commandButton value="#{cc.attrs.buttonValue}">
<f:ajax execute="#{cc.attrs.ajaxExecute}"
render="#{cc.attrs.ajaxRender}" listener="#{cc.attrs.ajaxListener}" />
</h:commandButton>
</composite:implementation>
</html>
And included this one into my view like so:
<my:ajaxCommandButton
buttonValue="foo"
ajaxExecute=""
ajaxRender=""
ajaxListener="#{viewBacking.resend()}"></my:ajaxCommandButton>
The interesting thing is - this guy works like a champ (!) - every time I click on it, the bean method is called and all seems to be wonderful.
Unfortunately I get this stuff logged out with every click on the button:
20160229:143610.598 [http-/0.0.0.0:8080-2] WARNING javax.enterprise.resource.webcontainer.jsf.lifecycle - Unable to resolve composite component from using page using EL expression '#{cc.attrs.ajaxListener}': javax.faces.FacesException: Unable to resolve composite component from using page using EL expression '#{cc.attrs.ajaxListener}'
at com.sun.faces.facelets.tag.TagAttributeImpl$AttributeLookupMethodExpression.invoke(TagAttributeImpl.java:444) [jsf-impl-2.1.28.redhat-8.jar:2.1.28.redhat-8]
at com.sun.faces.facelets.tag.jsf.core.AjaxBehaviorListenerImpl.processAjaxBehavior(AjaxHandler.java:447) [jsf-impl-2.1.28.redhat-8.jar:2.1.28.redhat-8]
at javax.faces.event.AjaxBehaviorEvent.processListener(AjaxBehaviorEvent.java:113) [jboss-jsf-api_2.1_spec-2.1.28.Final-redhat-1.jar:2.1.28.Final-redhat-1]
at javax.faces.component.behavior.BehaviorBase.broadcast(BehaviorBase.java:106) [jboss-jsf-api_2.1_spec-2.1.28.Final-redhat-1.jar:2.1.28.Final-redhat-1]
at javax.faces.component.UIComponentBase.broadcast(UIComponentBase.java:762) [jboss-jsf-api_2.1_spec-2.1.28.Final-redhat-1.jar:2.1.28.Final-redhat-1]
at javax.faces.component.UICommand.broadcast(UICommand.java:300) [jboss-jsf-api_2.1_spec-2.1.28.Final-redhat-1.jar:2.1.28.Final-redhat-1]
at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:786) [jboss-jsf-api_2.1_spec-2.1.28.Final-redhat-1.jar:2.1.28.Final-redhat-1]
at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:1251) [jboss-jsf-api_2.1_spec-2.1.28.Final-redhat-1.jar:2.1.28.Final-redhat-1]
at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:81) [jsf-impl-2.1.28.redhat-8.jar:2.1.28.redhat-8]
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101) [jsf-impl-2.1.28.redhat-8.jar:2.1.28.redhat-8]
at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118) [jsf-impl-2.1.28.redhat-8.jar:2.1.28.redhat-8]
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:593) [jboss-jsf-api_2.1_spec-2.1.28.Final-redhat-1.jar:2.1.28.Final-redhat-1]
[...]
20160229:143610.600 [http-/0.0.0.0:8080-2] SEVERE javax.enterprise.resource.webcontainer.jsf.context - javax.faces.FacesException: Unable to resolve composite component from using page using EL expression '#{cc.attrs.ajaxListener}'
at com.sun.faces.facelets.tag.TagAttributeImpl$AttributeLookupMethodExpression.invoke(TagAttributeImpl.java:444)
at com.sun.faces.facelets.tag.jsf.core.AjaxBehaviorListenerImpl.processAjaxBehavior(AjaxHandler.java:447)
at javax.faces.event.AjaxBehaviorEvent.processListener(AjaxBehaviorEvent.java:113)
at javax.faces.component.behavior.BehaviorBase.broadcast(BehaviorBase.java:106)
at javax.faces.component.UIComponentBase.broadcast(UIComponentBase.java:762)
at javax.faces.component.UICommand.broadcast(UICommand.java:300)
at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:786)
at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:1251)
at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:81)
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:593)
Anyone with an idea for me? Thanks a lot in advance!
Just an idea - add the method-signature attribute to:
<composite:attribute name="ajaxListener" />

spring mvc and ReloadableResourceBundleMessageSource

I am trying to build a spring MVC application (basically for self trainning reasons). This application has spring MVC, tiles, spring thems and jsp (sorry for numbering all but since i am not sure what i do wrong, i just wish to number all i think may help you help me).
my spring mvc configuration seems to work, untill i try to get message property from property files through org.springframework.context.support.ReloadableResourceBundleMessageSource.
so here is my configuration
<bean id="messageSource" class="org.springframework.context.support.ReloadableResourceBundleMessageSource" p:cacheSeconds="3000">
<property name="basenames">
<list>
<value>messages</value>
<value>dev</value>
<value>theme</value>
</list>
</property>
</bean>
<bean id="tilesConfigurer" class="org.springframework.web.servlet.view.tiles2.TilesConfigurer" p:definitions="/WEB-INF/tiles-defs/tiles-defs.xml" />
<bean id="tilesViewResolver" class="org.springframework.web.servlet.view.ResourceBundleViewResolver" p:basename="views" />
<!-- Declare the Interceptor -->
<bean id="localeChangeInterceptor" class="org.springframework.web.servlet.i18n.LocaleChangeInterceptor" p:paramName="language"/>
<bean id="themeChangeInterceptor" class="org.springframework.web.servlet.theme.ThemeChangeInterceptor" p:paramName="theme"/>
<!-- Declare the Resolver -->
<bean id="localeResolver" class="org.springframework.web.servlet.i18n.SessionLocaleResolver"/>
<bean id="themeResolver" class="org.springframework.web.servlet.theme.SessionThemeResolver"/>
<!-- Spring themes -->
<bean class="org.springframework.web.servlet.mvc.support.ControllerClassNameHandlerMapping">
<property name="interceptors">
<list>
<ref local="themeChangeInterceptor" />
<ref bean="localeChangeInterceptor" />
</list>
</property>
</bean>
tiles and theme seem to work, so in my tiles baselayout i have:
<title><tiles:insertAttribute name="title" ignore="true" /></title>
<c:set var="css"><spring:theme code="css"/></c:set>
<c:if test="${not empty css}">
<link rel="stylesheet" href="<c:url value='${css}'/>" type="text/css"/>
</c:if>
this works! html is rendered with the correct css that i have in css property located inside theme.properties file loaded from ReloadableResourceBundleMessageSource and magically existing inside tiles!
So, getting courage i go to my jsp and insert
attempt 1:
<p><spring:message code="context"/></p>
attempt 2:
<p><fmt:message key="context"/></p>
tags used:
<%# taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
(is there a difference? both work? seen both over web... so i tried once the first and then the second one)
and in the messages.properties/messages_el_gr.properties files i type context=default and context=greek.
This gives me exception in the first case and in the second just the string context prefixed and postfixed with ???.
Exception i get is:
SEVERE: Servlet.service() for servlet [dispatcher] in context with path [/homeAutomation] threw exception [Request processing failed; nested exception is org.apache.tiles.impl.CannotRenderException: ServletException including path '/WEB-INF/tiles/baseLayout.jsp'.] with root cause
javax.servlet.jsp.JspTagException: No message found under code 'context' for locale 'el_GR'.
at org.springframework.web.servlet.tags.MessageTag.doStartTagInternal(MessageTag.java:184)
at org.springframework.web.servlet.tags.RequestContextAwareTag.doStartTag(RequestContextAwareTag.java:79)
at org.apache.jsp.WEB_002dINF.jsp.friends_jsp._jspx_meth_spring_005fmessage_005f0(friends_jsp.java:104)
at org.apache.jsp.WEB_002dINF.jsp.friends_jsp._jspService(friends_jsp.java:75)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:419)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:333)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:304)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:684)
at org.apache.catalina.core.ApplicationDispatcher.doInclude(ApplicationDispatcher.java:593)
at org.apache.catalina.core.ApplicationDispatcher.include(ApplicationDispatcher.java:530)
at org.apache.jasper.runtime.JspRuntimeLibrary.include(JspRuntimeLibrary.java:927)
at org.apache.jasper.runtime.PageContextImpl.doInclude(PageContextImpl.java:684)
at org.apache.jasper.runtime.PageContextImpl.include(PageContextImpl.java:678)
at org.apache.tiles.jsp.context.JspTilesRequestContext.include(JspTilesRequestContext.java:103)
at org.apache.tiles.jsp.context.JspTilesRequestContext.dispatch(JspTilesRequestContext.java:96)
at org.apache.tiles.renderer.impl.TemplateAttributeRenderer.write(TemplateAttributeRenderer.java:44)
at org.apache.tiles.renderer.impl.AbstractBaseAttributeRenderer.render(AbstractBaseAttributeRenderer.java:106)
at org.apache.tiles.renderer.impl.ChainedDelegateAttributeRenderer.write(ChainedDelegateAttributeRenderer.java:76)
at org.apache.tiles.renderer.impl.AbstractBaseAttributeRenderer.render(AbstractBaseAttributeRenderer.java:106)
at org.apache.tiles.impl.BasicTilesContainer.render(BasicTilesContainer.java:670)
at org.apache.tiles.impl.BasicTilesContainer.render(BasicTilesContainer.java:336)
at org.apache.tiles.template.InsertAttributeModel.renderAttribute(InsertAttributeModel.java:210)
at org.apache.tiles.template.InsertAttributeModel.end(InsertAttributeModel.java:126)
at org.apache.tiles.jsp.taglib.InsertAttributeTag.doTag(InsertAttributeTag.java:311)
at org.apache.jsp.WEB_002dINF.tiles.baseLayout_jsp._jspx_meth_tiles_005finsertAttribute_005f3(baseLayout_jsp.java:307)
at org.apache.jsp.WEB_002dINF.tiles.baseLayout_jsp._jspService(baseLayout_jsp.java:108)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:419)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:333)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:304)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:684)
at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:471)
at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:402)
at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:329)
at org.apache.tiles.servlet.context.ServletTilesRequestContext.forward(ServletTilesRequestContext.java:241)
at org.apache.tiles.servlet.context.ServletTilesRequestContext.dispatch(ServletTilesRequestContext.java:222)
at org.apache.tiles.renderer.impl.TemplateAttributeRenderer.write(TemplateAttributeRenderer.java:44)
at org.apache.tiles.renderer.impl.AbstractBaseAttributeRenderer.render(AbstractBaseAttributeRenderer.java:106)
at org.apache.tiles.impl.BasicTilesContainer.render(BasicTilesContainer.java:670)
at org.apache.tiles.impl.BasicTilesContainer.render(BasicTilesContainer.java:690)
at org.apache.tiles.impl.BasicTilesContainer.render(BasicTilesContainer.java:644)
at org.apache.tiles.impl.BasicTilesContainer.render(BasicTilesContainer.java:627)
at org.apache.tiles.impl.BasicTilesContainer.render(BasicTilesContainer.java:321)
at ......
I consider that i do not have the messageSource inside my context, so i considered as next step of searching what is going on to do the following (found on web)
#Autowired
ReloadableResourceBundleMessageSource messageSource;
#RequestMapping("/friends.htm")
public ModelAndView getPage()
{
ModelAndView modelAndView=new ModelAndView("friends");
modelAndView.addObject(messageSource);
return modelAndView;
}
by the way, my previeus controller had that method as follows:
#RequestMapping("/friends.htm")
public String getPage()
{
return friends;
}
This again throws same exception.. messageSource is not null.. it is autowired.
if i do inside the controller:messageSource.getMessage("context", null, Locale.ENGLISH), this throws the same exception when trying to get it.. (Greek locale does not exist?? with english it will go to default locale properties file which is messages.properties, correct?)
Ah, what else can i give you... yes property files are located in the src/main/resources directory and in war inside homeAutomation.war\WEB-INF\classes\ and homeAutomation.war (why?? i thought these would exist only in homeautomation.war directory... but skip this, atleast they are there...) my poms war plugin configuration is as follows:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.1.1</version>
<configuration>
<webResources>
<resource>
<directory>src/main/resources</directory>
</resource>
</webResources>
</configuration>
</plugin>
in target directory again i see the property files in both target\classes directory and target\homeAutomation.
After all these, i still do not know what i do wrong and i cannot get localized properties inside my jsp working. I hope i gave al the necessary info (sorry for the too much info..., did not know which was relevant and which not). If you need more info please ask. Have been searching for this five days now and still have no clue.
you can use <p><spring:message code="context"/></p>
but you should have context= what you want in one of the following files :
messages_el_GR.properties
dev_el_GR.properties
theme_el_GR.properties

Why having NPE at jstl?

Do you have any ideea why having NPE for this?
<c:forEach
var="css"
items="${fn:split('test,test,', ',')}">
<link
rel="stylesheet"
type="text/css"
href="${css}"></link>
</c:forEach>
I simply don't understand why this is not correct.
javax.servlet.ServletException: java.lang.Exception: javax.faces.FacesException:
Problem in renderResponse: /WEB-INF/jsf/userapp-main.jsf #40,44 items="${fn:split('test,test,', ',')}" java.lang.NullPointerException
Well, seems that I forgot to declare fn:
xmlns:fn="http://java.sun.com/jsp/jstl/functions"
I would have expected something like tag not defined instead of a generic NPE.

JSF 2.0 loading the bundle

I got the following error:
> org.apache.jasper.JasperException: An
> exception occurred processing JSP page
> /ajax/busstop_ajax.jsp at line 12
10: <%#taglib prefix="f" uri="http://java.sun.com/jsf/core"%>
11: <%#taglib prefix="h" uri="http://java.sun.com/jsf/html"%>
12: <f:loadBundle basename="/../messages.Messages" var="msg" />
13:
14: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
15: "http://www.w3.org/TR/html4/loose.dtd">
Stacktrace:
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:510)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:419)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:393)
root cause
java.lang.NullPointerException
com.sun.faces.taglib.jsf_core.LoadBundleTag.doStartTag(LoadBundleTag.java:148)
org.apache.jsp.ajax.busstop_005fajax_jsp._jspx_meth_f_005floadBundle_005f0(busstop_005fajax_jsp.java:184)
org.apache.jsp.ajax.busstop_005fajax_jsp._jspService(busstop_005fajax_jsp.java:68)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:377)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:393)
I'm trying to add a bundle to be able to translate the interface. The whole page is in jsp rather than html.
<%#page import="java.util.List"%>
<%#page contentType="text/html" pageEncoding="UTF-8"%>
<%#taglib prefix="f" uri="http://java.sun.com/jsf/core"%>
<%#taglib prefix="h" uri="http://java.sun.com/jsf/html"%>
<f:loadBundle basename="messages.Messages" var="msg" />
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<f:view>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<title>JSP Page</title>
</head>
<body>
...
</body>
</html>
</f:view>
I tried to add it in faces-config as well but no success. What am I doing wrong here?
Thanks for help!
The <f:loadBundle> will throw NPE like that when the FacesContext is not present.
In other words, you aren't invoking the request through the url-pattern of the FacesServlet as definied in web.xml. The FacesServlet is namely the one who is responsible for creating the FacesContext. If the url-pattern is for example *.jsf, you should open the page in webbrowser by pagename.jsf and thus not by pagename.jsp.
The stacktrace by the way also gives evidence that it's not been processed by JSF at all. There's no single line indicating involvement of the JSF API or impl prior to calling the f:loadBundle.
That said (and unrelated to the current problem), given the fact that you're using JSF 2.0 (at least, you tagged like that) and that Facelets is the superior successor of JSP -in case of JSF-, I strongly recommend to drop JSP altogether and use Facelets instead.

Resources