【发布时间】:2012-02-22 16:28:51
【问题描述】:
我正在尝试使用 weblogic 10.3.5 容器对 Spring Security 进行单元测试。已经为我提供了一个 Eclipse 和 Weblogic 的环境,这两个我都不太熟悉。
启动时出现异常:
java.lang.NoClassDefFoundError: javax/servlet/Filter
at java.lang.ClassLoader.defineClass1(Native Method)
blahblahblah
因此,此单元测试失败:
@Test
public void testGetByIdViaAccessRoles() {
Person result;
// Test the results with a ROLE_ADMIN user. This SHOULD work.
SecurityContextHolder.getContext().setAuthentication(admin);
result = personRepository.getById(1L);
assertNotNull(result);
// test the results with a ROLE_USER. Should also be good...
SecurityContextHolder.getContext().setAuthentication(user);
result = personRepository.getById(1L);
assertNotNull(result);
// test the results with a nonexistent user. Should go kablooie.
SecurityContextHolder.getContext().setAuthentication(nonuser);
try {
result = personRepository.getById(1L);
fail("Should be impossible to get this with a nonexistent user.");
} catch (AccessDeniedException ex) {
}
}
所以,我猜我没有从 weblogic 中获取 servlet.jar。但由于我是一个相对较新的 eclipse 用户(长期使用 IntelliJ),我不确定我是否正确设置了 weblogic。
在我的项目方面,我检查了 Oracle WebLogic Web App Extensions,但没有配置其他 weblogic。动态 Web 模块也被选中。
任何人都可以为相对新手提供帮助吗?
杰森
【问题讨论】: