Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

org.springframework.expression.spel.SpelEvaluationException: EL1027E:(pos 4): Indexing into type 'com.test.domain.Employee' is not supported

I am developing an Spring Roo application and while displaying the Objects in list (in list.jspx), I am getting all the properties of the referenced object. For example:

@RooJavaBean
@RooToString    
@RooJpaActiveRecord

public class Employee {    
    @NotNull
    private String empName;    
    @ManyToOne
    private Department department;
}

And the Department

@RooJavaBean    
@RooToString    
@RooJpaActiveRecord    
public class Department {    
    @NotNull
    private String deptName;

   @NotNull
   private String deptLocation;
}

Now after building a web project in roo, and adding department entries and employee entries, I am getting an ugly looking table in employee list. All the properties from Department entity are being displayed, where as my intention was to show the Department Name (deptName).

Tried to change in list.jspx as follows:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<div xmlns:jsp="http://java.sun.com/JSP/Page" xmlns:page="urn:jsptagdir:/WEB-INF/tags/form" xmlns:table="urn:jsptagdir:/WEB-INF/tags/form/fields" version="2.0">
    <jsp:directive.page contentType="text/html;charset=UTF-8"/>
    <jsp:output omit-xml-declaration="yes"/>
    <page:list id="pl_com_test_domain_Employee" items="${employees}" z="user-managed">
        <table:table data="${employees}" id="l_com_test_domain_Employee" path="/employees" z="user-managed">
            <table:column id="c_com_test_domain_Employee_Department" property="department.deptName" z="user-managed"/>
            <table:column id="c_com_test_domain_Employee__DeptLocation" property="deptLocation" z="user-managed"/>
        </table:table>
    </page:list>

The error:

org.springframework.expression.spel.SpelEvaluationException: EL1027E:(pos 4): Indexing into type 'com.test.domain.Employee' is not supported
    at org.springframework.expression.spel.ast.Indexer$PropertyIndexingValueRef.getValue(Indexer.java:208)
    at org.springframework.expression.spel.ast.CompoundExpression.getValueInternal(CompoundExpression.java:81)
    at org.springframework.expression.spel.ast.SpelNodeImpl.getTypedValue(SpelNodeImpl.java:102)
    at org.springframework.expression.spel.standard.SpelExpression.getValue(SpelExpression.java:98)
    at org.springframework.web.servlet.tags.EvalTag.doEndTag(EvalTag.java:125)
    at org.apache.jsp.tag.webform.fields.table_tagx._jspx_meth_spring_005feval_005f4(table_tagx.java:1390)
    at org.apache.jsp.tag.webform.fields.table_tagx._jspx_meth_c_005fset_005f14(table_tagx.java:1357)
    at org.apache.jsp.tag.webform.fields.table_tagx._jspx_meth_c_005fotherwise_005f0(table_tagx.java:1324)
    at org.apache.jsp.tag.webform.fields.table_tagx._jspx_meth_c_005fchoose_005f0(table_tagx.java:1115)
    at org.apache.jsp.tag.webform.fields.table_tagx._jspx_meth_c_005fforTokens_005f1(table_tagx.java:1015)
    at org.apache.jsp.tag.webform.fields.table_tagx._jspx_meth_c_005fforEach_005f0(table_tagx.java:949)
    at org.apache.jsp.tag.webform.fields.table_tagx._jspx_meth_c_005fif_005f0(table_tagx.java:342)
    at org.apache.jsp.tag.webform.fields.table_tagx.doTag(table_tagx.java:269)
    at org.apache.jsp.WEB_002dINF.views.autoscalingtasks.list_jspx._jspx_meth_table_005ftable_005f0(list_jspx.java:126)
    at org.apache.jsp.WEB_002dINF.views.autoscalingtasks.list_jspx.access$0(list_jspx.java:108)
    at org.apache.jsp.WEB_002dINF.views.autoscalingtasks.list_jspx$Helper.invoke0(list_jspx.java:225)
    at org.apache.jsp.WEB_002dINF.views.autoscalingtasks.list_jspx$Helper.invoke(list_jspx.java:256)
    at org.apache.jsp.tag.webform.list_tagx._jspx_meth_c_005fwhen_005f0(list_tagx.java:444)
    at org.apache.jsp.tag.webform.list_tagx._jspx_meth_c_005fchoose_005f0(list_tagx.java:412)
    at org.apache.jsp.tag.webform.list_tagx.access$0(list_tagx.java:402)
    at org.apache.jsp.tag.webform.list_tagx$Helper.invoke0(list_tagx.java:526)
    at org.apache.jsp.tag.webform.list_tagx$Helper.invoke(list_tagx.java:544)
    at org.apache.jsp.tag.webutil.panel_tagx._jspx_meth_c_005fif_005f0(panel_tagx.java:193)
    at org.apache.jsp.tag.webutil.panel_tagx.doTag(panel_tagx.java:139)
    at org.apache.jsp.tag.webform.list_tagx._jspx_meth_util_005fpanel_005f0(list_tagx.java:397)
    at org.apache.jsp.tag.webform.list_tagx._jspx_meth_c_005fif_005f0(list_tagx.java:221)
    at org.apache.jsp.tag.webform.list_tagx.doTag(list_tagx.java:185)
    at org.apache.jsp.WEB_002dINF.views.autoscalingtasks.list_jspx._jspx_meth_page_005flist_005f0(list_jspx.java:103)
    at org.apache.jsp.WEB_002dINF.views.autoscalingtasks.list_jspx._jspService(list_jspx.java:72)
    at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
    at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:432)
    at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
    at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
    at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:749)
    at org.apache.catalina.core.ApplicationDispatcher.doInclude(ApplicationDispatcher.java:605)
    at org.apache.catalina.core.ApplicationDispatcher.include(ApplicationDispatcher.java:544)
    at org.apache.jasper.runtime.JspRuntimeLibrary.include(JspRuntimeLibrary.java:954)
    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.layouts.asg_005flist_005fbody_jspx._jspx_meth_tiles_005finsertAttribute_005f2(asg_005flist_005fbody_jspx.java:234)
    at org.apache.jsp.WEB_002dINF.layouts.asg_005flist_005fbody_jspx._jspService(asg_005flist_005fbody_jspx.java:96)
    at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
    at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:432)
    at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
    at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
    at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:749)
    at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:487)
    at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:412)
    at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:339)
    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 org.springframework.web.servlet.view.tiles2.TilesView.renderMergedOutputModel(TilesView.java:124)
    at org.springframework.web.servlet.view.AbstractView.render(AbstractView.java:264)
    at org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1208)
    at org.springframework.web.servlet.DispatcherServlet.processDispatchResult(DispatcherServlet.java:992)
    at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:939)
    at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:856)
    at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:915)
    at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:811)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
    at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:796)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
    at org.springframework.orm.jpa.support.OpenEntityManagerInViewFilter.doFilterInternal(OpenEntityManagerInViewFilter.java:180)
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:311)
    at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:116)
    at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:83)
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:323)
    at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:113)
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:323)
    at org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:101)
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:323)
    at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:113)
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:323)
    at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:54)
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:323)
    at org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:45)
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:323)
    at org.springframework.security.web.authentication.www.BasicAuthenticationFilter.doFilter(BasicAuthenticationFilter.java:150)
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:323)
    at org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:182)
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:323)
    at org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:105)
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:323)
    at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:87)
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:323)
    at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:173)
    at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:346)
    at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:259)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
    at org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:77)
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
    at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88)
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
    at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:936)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
    at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1004)
    at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589)
    at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:310)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at java.lang.Thread.run(Thread.java:722)

What should I do?

like image 897
Chandan Patra Avatar asked Aug 21 '13 13:08

Chandan Patra


1 Answers

I got the answer and here I am sharing it:

To avoid above error, I had changed the table.tagx as follows:

table.tagx: line-84 :

Replace this:

<spring:eval expression="item[column]" htmlEscape="false" />

with this:

<spring:eval expression="item.${column}"  htmlEscape="false" />

table.tagx: line-95 :

Replace this:

<spring:eval expression="item[typeIdFieldName]"/>

with this:

<c:set var="itemId"><spring:eval expression="item.${typeIdFieldName}"/></c:set>

Now you can access the properties from an object like this :

 <page:list id="pl_com_test_domain_Employee" items="${employees}" z="user-managed">
    <table:table data="${employees}" id="l_com_test_domain_Employee" path="/employees" z="user-managed">
        <table:column id="c_com_test_domain_Employee_Department"  property="department.deptName" z="user-managed"/>
        <table:column id="c_com_test_domain_Employee_DeptLocation" property="deptLocation" z="user-managed"/>
    </table:table>
</page:list>

Thank you!!!

Chandan

like image 51
Chandan Patra Avatar answered Oct 21 '22 07:10

Chandan Patra