0

i have Spring-boot project, scaning the folders and indexing all finded photos with keywords from metadata.

i have the next structure :

java
  de.stadt
    controllers
    entitys
    repository
    services
      ImageService
    tools
      ImageProcessing
      ScanDirs

when i'm trying to call Tools class ScanDirs with RecursiveTask from ImageService i have java.lang.NullPointerException: null how right to push data to constructur ScanDirs?

at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
        at java.util.concurrent.ForkJoinTask.getThrowableException(ForkJoinTask.java:598)
        at java.util.concurrent.ForkJoinTask.reportException(ForkJoinTask.java:677)
        at java.util.concurrent.ForkJoinTask.join(ForkJoinTask.java:720)
        at java.util.concurrent.ForkJoinPool.invoke(ForkJoinPool.java:2616)
        at de.stadt.presse.service.ImageService.callScanDirsToolsClass(ImageService.java:67)

ImageService.class:

@Service
public class ImageService {
  @Autowired
  private ImageRepository imageRepository;
  @Autowired
  private KeywordsService keywordsService;
  @Autowired
  private ScanDirs task;

  private static final int AVAILABLE_PROCESSORS = Runtime.getRuntime().availableProcessors();
  private final ForkJoinPool pool = new ForkJoinPool(AVAILABLE_PROCESSORS);

  public boolean callScanDirsToolsClass(String folderPath, String thumpPath, String googleVisionLocalPath,
                          int scaleHeight, int scaleHeightForGoogleVision, String strText) {


        task = new ScanDirs(folderPath, thumpPath, googleVisionLocalPath, scaleHeight,
 scaleHeightForGoogleVision, strText); //<-----------------if pusching the data here false . how right to push the data to the constructur  ?
        final Boolean result = pool.invoke(task);
        System.out.println(result);

        return true;
          }
       }

the ScanDirs.class look like:

 @Service
 @NoArgsConstructor
public class ScanDirs extends RecursiveTask<Boolean> {

  @Autowired
  private ImageService imageService;
  @Autowired
  private KeywordsService keywordsService;

  ...

  public ScanDirs(String folder, String thum........) {
    ...
  }

  @Override
  protected Boolean compute() {


    Image image = imageService.findByImagePath(file.getPath());

  ...

}

SezarA
  • 35
  • 7
  • THANK YOU. i try it with @Autowird but still the problem in the same place, ImageService can't find the ScanDirs Task . how right to push data to constructure Service? – SezarA Jul 09 '18 at 10:28
  • and the ScanDals class make Recursive task! – SezarA Jul 09 '18 at 10:40

0 Answers0