0

我正在使用 apache open JPA 在服务器端访问我的数据库。我试图从我的 gwt 客户端调用服务器以检索实体对象,但此请求总是失败并显示错误消息:NoClassDefFoundError org/apache/openjpa/enhance/PersistenceCapable。

我尝试在 gwt.xml 文件中定义我的增强实体类,但没有帮助:

<set-configuration-property name="rpc.enhancedClasses" value="com.jobsin.domain.SystemUser,com.jobsin.domain.Keyword,com.jobsin.domain.Job">/

我的服务器功能:

public  SystemUser getCurrentUser() 
throws InvalidUser{

    HttpServletRequest httpServletRequest = this.getThreadLocalRequest();
    HttpSession session =  httpServletRequest.getSession();
    SystemUser user=null;

    Cookie[] cookies = httpServletRequest.getCookies();
    SocialNetworkCookie cookie = network.generateCookieObject();
    if(!cookie.init(cookies)){
        session.invalidate();
        throw new InvalidUser(); // no user was connected, user need to login
    }

    //try get user details from db
    EntityManager em = factory.createEntityManager();
    SystemUserDAOImpl userdao = new  SystemUserDAOImpl(em);
    user = userdao.findUserByNetworkId(cookie.getMemberId());
         //make user detach
    em.close();

    return user;
}

系统用户类:

@Entity
public class SystemUser implements Serializable
{
    /**
     * 
     */
    private static final long serialVersionUID = -1673271845552139219L;

    @Id
    @GeneratedValue
    private long id; 

    @NotNull
    private String firstName;

    @NotNull
    private String lastName;

    @NotNull
    @Column(unique=true)
    private String email;


    @Temporal(TemporalType.TIMESTAMP) 
    private Date lastSearch;

    @ManyToMany(cascade = CascadeType.ALL)
    private Set<Job> jobs = new HashSet<Job>();

    @ManyToMany(cascade = CascadeType.ALL)
    private Set<Keyword> keywords = new HashSet<Keyword>();
}
4

1 回答 1

0

最简单的解决方案是将 OpenJPA 二进制文件添加到 GWT 客户端类路径。

于 2013-02-14T22:18:52.260 回答