Hi Matt, Thanks a lot for answering my mail, first of all I am on appfuse version 2.0.2
and In my file line 54 is: for (GrantedAuthority role1 : roles) { that is the line below the one that you mention, I am pretty sure I have not done any changes but here is the start of the void before method. This means that its the roles array that is null, basically the same as you assume that the user does not have any roles. public void before(Method method, Object[] args, Object target) throws Throwable { SecurityContext ctx = SecurityContextHolder.getContext(); if (ctx.getAuthentication() != null) { Authentication auth = ctx.getAuthentication(); boolean administrator = false; GrantedAuthority[] roles = auth.getAuthorities(); for (GrantedAuthority role1 : roles) { if (role1.getAuthority().equals(Constants.ADMIN_ROLE)) { administrator = true; break; } } User user = (User) args[0]; ... I have added a little more debugging around the for loop: log.debug("----------------- DEBUG ------------------"); log.debug("method: " + method); log.debug("args: " + args); log.debug("User: " + ((User) args[0]).getEmail()); log.debug("target: " + target); log.debug("roles: " + roles); for (GrantedAuthority role1 : roles) { if (role1.getAuthority().equals(Constants.ADMIN_ROLE)) { administrator = true; break; } } log.debug("----------------- /DEBUG ------------------"); giving me the following output: Running org.appfuse.webapp.action.SignupActionTest DEBUG - AbstractTransactionalSpringContextTests.startNewTransaction(392) | Began transaction (1): transaction manager [org.springframework.orm.hibernate3.hibernatetransactionmana...@f9aa66]; rollback [true]. DEBUG - UserSecurityAdvice.before(54) | ----------------- DEBUG ------------------ DEBUG - UserSecurityAdvice.before(55) | method: public abstract org.appfuse.model.User org.appfuse.service.UserManager.saveUser(org.appfuse.model.User) throws org.appfuse.service.UserExistsException DEBUG - UserSecurityAdvice.before(56) | args: [Ljava.lang.Object;@38d0a8 DEBUG - UserSecurityAdvice.before(57) | User: self-registe...@raibledesigns.com DEBUG - UserSecurityAdvice.before(58) | target: org.appfuse.service.impl.usermanageri...@adb3f DEBUG - UserSecurityAdvice.before(59) | roles: null DEBUG - AbstractTransactionalSpringContextTests.endTransaction(360) | Rolled back transaction after execution of test [testExecute]. DEBUG - AbstractTransactionalSpringContextTests.startNewTransaction(392) | Began transaction (1): transaction manager [org.springframework.orm.hibernate3.hibernatetransactionmana...@f9aa66]; rollback [true]. DEBUG - AbstractTransactionalSpringContextTests.endTransaction(360) | Rolled back transaction after execution of test [testDisplayForm]. Tests run: 2, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.425 sec <<< FAILURE! Running org.appfuse.service.UserExistsExceptionTest INFO - AbstractSingleSpringContextTests.loadContextLocations(210) | Loading context for locations: /applicationContext-service.xml,/applicationContext-resources.xml,classpath:/applicationContext-dao.xml DEBUG - AbstractTransactionalSpringContextTests.startNewTransaction(392) | Began transaction (1): transaction manager [org.springframework.orm.hibernate3.hibernatetransactionmana...@e9e40]; rollback [true]. DEBUG - UserExistsExceptionTest.testAddExistingUser(21) | entered 'testAddExistingUser' method DEBUG - UserSecurityAdvice.before(54) | ----------------- DEBUG ------------------ DEBUG - UserSecurityAdvice.before(55) | method: public abstract org.appfuse.model.User org.appfuse.service.UserManager.saveUser(org.appfuse.model.User) throws org.appfuse.service.UserExistsException DEBUG - UserSecurityAdvice.before(56) | args: [Ljava.lang.Object;@194a1e9 DEBUG - UserSecurityAdvice.before(57) | User: user DEBUG - UserSecurityAdvice.before(58) | target: org.appfuse.service.impl.usermanageri...@111f5f1 DEBUG - UserSecurityAdvice.before(59) | roles: null DEBUG - AbstractTransactionalSpringContextTests.endTransaction(360) | Rolled back transaction after execution of test [testAddExistingUser]. Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 2.351 sec <<< FAILURE! Running org.appfuse.webapp.action.UserActionTest DEBUG - AbstractTransactionalSpringContextTests.startNewTransaction(392) | Began transaction (1): transaction manager [org.springframework.orm.hibernate3.hibernatetransactionmana...@f9aa66]; rollback [true]. DEBUG - AbstractTransactionalSpringContextTests.endTransaction(360) | Rolled back transaction after execution of test [testCancel]. DEBUG - AbstractTransactionalSpringContextTests.startNewTransaction(392) | Began transaction (1): transaction manager [org.springframework.orm.hibernate3.hibernatetransactionmana...@f9aa66]; rollback [true]. DEBUG - UserAction.edit(121) | checking for remember me login... DEBUG - AbstractTransactionalSpringContextTests.endTransaction(360) | Rolled back transaction after execution of test [testEdit]. DEBUG - AbstractTransactionalSpringContextTests.startNewTransaction(392) | Began transaction (1): transaction manager [org.springframework.orm.hibernate3.hibernatetransactionmana...@f9aa66]; rollback [true]. DEBUG - UserSecurityAdvice.before(54) | ----------------- DEBUG ------------------ DEBUG - UserSecurityAdvice.before(55) | method: public abstract org.appfuse.model.User org.appfuse.service.UserManager.saveUser(org.appfuse.model.User) throws org.appfuse.service.UserExistsException DEBUG - UserSecurityAdvice.before(56) | args: [Ljava.lang.Object;@e00c09 DEBUG - UserSecurityAdvice.before(57) | User: user DEBUG - UserSecurityAdvice.before(58) | target: org.appfuse.service.impl.usermanageri...@adb3f DEBUG - UserSecurityAdvice.before(59) | roles: null DEBUG - AbstractTransactionalSpringContextTests.endTransaction(360) | Rolled back transaction after execution of test [testSave]. DEBUG - AbstractTransactionalSpringContextTests.startNewTransaction(392) | Began transaction (1): transaction manager [org.springframework.orm.hibernate3.hibernatetransactionmana...@f9aa66]; rollback [true]. DEBUG - UserActionTest.testSaveConflictingUser(65) | original version #: 6 DEBUG - UserSecurityAdvice.before(54) | ----------------- DEBUG ------------------ DEBUG - UserSecurityAdvice.before(55) | method: public abstract org.appfuse.model.User org.appfuse.service.UserManager.saveUser(org.appfuse.model.User) throws org.appfuse.service.UserExistsException DEBUG - UserSecurityAdvice.before(56) | args: [Ljava.lang.Object;@1194cf5 DEBUG - UserSecurityAdvice.before(57) | User: admin DEBUG - UserSecurityAdvice.before(58) | target: org.appfuse.service.impl.usermanageri...@adb3f DEBUG - UserSecurityAdvice.before(59) | roles: null DEBUG - AbstractTransactionalSpringContextTests.endTransaction(360) | Rolled back transaction after execution of test [testSaveConflictingUser]. DEBUG - AbstractTransactionalSpringContextTests.startNewTransaction(392) | Began transaction (1): transaction manager [org.springframework.orm.hibernate3.hibernatetransactionmana...@f9aa66]; rollback [true]. DEBUG - AbstractTransactionalSpringContextTests.endTransaction(360) | Rolled back transaction after execution of test [testSearch]. DEBUG - AbstractTransactionalSpringContextTests.startNewTransaction(392) | Began transaction (1): transaction manager [org.springframework.orm.hibernate3.hibernatetransactionmana...@f9aa66]; rollback [true]. DEBUG - UserManagerImpl.removeUser(117) | removing user: -2 DEBUG - AbstractTransactionalSpringContextTests.endTransaction(360) | Rolled back transaction after execution of test [testRemove]. Tests run: 6, Failures: 0, Errors: 2, Skipped: 0, Time elapsed: 0.897 sec <<< FAILURE! Then a little later in UserSecurityAdviceTest everthing runs smoothly on the same users "user" and "admin" Running org.appfuse.service.UserSecurityAdviceTest DEBUG - UserSecurityAdvice.before(54) | ----------------- DEBUG ------------------ DEBUG - UserSecurityAdvice.before(55) | method: public abstract org.appfuse.model.User org.appfuse.service.UserManager.saveUser(org.appfuse.model.User) throws org.appfuse.service.UserExistsException DEBUG - UserSecurityAdvice.before(56) | args: [Ljava.lang.Object;@2c39d2 DEBUG - UserSecurityAdvice.before(57) | User: admin DEBUG - UserSecurityAdvice.before(58) | target: org.appfuse.service.impl.usermanageri...@1883d5f DEBUG - UserSecurityAdvice.before(59) | roles: [Lorg.springframework.security.GrantedAuthority;@17531fd DEBUG - UserSecurityAdvice.before(66) | ----------------- /DEBUG ------------------ WARN - UserSecurityAdvice.before(78) | Access Denied: 'user' tried to modify 'admin'! DEBUG - UserSecurityAdvice.before(54) | ----------------- DEBUG ------------------ DEBUG - UserSecurityAdvice.before(55) | method: public abstract org.appfuse.model.User org.appfuse.service.UserManager.saveUser(org.appfuse.model.User) throws org.appfuse.service.UserExistsException DEBUG - UserSecurityAdvice.before(56) | args: [Ljava.lang.Object;@2df8f8 DEBUG - UserSecurityAdvice.before(57) | User: admin DEBUG - UserSecurityAdvice.before(58) | target: org.appfuse.service.impl.usermanageri...@347456 DEBUG - UserSecurityAdvice.before(59) | roles: [Lorg.springframework.security.GrantedAuthority;@1c1de1c DEBUG - UserSecurityAdvice.before(66) | ----------------- /DEBUG ------------------ DEBUG - UserSecurityAdvice.before(54) | ----------------- DEBUG ------------------ DEBUG - UserSecurityAdvice.before(55) | method: public abstract org.appfuse.model.User org.appfuse.service.UserManager.saveUser(org.appfuse.model.User) throws org.appfuse.service.UserExistsException DEBUG - UserSecurityAdvice.before(56) | args: [Ljava.lang.Object;@1d7ce63 DEBUG - UserSecurityAdvice.before(57) | User: user DEBUG - UserSecurityAdvice.before(58) | target: org.appfuse.service.impl.usermanageri...@12ecba8 DEBUG - UserSecurityAdvice.before(59) | roles: [Lorg.springframework.security.GrantedAuthority;@13c8540 DEBUG - UserSecurityAdvice.before(66) | ----------------- /DEBUG ------------------ DEBUG - UserSecurityAdvice.before(54) | ----------------- DEBUG ------------------ DEBUG - UserSecurityAdvice.before(55) | method: public abstract org.appfuse.model.User org.appfuse.service.UserManager.saveUser(org.appfuse.model.User) throws org.appfuse.service.UserExistsException DEBUG - UserSecurityAdvice.before(56) | args: [Ljava.lang.Object;@cfefc0 DEBUG - UserSecurityAdvice.before(57) | User: user DEBUG - UserSecurityAdvice.before(58) | target: org.appfuse.service.impl.usermanageri...@18526aa DEBUG - UserSecurityAdvice.before(59) | roles: [Lorg.springframework.security.GrantedAuthority;@ad8dbc DEBUG - UserSecurityAdvice.before(66) | ----------------- /DEBUG ------------------ WARN - UserSecurityAdvice.before(99) | Access Denied: 'user' tried to change their role(s)! DEBUG - UserSecurityAdvice.before(54) | ----------------- DEBUG ------------------ DEBUG - UserSecurityAdvice.before(55) | method: public abstract org.appfuse.model.User org.appfuse.service.UserManager.saveUser(org.appfuse.model.User) throws org.appfuse.service.UserExistsException DEBUG - UserSecurityAdvice.before(56) | args: [Ljava.lang.Object;@265121 DEBUG - UserSecurityAdvice.before(57) | User: user DEBUG - UserSecurityAdvice.before(58) | target: org.appfuse.service.impl.usermanageri...@19853c2 DEBUG - UserSecurityAdvice.before(59) | roles: [Lorg.springframework.security.GrantedAuthority;@1a2f9dd DEBUG - UserSecurityAdvice.before(66) | ----------------- /DEBUG ------------------ WARN - UserSecurityAdvice.before(99) | Access Denied: 'user' tried to change their role(s)! DEBUG - UserSecurityAdvice.before(54) | ----------------- DEBUG ------------------ DEBUG - UserSecurityAdvice.before(55) | method: public abstract org.appfuse.model.User org.appfuse.service.UserManager.saveUser(org.appfuse.model.User) throws org.appfuse.service.UserExistsException DEBUG - UserSecurityAdvice.before(56) | args: [Ljava.lang.Object;@d2ee5d DEBUG - UserSecurityAdvice.before(57) | User: user DEBUG - UserSecurityAdvice.before(58) | target: org.appfuse.service.impl.usermanageri...@1f568f DEBUG - UserSecurityAdvice.before(59) | roles: [Lorg.springframework.security.GrantedAuthority;@16c02df DEBUG - UserSecurityAdvice.before(66) | ----------------- /DEBUG ------------------ DEBUG - UserSecurityAdvice.before(54) | ----------------- DEBUG ------------------ DEBUG - UserSecurityAdvice.before(55) | method: public abstract org.appfuse.model.User org.appfuse.service.UserManager.saveUser(org.appfuse.model.User) throws org.appfuse.service.UserExistsException DEBUG - UserSecurityAdvice.before(56) | args: [Ljava.lang.Object;@f5bad0 DEBUG - UserSecurityAdvice.before(57) | User: user DEBUG - UserSecurityAdvice.before(58) | target: org.appfuse.service.impl.usermanageri...@bbd83d DEBUG - UserSecurityAdvice.before(59) | roles: [Lorg.springframework.security.GrantedAuthority;@718e31 DEBUG - UserSecurityAdvice.before(66) | ----------------- /DEBUG ------------------ I don't really understand what I could have done to cause this since I haven't been changing this part of the code and everything used to work smoothly. Another thing I have noticed is that when I run the SignupActionText textExecute in Eclipse then I never get into this if statement if (ctx.getAuthentication() != null) { ... } that is ctx.getAuthentication() returns null, still the test finishes successfully, is that expected? How come that is not happening when the same test is run from mvn jetty:run-war. best regards, Magnus On Tue, Jan 19, 2010 at 12:06 AM, Matt Raible <m...@raibledesigns.com> wrote: > Line 54 is: > Collection<GrantedAuthority> roles = auth.getAuthorities(); > So I'm guessing the user isn't authenticated or has no roles? What version > of AppFuse are you using? > On Jan 16, 2010, at 9:06 AM, Magnús Skúlason wrote: > > Hi, > All of a sudden I have started to get 4 failed tests when I run mvn > jetty:run-war > Tests in error: > testExecute(org.appfuse.webapp.action.SignupActionTest) > testAddExistingUser(org.appfuse.service.UserExistsExceptionTest) > testSave(org.appfuse.webapp.action.UserActionTest) > testSaveConflictingUser(org.appfuse.webapp.action.UserActionTest) > Tests run: 66, Failures: 0, Errors: 4, Skipped: 0 > They all start with: > java.lang.NullPointerException > at org.appfuse.service.UserSecurityAdvice.before(UserSecurityAdvice.java:54) > at > org.springframework.aop.framework.adapter.MethodBeforeAdviceInterceptor.invoke(MethodBeforeAdviceInterceptor.java:49) > at > org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171) > at > org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:106) > at > org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171) > at > org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:89) > at > org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171) > I am not aware of making any change that could result in this, also when I > run the tests in eclipse they successfully finish > When I start the application with: > mvn jetty:run-war -Dmaven.test.skip=true > it starts successfully and I don't get any errors, signing in both as admin > and regular user or signing up a new user. > Does anyone have a clue of what could be causing this? > best regards, > Magnus > --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@appfuse.dev.java.net For additional commands, e-mail: users-h...@appfuse.dev.java.net