`

can not access a member of class

 
阅读更多

      今天遇到个很奇怪的问题,报错为:严重: Servlet.service() for servlet default threw exception
  java.lang.IllegalAccessException: Class com.googlecode.jsonplugin.JSONWriter can not access a member of class org.apache.commons.dbcp.PoolingDataSource$PoolGuardConnectionWrapper with modifiers “public”
at sun.reflect.Reflection.ensureMemberAccess(Reflection.java:65)

  以下是我的实体Bean,应该说是很简单的一个应用,查询员工考勤,怎么就会报错了呢,在上面的错误中很明显是JSONWriter转换不了要转换的对象造成的,但是在我下面的实体Bean中明明很简单,不可能会有错的。在每一个get前加上 @JSON(serialize = false)问题依旧,这就很没道理了,偶想想到返回的数据中除了实体bean需要转化外还有一些参数,比如page页面等,马上找到了我的action控制类,果然如此:问题就出现在其中的getSignLogService啦,由于用eclipse生成get/set方法时没有注意,把这个接口也生成了get/set方法,JSONWriter自然无法将一个接口转换为实体对象了,问题解决。

/**.
 * 公共基础对象实体包
 *


 * 公共基础对象实体包,存放如HR,ERP,CRM中的公共实体部分对象
 *
 */
package com.lenxeon.extjs.bean.comm;

import java.io.Serializable;
import java.util.Date;

import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Version;

import com.googlecode.jsonplugin.annotations.JSON;

/**************************************************.
 * FileName:SignLog.java
 * Version: 1.00
 * Author: lenxeon
 * Date: 2009-12-25
 * Last modify Date: 2009-12-25
 * Function: 员工考勤信息对象实体封装类
 * CopyRight (c) zendlab.com Company 2009-2012 All rights reserved
 **************************************************/
@Entity()
@Table(name = "signLog")
public class SignLog implements Serializable {

    /**.
     *序列化id
     */
    private static final long serialVersionUID = 1L;
    /**.
     *记录ID
     */
    private int id;
    /**.
     * 员工工号
     */
    private int emID;
    /**.
     * 上班时间
     */
    private Date logInTime;
    /**.
     * 下班时间
     */
    private Date logOutTime;
    /**.
     * 版本控制
     */
    private int revision;
    /**.
     * 构造函数
     */
    public SignLog() {
    }
    /**.
     * 构造函数
     */
    public SignLog(int id) {
        super();
        this.id = id;
    }

    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    public int getId() {
        return id;
    }
    public void setId(int id) {
        this.id = id;
    }
    public int getEmID() {
        return emID;
    }
    public void setEmID(int emID) {
        this.emID = emID;
    }
    @JSON(format="yyyy-MM-dd' 'HH:mm:ss")
    public Date getLogInTime() {
        return logInTime;
    }
    public void setLogInTime(Date logInTime) {
        this.logInTime = logInTime;
    }
    @JSON(format="yyyy-MM-dd' 'HH:mm:ss")
    public Date getLogOutTime() {
        return logOutTime;
    }
    public void setLogOutTime(Date logOutTime) {
        this.logOutTime = logOutTime;
    }
    @Version
    public int getRevision() {
        return revision;
    }
    public void setRevision(int revision) {
        this.revision = revision;
    }
}

 

控制器中的代码:

private static final long serialVersionUID = 1L;
    @Resource(name = "signLogServiceImpl")
    private SignLogService signLogService;
    private List signLogs;
    private SignLog signLog;

    public SignLogService getSignLogService() {
        return signLogService;
    }
    public void setSignLogService(SignLogService signLogService) {
        this.signLogService = signLogService;
    }
    public List getSignLogs() {
        return signLogs;
    }
    public void setSignLogs(List signLogs) {
        this.signLogs = signLogs;
    }
    @JSON(format="yyyy-MM-dd' 'HH:mm:ss")
    public SignLog getSignLog() {
        return signLog;
    }
    public void setSignLog(SignLog signLog) {
        this.signLog = signLog;
    }
    @Override
    public int getLimit() {
        return super.getLimit();
    }
    @Override
    public int getStart() {
        return super.getStart();
    }
    @Override
    public String getMsg() {
        return super.getMsg();
    }
    @Override
    public Boolean getSuccess() {
        return super.getSuccess();
    }
    @Override
    public long getTotal() {
        return super.getTotal();
    }

    /**.
     * 考勤列表查询
     * @return String
     * @throws Exception
     */
    public final String signLogList() throws Exception {
        ....
    }

 

分享到:
评论

相关推荐

    SpringMVC中处理json数据所需jar包 jackson2.5.0.jar

    2、该版本jar包可以解决转json数据报错:can not access a member of class com.fasterxml.jackson.databind.ser.std.NullSerializer with modifiers "private" can not access a member of class ...

    axis2常见异常总结

    如果我们在使用 Axis2 时抛出了 org.apache.axis2.AxisFault: Class org.apache.axis2.engine.DefaultObjectSupplier can not access a member of class org.apache.lucene.analysis.Analyzer with modifiers ...

    Google C++ Style Guide(Google C++编程规范)高清PDF

    For example, if your header file uses the File class in ways that do not require access to the declaration of the File class, your header file can just forward declare class File; instead of having ...

    C 程序设计教学课件:Chapter 3 class and object.ppt

    Access control modifiers play a crucial role in managing how class members can be accessed. Public members can be accessed from anywhere, providing an interface for interacting with the object. ...

    NETCFSERUP

    <summary>UintAccessor class provides access to a uint within an Accessable object.</summary> </member> - <member name="M:Symbol.Marshaller.UintAccessor.#ctor(System.Int32)"> <summary>UintAccessor ...

    Selected.Topics.in.Cplusplus.15117

    Class Member Access Class member offsets Function Pointers Function Shadowing Understanding the Destructor Operator Overloading Multiple Inheritance Casting Conversions and Promotions Name Lookup

    BobBuilder_app

    I decided against using SortedDictionary for the pages as it was slower than a normal Dictionary and for the purpose of a key value store the sorted-ness was not need and could be handled in other ...

    DIBSection Class VB

    you initialise a BITMAPINFO structure with the required fields, which are all in the bmiHeader sub-structure: <br>Member Required Value biSize Size of the BITMAPINFO structure biWidth ...

    数位板压力测试

    Writing simple programs should require only a few lines of code and a minimal understanding of the en-vironment. On the other hand, more advanced features and functions should be available to those ...

    MMX_Setup_15_0_20_2385.zip

    For example: Drag interface members on a class to implement the interface (C#, pascal), Drag a module or local procedure on a class to convert it to a method (pascal) Use Editor Refactoring’s to ...

    Turbo C++ 3.0[DISK]

    If you are not a member of CompuServe, see the enclosed special offer, and write for full details on how to receive a free IntroPak containing a $15 credit toward your first month's on-line ...

    Turbo C++ 3.00[DISK]

    If you are not a member of CompuServe, see the enclosed special offer, and write for full details on how to receive a free IntroPak containing a $15 credit toward your first month's on-line ...

    SCJP6 Sun Certificated Programmer for Java 6 Study Guide (Exam 310-065) 英文原版

    Inner classes can access private members of the enclosing class: - **Member Inner Classes**: Declared inside a class but outside any method. - **Local Inner Classes**: Declared inside a method. - **...

    雷达技术知识

    scan angle of LiDAR to return from a water surface. Return factor is greatest at low scan angles relative to the nadir region of scan. (Maslov, D. V. et. al. (2000). A Shore-based LiDAR for Coastal ...

    Bloodshed Dev-C++

    * During Dev-C++ First Time COnfiguration window, users can now choose between using or not class browser and code completion features. * Many bug fixes Version 4.9.8.4 * Added the possibility to ...

    Google C++ Style Guide_英文版.pdf

    - **The #define Guard:** Use a unique macro name to prevent multiple inclusions of the same header file. For example: ```cpp #ifndef MYHEADER_H_ #define MYHEADER_H_ // header content #endif ``` ...

    Using DIB Sections in VB

    you initialise a BITMAPINFO structure with the required fields, which are all in the bmiHeader sub-structure: <br>Member Required Value biSize Size of the BITMAPINFO structure biWidth ...

    高考英语重点词汇与例句.doc

    Not having a college degree can be a disadvantage in the job market. discuss讨论; Let's discuss the pros and cons of the proposal. diverse多样的; The city is known for its diverse food scene. ...

    Effective C#

    - **Purpose:** Ensuring that the default state of a value type is valid can prevent errors. - **Example:** Define a `PersonId` struct that uses 0 as the default value. **Item 20: Prefer Immutable ...

    C PROGRAMMING TUTORIAL

    - **Lvalue:** An expression that refers to a memory location and can appear on the left-hand side of an assignment. - **Rvalue:** An expression representing a value that can appear on the right-hand ...

Global site tag (gtag.js) - Google Analytics