Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/337.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 身份';chartBean';不引用MethodExpression实例_Java_Jsf_Primefaces_Bar Chart - Fatal编程技术网

Java 身份';chartBean';不引用MethodExpression实例

Java 身份';chartBean';不引用MethodExpression实例,java,jsf,primefaces,bar-chart,Java,Jsf,Primefaces,Bar Chart,这个图表显示得很好,但是日志一点也不好 我找不到例外的原因。 任何建议都将不胜感激!! 我相信有两种情况,没有实例,因为它没有被调用,或者我的bean中有一个空指针。 但是我已经在bean中完成了错误处理,所以我相信可能还有其他原因 错误1 SEVERE: Servlet.service() for servlet [Faces Servlet] in context with path [/test threw exception [/home/barChart.xhtml @

这个图表显示得很好,但是日志一点也不好

我找不到例外的原因。 任何建议都将不胜感激!! 我相信有两种情况,没有实例,因为它没有被调用,或者我的bean中有一个空指针。 但是我已经在bean中完成了错误处理,所以我相信可能还有其他原因

错误1

    SEVERE: Servlet.service() for servlet [Faces Servlet] in context with path     [/test threw exception [/home/barChart.xhtml @14,67 listener="#{chartBean}": Identity 'chartBean' does not reference a MethodExpression instance, returned type: ChartBean] with root cause
    javax.el.ELException: /home/barChart.xhtml @14,67 listener="#{chartBean}": Identity 'chartBean' does not reference a MethodExpression instance, returned type: ChartBean
        at com.sun.faces.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:111)
错误2

    SEVERE: Servlet.service() for servlet [Faces Servlet] in context with path [/test] threw exception [null] with root cause
    java.lang.NullPointerException
        at org.primefaces.component.chart.bar.BarChartRenderer.encodeOptions(BarChartRenderer.java:64)
错误3

    SEVERE: Exception sending context initialized event to listener instance of class com.sun.faces.config.ConfigureListener
    java.lang.RuntimeException: java.lang.OutOfMemoryError: PermGen space
        at com.sun.faces.config.ConfigureListener.contextInitialized(ConfigureListener.java:292......
然后错误就加起来了

守则: barChart.xhtml

    <?xml version="1.0" encoding="ISO-8859-1" ?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml"
            xmlns:ui="http://java.sun.com/jsf/facelets"
            xmlns:h="http://java.sun.com/jsf/html"
            xmlns:f="http://java.sun.com/jsf/core"
            xmlns:p="http://primefaces.org/ui">
    <h:head>
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
    <title>Insert title here</title>
    </h:head>
    <h:body>


            <h1 class="title ui-widget-header ui-corner-all">Login - Statistics</h1>
            <div class="entry">

                <p:barChart id="horizontal" value="#{chartBean.categoryModel}" legendPosition="ne"  breakOnNull="false" barMargin="3" barPadding="3"
                            title="Horizontal Bar Chart"  orientation="horizontal" min="0" max="#{chartBean.count}" style="height:#{chartBean.ssize}" />


            </div>
    </h:body>
    </html>

您发布的代码似乎不完整。错误清楚地说明了问题:

/home/barChart.xhtml@14,67 listener=“#{chartBean}”:标识“chartBean”未引用MethodExpression实例,返回类型:chartBean

您发布的代码中的第14行是空的,请检查您的真实代码

监听器必须引用一个方法,因此您不应该使用
listener=“#{chartBean}”
,而应该使用类似
listener=“#{chartBean.doStuff}”

我的解决方案: 我进行了一般性清理,替换了不推荐使用的标记库,删除了truts xml文件,并在所安装的类路径上添加了struts jar。 我相信我有一个冲突贝森struts服务器面对和jsf。
我不知道是什么原因导致了缓存,在我清理之后它现在就消失了。

我不确定我是否理解你的意思,我在构造函数createCategoryModel调用的代码中有chartBean.categoryModel和它?是的,错误说明了问题,但我如何解决它?对我来说,这并不明显,但如果有人能给我一个建议,我很感激:)我的意思是,错误1的来源是对听众的错误定义。当#{chartBean}引用一个对象时,它应该引用一个方法。再次查看Error1的错误输出-它应该是xhtml中的第14行。我更新了答案,让它更清晰啊哈,我明白你的意思,但我不这样打电话。我想它可能还在缓存中,所以我清理并重建了项目,甚至重新启动了计算机。但我还是得到了错误。我不使用listener=“#{chartBean}”之类的东西:这让我觉得没问题,可能它存储在一些设置中,或者我不知道的任何东西……或者你的意思是我需要在第14行添加类似的内容来创建一个实例??我试过了,但没有效果。
    @ManagedBean(name="chartBean")
    @RequestScoped
    public class ChartBean implements Serializable {

        CDBPool cdb;
        ResultSet res = null;
        private int method = 0;
        private int  months = 12;
        private String  country = null;
        private int bitval = 1;
        private int type = 0;
        private CartesianChartModel categoryModel;

        private int size = 1;
        private String sSize = "10";           //Width of chart
        private String maxCount="100";          //size of x-axis 
        private int count = 0;
        private HttpServletRequest request;
        private HttpServletResponse response;

        public ChartBean()   {
        request = (HttpServletRequest)FacesContext.getCurrentInstance().getExternalContext().getRequest();
        response = (HttpServletResponse)FacesContext.getCurrentInstance().getExternalContext().getResponse();
            createCategoryModel();
        }


    /**
    * To set the max of x-axis as integer
    * @return 
    */
        public int getCount() {
            return count;
        }


    /**
    * To set the max of x-axis
    * @return 
    */
        public String getMaxCount() {
            return maxCount;
        }

        public int getSize() {
            return size;
        }
    /**
    * To set the width of chart
    * @return 
    */
        public String getSsize() {
            return sSize;
        }

        public void itemSelect(ItemSelectEvent event) {
            FacesMessage msg = new FacesMessage(FacesMessage.SEVERITY_INFO, "Item selected",
                    "Item Index: " + event.getItemIndex() + ", Series Index:" + event.getSeriesIndex());

            FacesContext.getCurrentInstance().addMessage(null, msg);
        }

        public CartesianChartModel getCategoryModel() {
            return categoryModel;
        }

        public final void setChartProp(int method, int  months, String country, int  bitval, int  type){
            //TODO Replace thees values with request get...
            this.method = method;
            this.months = months;
            this.country = country;
            this.bitval = bitval;
            this.type = type;
            if (method == 0) {
                method = 0;
            }
            if (months == 12) {
                months = 12;
            }
            if (country == null) {
                country = "%";
            }
            if (bitval == 1) {
                bitval = 1;
            }
            if (type == 0) {
                type = 0;
            }
            //CALL "cdbdba"."CDBStatLoginDay"("@SUMMETHOD" = 0,"@MONTHSBACK" = 12,"@COUNTRY" = '%',"@BITVAL" = '1',"@TYPE" = 0)
    /*
            mint,diff,dh,sum
            20110616,366,0,84
            20110616,366,1,52
            20110616,366,2,6
            20110616,366,3,17
    */      

            String sqlString = "Exec CDBStatLoginDay " + method + "," + months + ",'" + country + "'," + bitval + "," + type;
            res = cdb.dbQuery(sqlString);
        }

        private void createCategoryModel()  {
            try {
                cdb = JSPCodeFunctions.getDBPool(request, response);
            } catch (Exception ex) {
                Logger.getLogger(ChartBean.class.getName().concat(" when calling JSPCodeFunctions ")).log(Level.SEVERE, null, ex);
            }
                setChartProp(method,  months,  country,  bitval,  type);    
            categoryModel = new CartesianChartModel();
            ChartSeries hits = new ChartSeries();

            if (res != null) {

                Date incrementDate = null;
                DateFormat formatter = new SimpleDateFormat("yyyyMMdd");
                int days = 0;
                String day;
                String month;
                String year; 
                String serieDate = null;
                String startDate = null;

                count = 100;
                try {
                    while (res.next()) {
                        size = res.getInt(2);
                        try {
                            incrementDate = ChartDate.addDays((Date)formatter.parse( res.getString(1)), res.getInt(3));
                        } catch (ParseException ex) {
                            Logger.getLogger(ChartBean.class.getName().concat(" When retriving rows from res ")).log(Level.SEVERE, null, ex);
                        }
                        day = incrementDate.toString().split(" ")[2];
                        month = incrementDate.toString().split(" ")[1];
                        year = incrementDate.toString().split(" ")[5];
                        serieDate = day+""+month+""+year;
                        count = (res.getInt(4)>count)? res.getInt(4):count;
                        hits.set(serieDate, res.getInt(4));  //Sets date and count
                        days++;
                        try {
                            startDate = ChartDate.addDays((Date)formatter.parse( res.getString(1)), 0).toString().split(" ")[2]+"-"+ChartDate.addDays((Date)formatter.parse( res.getString(1)), 0).toString().split(" ")[1]+"-"+ChartDate.addDays((Date)formatter.parse( res.getString(1)), 0).toString().split(" ")[5];
                        } catch (ParseException ex) {
                            Logger.getLogger(ChartBean.class.getName().concat(" When retriving rows from res")).log(Level.SEVERE, null, ex);
                        }

                    }
                    maxCount = String.valueOf(count);
                    sSize= String.valueOf(size*15)+"px";                
                    hits.setLabel("Numer of login from: "+startDate+" to "+serieDate.toString());
                } catch (SQLException ex) {
                    Logger.getLogger(ChartBean.class.getName()).log(Level.SEVERE, null, ex);
                }

                try {
                    if (res!=null)res.close();res = null;
                } catch (SQLException ex) {
                    Logger.getLogger(ChartBean.class.getName()).log(Level.SEVERE, null, ex);
                }
                categoryModel.addSeries(hits);


            }else{
                //Lets add some default test data
                ChartSeries boys = new ChartSeries();
                boys.setLabel("Boys");
                boys.set("2004", 120);
                boys.set("2005", 100);
                ChartSeries girls = new ChartSeries();
                girls.setLabel("Girls");
                girls.set("2004", 52);
                girls.set("2005", 60);
                categoryModel.addSeries(boys);
                categoryModel.addSeries(girls);
                }
        }

    }