2012-02-22 71 views
0

我試圖用weblogic 10.3.5容器對Spring Security進行單元測試。我已經爲Eclipse和Weblogic提供了一個環境,這兩者我都不太熟悉。單元測試帶Weblogic容器的Spring Security

啓動時,我得到一個異常:

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) { 

    } 
} 

所以,我猜,我不是撿的servlet。來自weblogic的jar。但由於我是一個相對較新的eclipse用戶(IntelliJ很長一段時間),我不確定我是否已經正確設置了weblogic。

在我的項目方面,我檢查了Oracle WebLogic Web應用程序擴展,但沒有配置其他weblogic應用程序。動態網頁模塊也被選中。

任何人都可以提供援助給一個相對的newb?

Jason

回答

0

無視。在某處我發現了另一個目標運行時選項。一旦我確定了它,它就起作用了。