Peter Penzov
Peter Penzov

Reputation: 1678

Cannot load .class file with ResourcePatternResolver

I'm trying to load a .class file into Spring project. I tried this:

            WebApplicationContext context = ContextLoader.getCurrentWebApplicationContext();

            ResourcePatternResolver resolver = (ResourcePatternResolver)context;
            Resource[] res = resolver.getResources("classpath*:/opt/validation/*.class");

            resolver.getClassLoader().loadClass("ValidateProcessor");

But I I get error Root cause of ServletException. java.lang.ClassNotFoundException: ValidateProcessor

The file ValidateProcessor.class is present into that directory but it's not found. Can you give me some advice how to fix this issue please?

Upvotes: 0

Views: 113

Answers (1)

Roland Weisleder
Roland Weisleder

Reputation: 10511

You have to use the full qualified class name. In case the class is located in a package opt.validation you should load:

resolver.getClassLoader().loadClass("opt.validation.ValidateProcessor");

Upvotes: 1

Related Questions