0

我有一个 UserService 在使用 ViewScoped 时因 ClassNotFound 而失败,但与 SessionScoped 一起使用,我希望有人能告诉我原因。我的应用程序将 JSF2 与 Spring 混合在一起。

我得到的错误是:

java.lang.ClassNotFoundException: com.dave.user.service.IUserService

托管 bean 是

@ManagedBean(name="ClientMB")
@ViewScoped
public class ClientMB implements Serializable{


@ManagedProperty(value="#{UserService}")
IUserService  userService;

public IUserService getUserService() {
    return userService;
}

public void setUserService(IUserService userService) {
    this.userService = userService;
}

UserService 定义为

public class UserService implements Serializable, IUserService  {

// UserDAO is injected...
IUserDAO userDAO;

}

IUserService 只是一个接口:

public interface IUserService {

ApplicationContext 中的声明是

<bean id="UserService" class="com.dave.user.service.UserService">
    <property name="userDAO" ref="UserDAO" />
</bean>

正如我所说,使用 SessionScoped 可以正常工作,但是当我将托管 bean 更改为 ViewScoped 时会失败。

4

1 回答 1

0

Problem came from changing the state saving from server to client. Once I returned the state saving to server viewscope worked fine. Not quite sure why that happened but embarassing none the less.

于 2012-10-12T19:49:02.547 回答