ok it seems that my function is being null
so i created a new SpringPage file
that has some methods the BorderPage extends this page

public class SpringPage extends Page implements ApplicationContextAware,
AuthorizationService {

        protected Logger logger;
        private ApplicationContext applicationContext;
        
        @SuppressWarnings("unchecked")
        public Logger getLogger(Class cl) {
                if (logger == null) {
                        logger = Logger.getLogger(cl);
                }
                return logger;
        }
        
        public DatabaseFunctions getDatabaseFunctions() {
                logger.error("running getFunctions");
                return (DatabaseFunctions) getBean("databaseFunctions");
        }

        public DatabaseService getDatabaseService() {
                return (DatabaseService) getBean("databaseService");
        }
        
        public PermissionService getPermissionService() {
                return (PermissionService) getBean("permissionService");
        }
        
        public String getUserName() {
                return 
SecurityContextHolder.getContext().getAuthentication().getName();
        }

        public boolean hasPermission(String permission) {
                return AuthorityUtils.userHasAuthority(permission);
        }
        
        public Authentication getAuthentication() {
                return SecurityContextHolder.getContext().getAuthentication();
        }
        
        public GrantedAuthority[] getAuthorities() {
                return getAuthentication().getAuthorities();
        }

        public Object getBean(String beanName) {
        if (beanName == null) {
            throw new IllegalArgumentException("Null name parameter");
        }
        if (applicationContext == null) {
            throw new IllegalStateException("Application context is not
set");
        }
        return applicationContext.getBean(beanName);
    }
        
        public void setApplicationContext(ApplicationContext applicationContext)
                        throws BeansException {
                this.applicationContext = applicationContext;
                
        }

as you see everything is implemented
when loading aplications applicationContext is being asigned but when i run
my app file

for example this one

import org.apache.log4j.Logger;

public class HomePage extends BorderPage {

        private Logger logger = getLogger(getClass());
        
        @SuppressWarnings("unchecked")
        public HomePage() {
                
                if (hasPermission(Permission.LOGIN)) {
                        logger.error("has permision :" + getUserName());
                }
        
                logger.error("Logged in as :" + getUserName());
                logger.error("Text from interface " +
getDatabaseFunctions().getText(getUserName()));
                getModel().put("title", getUserName());
        }
}

i get 
java.lang.IllegalStateException: Application context is not set
the line in bold

how can i save application context?

i attaching my web.xml
besided i am using spring security libs with CAS al logins and my custom
UserDetailService is working
http://n2.nabble.com/file/n3066822/web.xml web.xml 



-- 
View this message in context: 
http://n2.nabble.com/problem-with-spring-injection-tp3049285p3066822.html
Sent from the click-user mailing list archive at Nabble.com.

Reply via email to