本帖最后由 mail1239 于 2013-03-17 19:14:38 编辑

解决方案 »

  1.   

    Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'securityMetadataSource' defined in ServletContext resource [/WEB-INF/applicationContext-security.xml]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [cn.cbtvu.contect.service.MyInvocationSecurityMetadataSourceService]: Constructor threw exception; nested exception is java.lang.NullPointerException
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:997)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:943)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:485)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:294)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:225)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:291)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)
    at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:322)
    ... 69 more
    Caused by: org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [cn.cbtvu.contect.service.MyInvocationSecurityMetadataSourceService]: Constructor threw exception; nested exception is java.lang.NullPointerException
    at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:162)
    at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:76)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:990)
    ... 77 more
    Caused by: java.lang.NullPointerException
    at cn.cbtvu.contect.DAO.PowerInter.findByTSysPowersystem(PowerInter.java:54)
    at cn.cbtvu.contect.service.MyInvocationSecurityMetadataSourceService.loadResourceDefine(MyInvocationSecurityMetadataSourceService.java:90)
    at cn.cbtvu.contect.service.MyInvocationSecurityMetadataSourceService.<init>(MyInvocationSecurityMetadataSourceService.java:72)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
    at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:147)
    ... 79 more
    2013-3-17 18:48:02 org.apache.catalina.core.StandardContext listenerStart
      

  2.   


    PowerInter
    @Repository("powerInter")
    public class PowerInter {
    private static final Logger log = LoggerFactory.getLogger (PowerInter.class);
    @Resource(name="jdbcTemplate" )
    private JdbcTemplate JDBC;

     /**
     * @return the jDBC
     */
    public JdbcTemplate getJDBC() {
    return JDBC;
    }
    /**
     * @param jDBC the jDBC to set
     */
    public void setJDBC(JdbcTemplate jDBC) {
    System.out.println( "++++++++++++++++++authority_name1111++++++++++++++++++++++++++++" );
    JDBC = jDBC;
    }
    public PowerInter(){

    super();
    JDBC=null;
     
    }
    public PowerInter(JdbcTemplate JDBC){
    super();
     this.JDBC=JDBC;
     }
    public List<String> findByTSysPowersystem() {
    // TODO Auto-generated method stub

    System.out.println( "++++++++++++++++++authority_name++++++++++++++++++++++++++++" );
    if(JDBC==null)
    System.out.println( "++++++++++++++++++hell++++++++++++++++++++++++++++" );
    List<String> query = JDBC.query("select authority_name from Pub_authorities ",new RowMapper<String>(){ public String mapRow(ResultSet rs, int arg1) throws SQLException {
    // TODO Auto-generated method stub
    System.out.println(rs.getString("authority_name"));
    return rs.getString("authority_name");
    }

    });
    return  query;
    }
    public List<String> findByAutAllresource_string(String auth) {
    // TODO Auto-generated method stub

    List<String> query = JDBC.query("sselect resource_string " +
    "from Pub_Authorities_Resources,Pub_Resources,  Pub_authorities " +
    "where Pub_Authorities_Resources.resource_id=Pub_Resources.resource_id and " +
    " Pub_Authorities_Resources.resource_id=Pub_authorities.authority_id  and " +
    "   Authority_name=?",new Object[]{auth} ,new RowMapper<String>(){ public String mapRow(ResultSet rs, int arg1) throws SQLException {
    // TODO Auto-generated method stub
    return rs.getString("resource_string");
    }

    });
    return  query;
    }}
      

  3.   

     public PowerInter(){
             
            super();
            JDBC=null;
          
            }改为
     public PowerInter(){
             
          
            }无参构造函数,不要写函数体
      

  4.   

    试了不是这个问题 ,我怀疑是不是spring security3 问题  使用了 spring security 就不能使用注解了?