在 XPage 内的 Domino 服务器上使用 Codehaus Jackson 会产生以下堆栈跟踪
[07715:00011-2293234576] 04/02/2013 10:28:12 AM HTTP JVM: java.lang.SecurityException: not allowed to access members in class class java.util.ArrayList
[07715:00011-2293234576] 04/02/2013 10:28:12 AM HTTP JVM: at java.lang.Throwable.<init>(Throwable.java:67)
[07715:00011-2293234576] 04/02/2013 10:28:12 AM HTTP JVM: at lotus.notes.AgentSecurityManager.checkMemberAccess(Unknown Source)
[07715:00011-2293234576] 04/02/2013 10:28:12 AM HTTP JVM: at java.lang.Class.checkMemberAccess(Class.java:112)
[07715:00011-2293234576] 04/02/2013 10:28:12 AM HTTP JVM: at java.lang.Class.getDeclaredMethods(Class.java:675)
[07715:00011-2293234576] 04/02/2013 10:28:12 AM HTTP JVM: at org.codehaus.jackson.map.introspect.AnnotatedClass._addMemberMethods(AnnotatedClass.java:620)
[07715:00011-2293234576] 04/02/2013 10:28:12 AM HTTP JVM: at org.codehaus.jackson.map.introspect.AnnotatedClass.resolveMemberMethods(AnnotatedClass.java:413)
[07715:00011-2293234576] 04/02/2013 10:28:12 AM HTTP JVM: at org.codehaus.jackson.map.introspect.BasicClassIntrospector.classWithCreators(BasicClassIntrospector.java:185)
[07715:00011-2293234576] 04/02/2013 10:28:12 AM HTTP JVM: at org.codehaus.jackson.map.introspect.BasicClassIntrospector.collectProperties(BasicClassIntrospector.java:157)
[07715:00011-2293234576] 04/02/2013 10:28:12 AM HTTP JVM: at org.codehaus.jackson.map.introspect.BasicClassIntrospector.forSerialization(BasicClassIntrospector.java:96)
[07715:00011-2293234576] 04/02/2013 10:28:12 AM HTTP JVM: at org.codehaus.jackson.map.introspect.BasicClassIntrospector.forSerialization(BasicClassIntrospector.java:16)
[07715:00011-2293234576] 04/02/2013 10:28:12 AM HTTP JVM: at org.codehaus.jackson.map.SerializationConfig.introspect(SerializationConfig.java:973)
在 java.policy 我尝试了以下设置:
// Jackson (JSON)
permission java.lang.reflect.ReflectPermission "suppressAccessChecks";
// permission java.lang.RuntimePermission "accessDeclaredMembers";
// permission java.lang.RuntimePermission "accessClassInPackage.java.util.ArrayList";
permission java.security.AllPermission;
第一个权限与当前问题无关。我试图用第二个和第三个设置来解决它,但它不起作用。
只有最后一个设置有帮助,但这已经很重要了......有更好的解决方案吗?