Search code examples
jspjavabeansjsp-tagsaem

Cannot find any information on property in bean... in Hello World


I'm just starting out in JSP in Adobe CQ and I'm trying to do a simple Hello World to access data from the world's simplest Bean. From everything I've read, this is correct. What's going on here?

My JSP (html.jsp) is:

<%@page session="false"
        contentType="text/html;charset=UTF-8"
        import="org.apache.sling.api.request.ResponseUtil"
%>
<%@taglib prefix="sling" uri="http://sling.apache.org/taglibs/sling/1.0"%>
<sling:defineObjects/>
<html>
  <body>
<jsp:useBean id="myBean" class="com.example.helloBean.SampleUtil" >
        <jsp:getProperty name="myBean" property="text"/>
      </jsp:useBean>
  </body>
</html>

And I modified the template-generated "Hello World" class (SampleUtil.java) to be as follows:

package com.example.helloBean;
public class SampleUtil{
    private String text;
    public SampleUtil(){
        this.text = "Hello World.";
    }
    public  String getText() {
        return text;
    }
    public void setText(String text){
    this.text = text;
    }
}

When accessing the page I get

Cannot find any information on property 'text' in a bean of type 'com.example.helloBean.SampleUtil'

Possibly relevant details: I generated this in CQ using the "Create Project" command in CRXDELite on /apps, which made a working Hello World, then modified the two files above.


Solution

  • Try to rename package name helloBean to hellobean everywhere. It should contain only lower-case letter.