Skip to content

Accidental ClassLoader defineClass enforcement after #34677 #34824

Closed
@tongtongzheng1973

Description

@tongtongzheng1973

I migrated to spring boot 3.4.5 and get a error proxiedThreadLocalTargetSource

@Data
@Component
public class UserFilter implements Filter {

    @Autowired
    private UserStore userStore;

    @Override
    public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {

....
}

@Configuration
public class FilterConfig {

    @Bean
    public FilterRegistrationBean tenantFilterRegistration(UserFilter userFilter) {
        FilterRegistrationBean result = new FilterRegistrationBean();
        result.setFilter(userFilter);
        result.addUrlPatterns("/*");
        result.setName("User Store Filter");
        result.setOrder(1);
        return result;
    }

    @Bean(destroyMethod = "destroy")
    public ThreadLocalTargetSource threadLocalUserStore() {
        ThreadLocalTargetSource result = new ThreadLocalTargetSource();
        result.setTargetBeanName("userStore");
        return result;
    }

    @Primary
    @Bean(name = "proxiedThreadLocalTargetSource")
    public ProxyFactoryBean proxiedThreadLocalTargetSource(ThreadLocalTargetSource threadLocalTargetSource) {
        ProxyFactoryBean result = new ProxyFactoryBean();
        result.setTargetSource(threadLocalTargetSource);
        return result;
    }

    @Bean(name = "userStore")
    @Scope(scopeName = "prototype")
    public UserStore userStore() {
        return new UserStore();
    }

}

@Data
public class UserStore {

    Long userId;
    String email;
    String name;
    String firstName;
    String lastName;

    public void clear() {
        this.userId = null;
        this.email = null;
        this.name = null;
        this.firstName=null;
        this.lastName=null;
    }

}
o.s.b.web.embedded.tomcat.TomcatStarter  : Error starting Tomcat context. Exception: org.springframework.beans.factory.UnsatisfiedDependencyException. Message: Error creating bean with name 'tenantFilterRegistration' defined in class path resource [com/acme/config/FilterConfig.class]: Unsatisfied dependency expressed through method 'tenantFilterRegistration' parameter 0: Error creating bean with name 'userFilter': Unsatisfied dependency expressed through field 'userStore': Error creating bean with name 'proxiedThreadLocalTargetSource': FactoryBean threw exception on object creation

Metadata

Metadata

Assignees

Labels

in: coreIssues in core modules (aop, beans, core, context, expression)status: backportedAn issue that has been backported to maintenance branchesstatus: feedback-providedFeedback has been providedtype: regressionA bug that is also a regression

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions