Tag: decorator

为什么在装饰器中调用安全认证属性`principal.displayName`会抛出exception?

是否有理由在装饰器中调用安全认证属性principal.displayName会导致问题? 我将它设置为sitemesh装饰器中的变量: 但是它会产生这个exception: java.lang.RuntimeException: javax.servlet.ServletException: javax.servlet.jsp.JspException: Invalid property ‘principal.displayName’ o f bean class [org.springframework.security.authentication.AnonymousAuthenticationToken]: Bean property ‘principal.displayName’ is not readable or has an invalid getter method: Does the return type of the getter match the parameter type of the setter? at com.opensymphony.sitemesh.webapp.decorator.BaseWebAppDecorator.render(BaseWebAppDecorator.java:39) at com.opensymphony.sitemesh.webapp.SiteMeshFilter.doFilter(SiteMeshFilter.java:84) at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157) at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:388) at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216) at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182) at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765) at […]

Java EE 7 – @Decorator,@ Stateless和@PersistenceContext = nullpointerException

我在java ee 7(glassfish 4)中使用装饰模式。 我有这个装饰师 @Decorator public class FooIndexer implements FooService { @Inject @Delegate FooService fooService; private Logger logger = Logger.getLogger(FooIndexer.class.getName()); //@Inject //Indexer indexer; @Override public Foo create(Foo foo, boolean index) { fooService.create(foo, index); if (index) { System.out.println(“Im in”); } return foo; } } 而这个ejb类 @Stateless(name = “fooService”) @TransactionAttribute(TransactionAttributeType.REQUIRES_NEW) @DeclareRoles({“ADMINISTRATOR”, “USER”}) public class FooServiceImpl implements […]