开发者

ApplicationError when trying to implement an edited version of the Secure module

开发者 https://www.devze.com 2023-02-21 02:31 出处:网络
I\'m implementing an edited version of the Secure controller, default in the latest Play Framework. I have read several times that, if you want to customize the Secure behaviour, you\'re better off c

I'm implementing an edited version of the Secure controller, default in the latest Play Framework.

I have read several times that, if you want to customize the Secure behaviour, you're better off copying the source of the Secure module, and start customizing it.

So I did, and after editing the needed dependencies I received following error:

    Execution exception
NullPointerException occured : null

In /app/controllers/SecureController.java (around line 194)

190:
                 security = classes.get(0);
191:
             }
192:
             if(security==null)System.out.println("security is null");
193:
             try {
194:
                 return Java.invokeStaticOrParent(security, m, args);
195:
             } catch(InvocationTargetException e) {
196:
                 throw e.getTargetException();
197:
             }
198:
         }
199:

200:
     }

The first logic conclusion to jump to is: there are no classes that implement the needed Secure$Security inner class. But there most certainly is a subclass, so I was wondering how this error can be fixed.

A debugging session learns that the classes.get(0) does contain the class that has the @With annotation. So the null pointer exception must be caused by something within the class that contains the @With(SecureController). But I left that class just th开发者_JAVA百科e way it was, I just edited the reference within the With annotation.

So my guess is that somehow, there is a null pointer within the class implementation. But even when I implement default behaviour, without any references, it still generates a nullpointerexception.

EDIT: I found the cause of this error, but the 'why' isn't clear. This line is found in the implementation of the authenticate(...) method in the subclass of SecureController$Security:

flash.put("url", request.url);

Why does this fail?

I understand this situation may be very hard to reproduce, but I was wondering if someone already experienced the same issue.

Thanks for the help (on many Play! related topics) so far.


the Scope.Flash class does not allow you to store null values. Perhaps you unset or failed to set request.url elsewhere in your modifications?

0

精彩评论

暂无评论...
验证码 换一张
取 消